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

Adding an override to LoggerProvider.GetLogger #6132

Open
wants to merge 4 commits into
base: main
Choose a base branch
from

Conversation

juliuskoval
Copy link
Contributor

Towards #4433
LoggerProvider.GetLogger should accept attributes according to the spec.

Changes

I added an overload to the LoggerProvider.GetLogger method which accepts attributes and I modified the ProtobufOtlpLogSerializer so that it now exports both the version of instrumentation scope and the associated attributes.

Merge requirement checklist

  • CONTRIBUTING guidelines followed (license requirements, nullable enabled, static analysis, etc.)
  • Unit tests added/updated
  • Appropriate CHANGELOG.md files updated for non-trivial changes
  • Changes in public API reviewed (if applicable)

@juliuskoval juliuskoval requested a review from a team as a code owner February 12, 2025 20:04
@github-actions github-actions bot added pkg:OpenTelemetry.Api Issues related to OpenTelemetry.Api NuGet package pkg:OpenTelemetry.Exporter.OpenTelemetryProtocol Issues related to OpenTelemetry.Exporter.OpenTelemetryProtocol NuGet package labels Feb 12, 2025
{
this.Version = version;
this.Attributes = attributes;
Copy link
Member

Choose a reason for hiding this comment

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

If we are going to do this we need to take a copy here so they can't be mutated after being set.

Same idea as here, which also sorts:

https://github.com/dotnet/runtime/blob/fcd9339f16500a4954d84e9d0d93a99e84b08987/src/libraries/System.Diagnostics.DiagnosticSource/src/System/Diagnostics/ActivitySource.cs#L42-L49

@github-actions github-actions bot added the perf Performance related label Feb 18, 2025
@juliuskoval
Copy link
Contributor Author

I added a benchmark since @Kielek asked me to here. Sorting the instrumentation scope attributes increases the performance impact in the benchmark I added by about 40%, so I'm not sure if it's worth it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
perf Performance related pkg:OpenTelemetry.Api Issues related to OpenTelemetry.Api NuGet package pkg:OpenTelemetry.Exporter.OpenTelemetryProtocol Issues related to OpenTelemetry.Exporter.OpenTelemetryProtocol NuGet package
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants