-
Notifications
You must be signed in to change notification settings - Fork 773
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
OTLP LogExporter to special case {OriginalFormat} to populate body #3182
OTLP LogExporter to special case {OriginalFormat} to populate body #3182
Conversation
} | ||
else | ||
{ | ||
Assert.Equal("OpenTelemetry {Greeting} {Subject}!", otlpLogRecord.Body.StringValue); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is the "special" treatment of {OriginalFormat} key.
{ | ||
Assert.Null(otlpLogRecord.Body); | ||
} | ||
else |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
intentionally making the same Assert on If..Else, to make it easy for readers :)
Codecov Report
@@ Coverage Diff @@
## main #3182 +/- ##
==========================================
+ Coverage 84.85% 84.87% +0.01%
==========================================
Files 259 259
Lines 9326 9330 +4
==========================================
+ Hits 7914 7919 +5
+ Misses 1412 1411 -1
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
Co-authored-by: Alan West <[email protected]>
test/OpenTelemetry.Exporter.OpenTelemetryProtocol.Tests/OtlpLogExporterTests.cs
Show resolved
Hide resolved
src/OpenTelemetry.Exporter.OpenTelemetryProtocol/Implementation/LogRecordExtensions.cs
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
…//github.com/cijothomas/opentelemetry-dotnet into cijothomas/otlplog_specialcaseoriginalformat
([#3177](https://github.com/open-telemetry/opentelemetry-dotnet/pull/3177)) | ||
|
||
* LogExporter to special case {OriginalFormat} to populate |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
* LogExporter to special case {OriginalFormat} to populate | |
* LogExporter to special case '{OriginalFormat}' to populate |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
This PR modifies OTLP LogExporter to:
"specially" treat {OriginalFormat} key from
LogRecord.StateValues
, and populate Body from its value, ifLogRecord.FormattedMessage
is not available.Why:
Official docs on logging recommends (or rather only talks about), using the extensions methods to do logging, which would result in storing the "template" as {OriginalFormat}
Since this is the most common scenario, I am proposing to "special" case this, to populate body from. (If user opted-in for
IncludeFormattedMessage=true
, then this special casing is not applied, and {OriginalFormat} get stores as just any other attribute, and Body will be theLogRecord.FormattedMessage
. Okay to change that behavior if there is agreement.)