Skip to content

Callback on context change #3915

Description

@xrmx

Why you need this feature?

Elastic is proposing a donation of our continuous profiler (open-telemetry/community#1918). In order to do correlation of profiling data with traces collected by language sdks we need to provide to the profiler current thread trace id, span id and root span id.

Describe the solution you'd like

Following java implementation I thought an hook on the context api may work, I've done a quick POC here:

https://gist.github.com/xrmx/fc81e710e7a860ca229839b10e780dfd

On the technical side I'm unsure if the optional hook callback should be configured via an environment variable or via an entrypoint.

Describe alternatives you've considered

An alternative if the context is the right place to hook would be to provide a custom context storage implementation but that would not be generic or upstreamable.

Additional context

In the java sdk they have https://javadoc.io/doc/io.opentelemetry/opentelemetry-context/latest/io/opentelemetry/context/ContextStorage.html#addWrapper(java.util.function.Function)

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions