You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I went with AddOpenTelemetryLogging instead of SendToOpenTelemetry because all of the ILoggingBuilder extensions today are named "AddThing" so it just seemed weird. But I'm open to naming it whatever.
Now the OpenTelemetry Specification has LoggerProvider and we have a LoggerProviderBuilder API. The SDK LoggerProvider is fed into the ILogger integration (OpenTelemetryLoggerProvider).
There are different ways we could approach this. Today we have extensions for logging that target OpenTelemetryLoggerOptions. We will need to target LoggerProviderBuilder now. We could forever have two versions of every extension, but that seems lame.
This PR is adding a new extension AddOpenTelemetryLogging to try and bridge the two worlds. AddOpenTelemetry extension and OpenTelemetryLoggerOptions.AddProcessor and OpenTelemetryLoggerOptions.SetResourceBuilder methods would be obsoleted as would our existing extensions on OpenTelemetryLoggerOptions.
All of these styles can be interchanged.
// Configure OTel via ILoggingBuilderappBuilder.Logging.AddOpenTelemetryLogging(builder =>builder.ConfigureLoggerOptions(options =>options.IncludeFormattedMessage=true).AddConsoleExporter());
// Configure OTel via OpenTelemetryBuilderappBuilder.Services.AddOpenTelemetry().WithLogging(builder =>builder.ConfigureLoggerOptions(options =>options.IncludeFormattedMessage=true).AddConsoleExporter());
// Configure OTel via OpenTelemetryBuilderappBuilder.Services.AddOpenTelemetry().WithLogging(builder =>builder.AddConsoleExporter());// Configure ILogger options via Options APIappBuilder.Services.Configure<OpenTelemetryLoggerOptions>(options =>options.IncludeFormattedMessage=true);
// Configure OTel via ILoggingBuilderappBuilder.Logging.AddOpenTelemetryLogging(builder =>builder.AddConsoleExporter());// Configure ILogger options via Options APIappBuilder.Services.Configure<OpenTelemetryLoggerOptions>(options =>options.IncludeFormattedMessage=true);
Merge requirement checklist
CONTRIBUTING guidelines followed (nullable enabled, static analysis, etc.)
I went with AddOpenTelemetryLogging instead of SendToOpenTelemetry because all of the ILoggingBuilder extensions today are named "AddThing" so it just seemed weird. But I'm open to naming it whatever.
Yeah, I think any name we pick will be more awkward than AddOpenTelemetry() and its just a matter of picking which particular awkward one we want. If I was picking my favorite I'd probably still take SendToOpenTelemetry(), but this one seems fine too.
This PR was marked stale due to lack of activity and will be closed in 7 days. Commenting or Pushing will instruct the bot to automatically remove the label. This bot runs once per day.
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
StaleIssues and pull requests which have been flagged for closing due to inactivity
2 participants
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.
Relates to #4433
Relates to #4496
Changes
ILoggingBuilder.AddOpenTelemetryLoggingextension for configuringLoggerProviderBuilderLoggerProviderBuilder.ConfigureLoggerOptionsextension for configuringOpenTelemetryLoggerOptionsOverview
This is a draft implementation of @noahfalk's comment: #4496 (comment)
I went with
AddOpenTelemetryLogginginstead ofSendToOpenTelemetrybecause all of the ILoggingBuilder extensions today are named "AddThing" so it just seemed weird. But I'm open to naming it whatever.Details
Today we configure logging like this:
"options" is
OpenTelemetryLoggerOptionsclass.Now the OpenTelemetry Specification has
LoggerProviderand we have aLoggerProviderBuilderAPI. The SDKLoggerProvideris fed into theILoggerintegration (OpenTelemetryLoggerProvider).There are different ways we could approach this. Today we have extensions for logging that target
OpenTelemetryLoggerOptions. We will need to targetLoggerProviderBuildernow. We could forever have two versions of every extension, but that seems lame.This PR is adding a new extension
AddOpenTelemetryLoggingto try and bridge the two worlds.AddOpenTelemetryextension andOpenTelemetryLoggerOptions.AddProcessorandOpenTelemetryLoggerOptions.SetResourceBuildermethods would be obsoleted as would our existing extensions onOpenTelemetryLoggerOptions.All of these styles can be interchanged.
Merge requirement checklist