Skip to content

Allow HttpTraceContext to accept a SpanContext #3289

@diehard2

Description

@diehard2

I'm not using global contexts in my application. Instead I'm passing SpanContexts and creating children manually. My code has a lot of threads, and its easier to keep track of how everything is hooking up this way. This is all working extremely well until I need to propagate my latest span context. The Inject method in HttpTraceContext only takes a Context, which it immediately makes into a SpanContext.

  void Inject(context::propagation::TextMapCarrier &carrier,
              const context::Context &context) noexcept override
  {
    SpanContext span_context = trace::GetSpan(context)->GetContext();
    if (!span_context.IsValid())
    {
      return;
    }
    InjectImpl(carrier, span_context);
  }
  1. Would it be possible to supply a constructor that takes a SpanContext for those of us who are doing this more manually?
  2. Alternatively, is there a way to make a Context from a SpanContext. I couldn't find an easy way to do this

I know I can copy that file and change it to suit my needs, but ideally there would be a way around that. Thanks for any help.

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions