Skip to content

Helper methods for accessing Span directly from Context in Span API #950

@jsuereth

Description

@jsuereth

The 1.0.0 specification states:

This section defines all operations within the Tracing API that interact with the Context.

The API MUST provide the following functionality to interact with a Context instance:

- Extract the Span from a Context instance
- Insert the Span to a Context instance
The functionality listed above is necessary because API users SHOULD NOT have access to the Context Key used by the Tracing API implementation.

If the language has support for implicitly propagated Context (see here), the API SHOULD also provide the following functionality:

- Get the currently active span from the implicit context. This is equivalent to getting the implicit context, then extracting the Span from the context.
- Set the currently active span to the implicit context. This is equivalent to getting the implicit context, then inserting the Span to the context.

I was looking for documentation or example (e.g. context propagation) where this is done. In some languages, they provide helper methods directly on Span which will extract/insert into context (both explicitly or implicitly).

Specifically, I think this may need to be public: https://github.com/open-telemetry/opentelemetry-cpp/blob/main/api/include/opentelemetry/trace/propagation/detail/context.h#L14

It looks like these methods may be on Tracer: https://github.com/open-telemetry/opentelemetry-cpp/blob/main/api/include/opentelemetry/trace/tracer.h#L146. This is inconsistent with other APIs.

Ideally the propogation:detail + tracer methods would get reconciled into a standard header with Span <-> Context interaction.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions