Documentation ¶
Overview ¶
Package ochttp contains:
- a propagation.HTTPFormat implementation for B3 and Datadog propagation
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type HTTPFormat ¶
type HTTPFormat struct{}
HTTPFormat implements propagation.HTTPFormat to propagate traces in HTTP headers in B3 and Datadog propagation format. HTTPFormat skips the X-B3-ParentId and X-B3-Flags headers because there are additional fields not represented in the OpenCensus span context. Spans created from the incoming header will be the direct children of the client-side span. Similarly, receiver of the outgoing spans should use client-side span created by OpenCensus as the parent.
The HTTPFormat is based on ochttp and ddtrace. - ochttp: https://github.com/census-instrumentation/opencensus-go/tree/master/plugin/ochttp/propagation/b3 - ddtrace: https://github.com/DataDog/dd-trace-go/blob/v1/ddtrace/tracer/textmap.go See https://github.com/openzipkin/b3-propagation for more details on B3 propagation.
Examples ¶
An example of using the propagator
func ListenAndServe(port string, handler http.Handler) error { ocHandler := new(oc_http.Handler) ocHandler.Handler = handler ocHandler.Propagation = new(HTTPFormat) server = http.Server{ Addr: ":" + port, Handler: ocHandler, } return server.ListenAndServe() }
func (*HTTPFormat) SpanContextFromRequest ¶
func (f *HTTPFormat) SpanContextFromRequest(req *http.Request) (sc oc_trace.SpanContext, ok bool)
SpanContextFromRequest extracts an OC span context from incoming requests. Will first try to extract from Datadog headers and then from B3 headers.
func (*HTTPFormat) SpanContextToRequest ¶
func (f *HTTPFormat) SpanContextToRequest(sc oc_trace.SpanContext, req *http.Request)
SpanContextToRequest modifies the given request to include B3 and Datadog headers.