// SpanFromRequest returns a new trace span for an HTTP request.
//
// It returns nil iff the client is nil.
//
// If the incoming HTTP request contains a trace context header, the trace ID,
// parent span ID, and tracing options will be read from that header.
// Otherwise, a new trace ID is made and the parent span ID is zero.
//
// If a non-nil sampling policy has been set in the client, it can override the
// options set in the header and choose whether to trace the request.
//
// If the request is not being traced, then a *Span is returned anyway, but it
// will not be uploaded to the server -- it is only useful for propagating
// trace context to child requests and for getting the TraceID.  All its
// methods can still be called -- the Finish, FinishWait, and SetLabel methods
// do nothing.  NewChild does nothing, and returns the same *Span.  TraceID
// works as usual.
SpanFromRequest returns a new trace span for an HTTP request.

It returns nil iff the client is nil.

If the incoming HTTP request contains a trace context header, the trace ID,
parent span ID, and tracing options will be read from that header.
Otherwise, a new trace ID is made and the parent span ID is zero.

If a non-nil sampling policy has been set in the client, it can override the
options set in the header and choose whether to trace the request.

If the request is not being traced, then a *Span is returned anyway, but it
will not be uploaded to the server -- it is only useful for propagating
trace context to child requests and for getting the TraceID.  All its
methods can still be called -- the Finish, FinishWait, and SetLabel methods
do nothing.  NewChild does nothing, and returns the same *Span.  TraceID
works as usual.
// SpanFromRequest returns a new trace span for an HTTP request . // // It returns nil iff the client is nil . // // If the incoming HTTP request contains a trace context header the trace ID // parent span ID and tracing options will be read from that header . // Otherwise a new trace ID is made and the parent span ID is zero . // // If a non - nil sampling policy has been set in the client it can override the // options set in the header and choose whether to trace the request . // // If the request is not being traced then a * Span is returned anyway but it // will not be uploaded to the server -- it is only useful for propagating // trace context to child requests and for getting the TraceID . All its // methods can still be called -- the Finish FinishWait and SetLabel methods // do nothing . NewChild does nothing and returns the same * Span . TraceID // works as usual .
func (c *Client) SpanFromRequest(r *http.Request) *Span {
	if c == nil {
		return nil
	}
	traceID, parentSpanID, options, ok := traceInfoFromHeader(r.Header.Get(httpHeader))
	if !ok {
		traceID = nextTraceID()
	}
	t := &trace{
		traceID:       traceID,
		client:        c,
		globalOptions: options,
		localOptions:  options,
	}
	span := startNewChildWithRequest(r, t, parentSpanID)
	span.span.Kind = spanKindServer
	span.rootSpan = true
	configureSpanFromPolicy(span, c.policy, ok)
	return span
}
func ( c * Client ) SpanFromRequest ( r * http . Request ) * Span { if c == nil { return nil } traceID , parentSpanID , options , ok := traceInfoFromHeader ( r . Header . Get ( httpHeader ) ) if ! ok { traceID = nextTraceID ( ) } t := & trace { traceID : traceID , client : c , globalOptions : options , localOptions : options , } span := startNewChildWithRequest ( r , t , parentSpanID ) span . span . Kind = spanKindServer span . rootSpan = true configureSpanFromPolicy ( span , c . policy , ok ) return span }
SpanFromRequest returns a new trace span for an HTTP request.
SpanFromRequest returns a new trace span for an HTTP request .