-
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
[sdk-logs] Update LogRecord to keep CategoryName and Logger in sync #5317
[sdk-logs] Update LogRecord to keep CategoryName and Logger in sync #5317
Conversation
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.
One thing @alanwest will like is OtlpLogExporter no longer has any knowledge of CategoryName.
Yes I do like it. But c'mon don't we all like a little spec compliance?
…github.com/CodeBlanch/opentelemetry-dotnet into sdk-logs-categoryname-instrumentationscope
@@ -49,7 +47,7 @@ public OtlpLogRecordTransformer(SdkLimitOptions sdkLimitOptions, ExperimentalOpt | |||
var otlpLogRecord = this.ToOtlpLog(logRecord); | |||
if (otlpLogRecord != null) | |||
{ | |||
var scopeName = logRecord.CategoryName ?? logRecord.Logger?.Name ?? DefaultScopeName; | |||
var scopeName = logRecord.Logger.Name; |
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.
In the tests, we are proving that the values of logRecord.Logger.Name
and logRecord.CategoryName
are the same. Is there any difference in using one over the other in this context?
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.
OTLPExporter can remain agnostic to ILogger specific CategoryName
.
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.
No practical difference between the two. This is more of a philosophical change which brings OtlpExporter closer to the spec. The goal being it doesn't know anything about any specific logging framework (ILogger being one of those).
Follow-up to #5300 (comment)
Changes
LogRecord.Logger
to aLogger
built fromCategoryName
.LogRecord.CategoryName
getter to returnLogRecord.Logger.Name
.LogRecord.CategoryName
setter to changeLogRecord.Logger
(if needed).LogRecord.Logger.Name
.Details
The big benefit to this change is if users start using something which is emitting logs via the Log Bridge API AND they use an exporter coded to expect
CategoryName
they will now have something set.One thing @alanwest will like is OtlpLogExporter no longer has any knowledge of
CategoryName
. You're welcome @alanwest! 😄Merge requirement checklist
CHANGELOG.md
files updated for non-trivial changes