OTLP LogExporter to special case {OriginalFormat} to populate body#3182
Merged
cijothomas merged 5 commits intoApr 14, 2022
Merged
Conversation
cijothomas
commented
Apr 14, 2022
| } | ||
| else | ||
| { | ||
| Assert.Equal("OpenTelemetry {Greeting} {Subject}!", otlpLogRecord.Body.StringValue); |
Member
Author
There was a problem hiding this comment.
This is the "special" treatment of {OriginalFormat} key.
cijothomas
commented
Apr 14, 2022
| { | ||
| Assert.Null(otlpLogRecord.Body); | ||
| } | ||
| else |
Member
Author
There was a problem hiding this comment.
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
|
alanwest
reviewed
Apr 14, 2022
Co-authored-by: Alan West <3676547+alanwest@users.noreply.github.com>
alanwest
reviewed
Apr 14, 2022
…//github.com/cijothomas/opentelemetry-dotnet into cijothomas/otlplog_specialcaseoriginalformat
reyang
reviewed
Apr 14, 2022
| * LogExporter to correctly map Severity to OTLP. | ||
| ([#3177](https://github.com/open-telemetry/opentelemetry-dotnet/pull/3177)) | ||
|
|
||
| * LogExporter to special case {OriginalFormat} to populate |
Member
There was a problem hiding this comment.
Suggested change
| * LogExporter to special case {OriginalFormat} to populate | |
| * LogExporter to special case '{OriginalFormat}' to populate |
This was referenced Apr 20, 2022
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This PR modifies OTLP LogExporter to:
"specially" treat {OriginalFormat} key from
LogRecord.StateValues, and populate Body from its value, ifLogRecord.FormattedMessageis 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.)