-
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
[Logs-branch] Add LoggerProvider spec changes #3707
Merged
CodeBlanch
merged 29 commits into
open-telemetry:main-logs
from
CodeBlanch:log-api-additions
Sep 30, 2022
Merged
[Logs-branch] Add LoggerProvider spec changes #3707
CodeBlanch
merged 29 commits into
open-telemetry:main-logs
from
CodeBlanch:log-api-additions
Sep 30, 2022
Conversation
This file contains 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
reyang
approved these changes
Sep 29, 2022
Codecov Report
Additional details and impacted files@@ Coverage Diff @@
## main-logs #3707 +/- ##
=============================================
+ Coverage 87.14% 87.27% +0.13%
=============================================
Files 274 296 +22
Lines 10008 10590 +582
=============================================
+ Hits 8721 9242 +521
- Misses 1287 1348 +61
|
alanwest
approved these changes
Sep 30, 2022
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.
BLRP! Excuse me...
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.
Fixes #3637
Description
This PR brings the changes reverted on #3702 with additions from #3677 to the
main-logs
branch. Since it is now a dedicated branch things have been madepublic
as if the spec was stable. Making things public is helpful to see the true shape and vet the usage 🔍Changes
LoggerProvider
\Logger
API from the OpenTelemetry Specification.Body
&Attributes
onLogRecord
and gives new meaning to theOpenTelemetryLoggerOptions.ParseStateValues
option.Public API Changes
OpenTelemetry.Api
OpenTelemetry
Also...
LoggerProviderBuilder
API.Backwards compatibility
The stable API in 1.3.1 uses OpenTelemetryLoggerOptions as the builder for logging. There isn't much to it, only
AddProcessor
andSetResourceBuilder
are available. Extensions are coded to use that API when building up the provider. 1.4 is addingConfigureResource
.This PR is essentially splitting things up so that
LoggingProviderBuilder
is responsible for building the specLoggerProvider
andOpenTelemetryLoggerOptions
is responsible for configuring theOpenTelemetryLoggerProvider
which is theILogger
integration.This was tricky and I spent a lot of time trying many different things. This is the best I could come up with! Open to suggestions 🤔
AddProcessor
,SetResourceBuilder
, &ConfigureResource
still exist onOpenTelemetryLoggerOptions
. Code and extensions that rely on them will continue to function. How this works is anything set on the options will be applied to the provider when it is ready.LoggingProviderBuilder
has all the great stuff now. This is the API we want to use instead. To encourage migrationAddProcessor
,SetResourceBuilder
, &ConfigureResource
are now marked asObsolete
as are the extensions usingOpenTelemetryLoggerOptions
. New extensions have been added targetingLoggingProviderBuilder
instead.Here is some working 1.3.1/1.4 code:
That will continue to work but now generates warnings due to the obsoletions. Here is the new pattern:
AddOpenTelemetry
returnsOpenTelemetryLoggingBuilder
which implementsLoggerProviderBuilder
to configure the builder.This pattern works equally well:
As does...
The first pattern configures everything off of
ILoggingBuilder
in one spot. The second two configureLoggerProvider
independently and then tellILoggerBuilder
(ILogger integration) to use it. We don't have to provide a "one-spot" option, but if ILogger integration is our most common scenario it is kind of nice.TODOs
CHANGELOG.md
updated for non-trivial changes