Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Parse basic logging severity text values #446

Merged
merged 2 commits into from Jul 1, 2022

Conversation

damemi
Copy link
Member

@damemi damemi commented Jun 29, 2022

Fixes #442

exporter/collector/logs.go Outdated Show resolved Hide resolved
@@ -349,7 +382,14 @@ func (l logMapper) logToSplitEntries(
if log.SeverityNumber() < 0 || int(log.SeverityNumber()) > len(severityMapping)-1 {
return []logging.Entry{entry}, fmt.Errorf("Unknown SeverityNumber %v", log.SeverityNumber())
}
entry.Severity = severityMapping[log.SeverityNumber()]
logSeverity := severityMapping[log.SeverityNumber()]
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The nested boolean logic is a bit hard for me to follow. Would you consider instead:

func cloudLoggingSeverity(log plog.LogRecord) logging.Severity {
  severityNumber := log.SeverityNumber()
  if severityNumber == 0 {
    severityNumber := otelSeverityTexts[strings.ToLower(log.SeverityText())]
  }
  return severityMapping[severityNumber]
}

The double negative in the comment is also difficult, could you rephrase it? e.g., document how severity mapping works overall, rather than this particular sub-case.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

updated, I changed the variable declaration and added more comments but kept the nested boolean. Hoping the new comment explains it better, we want to check that the SeverityText exists in our map (in other words, severityNumber == 0 isn't enough on its own to do this logic)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Exporter does not recognize log levels or any extra attributes
2 participants