Repository navigation
Conversation
…cope configuration Allow constructing `OpentelemetryLog` from a caller-managed `SdkLoggerProvider` and `InstrumentationScope` via `OpentelemetryLog::from_provider` (plus `OpentelemetryLog::with_make_body`), and allow overriding the builder's full `InstrumentationScope` via `OpentelemetryLogBuilder::scope`. Appenders constructed via `from_provider` leave provider shutdown to the caller (or `opentelemetry_sdk`'s final-reference drop) rather than calling `SdkLoggerProvider::shutdown` when an individual appender drops, so multiple logging channels can share one provider, resource, and processor pipeline with distinct scopes. Signed-off-by: tison <wander4096@gmail.com>
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
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.
Summary
OpentelemetryLogBuildercurrently creates a dedicatedSdkLoggerProvider(with_batch_exporter), allows setting only theInstrumentationScopename string, and unconditionally callsSdkLoggerProvider::shutdowninsideOpentelemetryLog::drop. That prevents callers from sharing oneSdkLoggerProvider(with customResourceattributes or customLogProcessorpipelines) across multipleLoggerchannels with distinctInstrumentationScopemetadata, and causes dropping one channel to shut down the shared provider while sibling channels are still active.This PR decouples provider ownership from
OpentelemetryLogwhile keepingOpentelemetryLogBuilderergonomic for single-pipeline setups:OpentelemetryLog::from_provider(provider: SdkLoggerProvider, scope: InstrumentationScope) -> SelfandOpentelemetryLog::with_make_bodyso multiple appenders can share a caller-configuredSdkLoggerProviderunder distinctInstrumentationScopedescriptors.Drop for OpentelemetryLogwithowned_provider: boolso builder-owned providers continue to shut down on drop while shared providers created viafrom_providerleave shutdown to the caller (oropentelemetry_sdk's automatic shutdown when the final provider reference drops).OpentelemetryLogBuilder::scope(self, scope: InstrumentationScope) -> Selfso single-provider builder callers can also configure fullInstrumentationScopemetadata (version,schema_url,attributes).Test Plan
InstrumentationScopeemission,with_make_body, andDroplifetime isolation intests-integration/tests/append_test/opentelemetry.rs(opentelemetry_appenders_preserve_scopes_and_share_provider_lifetime).logforth-append-opentelemetry.