Prototype for sessions as entities#1
Draft
martinkuba wants to merge 3 commits intopackages-prototypefrom
Draft
Conversation
martinkuba
commented
Mar 1, 2026
| // Rebind on session rotation | ||
| sessionManager.addObserver({ | ||
| onSessionStarted(session) { | ||
| loggerProvider.setEntity(createSessionEntity(session.id)); |
Owner
Author
There was a problem hiding this comment.
This shows user code updating the global logger provider with a new session entity.
david-luna
reviewed
Mar 5, 2026
| * route telemetry through the new entity-bound provider. | ||
| */ | ||
| setEntity(entity: Entity): void { | ||
| this._currentProvider = this.forEntity(entity); |
There was a problem hiding this comment.
If we are replacing the current provider I wonder if its necessary to shut it down 1st 🤔
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.
This is intended as a prototype of modeling browser sessions using entities based on this proposal:
OTEP: Allow multiple Resources in an SDK by jsuereth · Pull Request #4665 · open-telemetry/opentelemetry-specification.
The proposal introduces a
forEntity()method on providers. I think this works when a single module (e.g. single instrumentation) is in control of the entity-bound provider.However, the session entity should be applied to all telemetry. When any instrumentation (and user code) emits a signal, it should include the session attributes. And when a session rotates, this needs to propagate to all.
This prototype includes an
EntityAwareLoggerProviderthat delegates to an internal LoggerProvider and allows updating the entity via thesetEntity()method. Internally, the delegate LoggerProvider is constructed by using theforEntity()method as described in the proposal.