Documentation ¶
Index ¶
Constants ¶
const TraceContextHeaderName = "x-cloud-trace-context"
TraceContextHeaderName is the HTTP header field for Google Cloud Trace https://cloud.google.com/trace/docs/setup#force-trace
Variables ¶
This section is empty.
Functions ¶
func SpanContextFromRequest ¶
func SpanContextFromRequest(req *http.Request) (trace.SpanContext, error)
SpanContextFromRequest extracts a trace.SpanContext from the HTTP request req. In this method, SpanID is expected to be stored in big endian.
Types ¶
type CloudTraceFormatPropagator ¶
type CloudTraceFormatPropagator struct{}
CloudTraceFormatPropagator is a TextMapPropagator that injects/extracts a context to/from the carrier following Google Cloud Trace format.
func (CloudTraceFormatPropagator) Extract ¶
func (p CloudTraceFormatPropagator) Extract(ctx context.Context, carrier propagation.TextMapCarrier) context.Context
Extract extacts a context from the carrier if the header contains Google Cloud Trace header format. In this method, SpanID is expected to be stored in big endian.
func (CloudTraceFormatPropagator) Fields ¶
func (p CloudTraceFormatPropagator) Fields() []string
Fields just returns the header name.
func (CloudTraceFormatPropagator) Inject ¶
func (p CloudTraceFormatPropagator) Inject(ctx context.Context, carrier propagation.TextMapCarrier)
Inject injects a context to the carrier following Google Cloud Trace format. In this method, SpanID is expected to be stored in big endian.
type CloudTraceOneWayPropagator ¶
type CloudTraceOneWayPropagator struct {
CloudTraceFormatPropagator
}
CloudTraceOneWayPropagator will propagate trace context from the w3c standard headers (traceparent and tracestate). If traceparent is not present, it will extract trace context from x-cloud-trace-context, and propagate that trace context forward using the w3c standard headers.
This is the preferred mechanism of propagation as X-Cloud-Trace-Context sampling flag behaves subtly different from expectations in both w3c traceparent *and* opentelemetry propagation.
func (CloudTraceOneWayPropagator) Fields ¶
func (p CloudTraceOneWayPropagator) Fields() []string
Fields returns an empty list of fields, since the one way propagator does not inject any fields.
func (CloudTraceOneWayPropagator) Inject ¶
func (p CloudTraceOneWayPropagator) Inject(ctx context.Context, carrier propagation.TextMapCarrier)
Inject does not inject anything for the oneway propagator.