Skip to content
This repository was archived by the owner on May 23, 2023. It is now read-only.
This repository was archived by the owner on May 23, 2023. It is now read-only.

Expose TraceID and SpanID from SpanContext #188

@gianarb

Description

@gianarb

Hello folks! Thanks for all the work you did.

Use Case

I would like to expose the trace_id out from a Span mainly over HTTP header, and I would also like to attach it to the logs that my application generates.

Mainly for support purpose. A developer or a system integrator will be able to communicate the trace_id back to the support team, and it will easy for them to understand what is going on.

Problem

I looked around, and it seems like this information is not accessible from the SpanContext but I had a quick chat with @yurishkuro in the mailing list, and it looks like the specification now covers this use case:

https://github.com/opentracing/specification/blob/master/rfc/trace_identifiers.md#specification-changes

Proposal

I opened this issue to figure out together how we should update the SpanContext interface to cover this use case.

// SpanContext represents Span state that must propagate to descendant Spans and across process
// boundaries (e.g., a <trace_id, span_id, sampled> tuple).
type SpanContext interface {
	// ForeachBaggageItem grants access to all baggage items stored in the
	// SpanContext.
	// The handler function will be called for each baggage key/value pair.
	// The ordering of items is not guaranteed.
	//
	// The bool return value indicates if the handler wants to continue iterating
	// through the rest of the baggage items; for example if the handler is trying to
	// find some baggage item by pattern matching the name, it can return false
	// as soon as the item is found to stop further iterations.
	ForeachBaggageItem(handler func(k, v string) bool)

        SpanID() string
        TraceID() string
}

We can probably add two simple method SpanID() and TraceID() to the SpanContext.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions