-
Notifications
You must be signed in to change notification settings - Fork 316
Expose TraceID and SpanID from SpanContext #188
Description
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:
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
.