Skip to content
This repository has been archived by the owner on Nov 10, 2022. It is now read-only.

ContextManager.bind with a dynamic context #24

Closed
seemk opened this issue Mar 23, 2021 · 1 comment
Closed

ContextManager.bind with a dynamic context #24

seemk opened this issue Mar 23, 2021 · 1 comment

Comments

@seemk
Copy link

seemk commented Mar 23, 2021

I stumbled upon an issue where it would be useful to additionally have a bind method which does not take a context argument, but a function returning a context. It's useful when binding event emitters as some of the emitted events might have different context active based on event types.

What do you think, would there be room for such a method?

Rough sketch (naming, parameter types of the callback uncertain)

public bind<T>(target: T, getContext: () => Context): T

More context here: open-telemetry/opentelemetry-js#2037

@dyladan
Copy link
Member

dyladan commented Mar 23, 2021

Can you provide a motivating example of a usecase which requires such a feature? Not a theoretical explanation but an actual feature you would like to implement.

@seemk seemk closed this as completed Mar 24, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants