-
Notifications
You must be signed in to change notification settings - Fork 772
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
Decide what to do with LogRecord.CategoryName
#3491
Comments
@alanwest would you elaborate the importance and urgency of this change? I can imagine with "Event" API effort, we might reconsider if LogLevel should be made optional. Also consider Scopes - that might be specific to ILogger, too. A simple approach would be - not deprecating anything at this moment, until we have good understanding of what's the final shape. Or maybe this can be marked as "changes that should happen in major version 2 in the future". |
I do not feel strongly that any change is immediately urgent, but I do think the conversation regarding our stance on using This originated from a conversation with @CodeBlanch here https://github.com/open-telemetry/opentelemetry-dotnet/pull/3454/files#r927184812. Currently, the Serilog sink is using CategoryName and he questioned whether to also use it for the EventSource integration. I figure if we decide to further our use of CategoryName it would be more difficult to change or more disruptive to obsolete it later if we thought that was the right thing to do in the future.
I think option 1 embodies this spirit. That is, things like CategoryName, Scopes, and EventId may just become understood to be exclusively for use with ILogger. I guess I was less concerned with LogLevel since I suspect it may always map nicely to the data model's notion of severity number/text - which is already optional. |
Just FYI from the perspective of LogEmitter, the only thing required/guaranteed to always be there is Timestamp. Everything else is optional. I did that because I was thinking about the upcoming "Event" API.
|
💯💯💯💯💯 |
Ah yea, None makes sense.
Yes, understood. The optionality of fields is not really related to my question at hand. To clarify, my question is: when we do populate a field - optionality aside - how does it get handled by the components we maintain? I'm picking specifically on Narrowing the scope of my question, here's the specific "weird" situation we have today:
I think the options I've posed are all valid ways to address this situation. There may be other options. |
I like option1 - CategoryName, Scopes, EventId etc are ILogger specific concepts, and by OpenTelemetry .NET SDK preferentially treating We should not force other things (like Serilog sinks or other LogEmitter usages) to populate the |
This conversation is pulling in a few different directions, I'll try to reply generally.
I think this is good to do on
Agree with CategoryName. Agree with Scopes (they are already NOT available on So here would be my plan of attack...
|
^ agree with this "attack" plan :) |
Yes, agreed. I think this solves the immediate issues at hand. And big 👍 to the guardrails against using any "ILogger stuff" for non-ILogger things - maybe this is something that's circled back to later, but I think it's good to start with this stance. |
Somewhat related/similar is - OTel .NET decided to use |
I was on the log SIG this week. There was some discussion about what Java does. Apparently what the Processor gets is a read/write interface to the data (span, log, whatever). Then the exporter gets a read-only interface. Kind of interesting. Not super helpful for us because we can't add interfaces to Activity 😄 We would have to wrap it which would be another allocation (or a boxing op). |
Do you see benefit of having such difference besides preventing accidental modification from the exporter? |
We have seen users use reflection to get around things being read-only so my currently feeling is: Just make everything mutable and let the users decide if they want to follow the spec guidance or not 😄 |
https://github.com/open-telemetry/opentelemetry-specification/blob/main/specification/logs/data-model.md#field-instrumentationscope As per this guidance, the logger name (java equivalent : https://docs.oracle.com/javase/7/docs/api/java/util/logging/Logger.html#getLogger(java.lang.String) should be part of the instrumentation scope. |
Removing from 1.6 milestone, as it was decided to remove CategoryName completely to unblock 1.6 stable release. The issue is still open and importantly, the category name is not even going to be exported in 1.6 stable. This will be brought back in 1.7.* prerleases, probably under experimental feature, as it is not yet solidified what to do with category/exception/eventid,name. |
Hi folks! I think this issue is stale - category names were routed into |
@vishweshbankwar This can be closed right? CategoryName is exported as InstrumentationScope in OTLP Exporters now. |
This was fixed in 1.7.0 |
Related conversation https://github.com/open-telemetry/opentelemetry-dotnet/pull/3454/files#r927184812
The top-level
name
field was dropped from the log data model. Originally, .NET'sLogRecord.CategoryName
was intended to serve the purpose of this top-level field.CategoryName
cannot be removed because it is part of .NET's stable log data model, so we need to decide what to do with it.Options
1. Only use it for
ILogger
Each exporter is responsible for how it represents
CategoryName
. Currently, the OTLP exporter translates this to an attribute nameddotnet.ilogger.category
opentelemetry-dotnet/src/OpenTelemetry.Exporter.OpenTelemetryProtocol/Implementation/LogRecordExtensions.cs
Lines 78 to 86 in cf3dfc5
If we agree to only use
CategoryName
for the purpose ofILogger
then we could keep the OTLP exporter as it is. Though, we should decide if it makes sense to mimic this behavior in other exporters and components like log enrichers.2. Make use of it across all logging frameworks we support
The Serilog sink makes use of
CategoryName
opentelemetry-dotnet/src/OpenTelemetry.Extensions.Serilog/OpenTelemetrySerilogSink.cs
Lines 71 to 75 in bfabe9b
This is problematic from the standpoint of the OTLP exporter. If we want to make use of
CategoryName
across logging frameworks, then we need to devise a generically named attribute that it gets mapped to.3. Abandon the use of
CategoryName
from all SDK componentsPerhaps the cleanest option is to abandon the use of
CategoryName
across all logging components. For each logging framework we support, if the framework has some notion of "category", we would map that to an attribute named appropriately for the framework - e.g.,ilogger.category
,serilog.context
,event_source.name
.If we take this approach, it might make sense to mark
CategoryName
obsolete.Though, we still would need to decide what to do if an end user wrote their own extension and made use of
CategoryName
. Should we map it to a generic attribute? e.g.,dotnet.otel.category_name
I'm personally leaning towards option 3. There is an open issue asking to reintroduce the
name
field to the log data model. If this does happen in the future, it might make sense to keep ourCategoryName
field obsolete and instead introduce a new field.The text was updated successfully, but these errors were encountered: