// WithTracing returns a Send Handler that wraps another Send Handler in a trace
// span.
170681
func WithTracing(h Handler) Handler {
	return Handler{
		Name: "TracedSender",
		Fn: func(r *Request) {
			span, ctx := opentracing.StartSpanFromContext(r.HTTPRequest.Context(), "client.request")
			opentracing.GlobalTracer().Inject(
				span.Context(),
				opentracing.HTTPHeaders,
				opentracing.HTTPHeadersCarrier(r.HTTPRequest.Header),
			)
			defer span.Finish()
			r.HTTPRequest = r.HTTPRequest.WithContext(ctx)

			span.SetTag(ext.ResourceName, r.ClientInfo.ServiceName)
			span.SetTag("http.method", r.HTTPRequest.Method)
			span.SetTag("http.url", r.HTTPRequest.URL.Hostname()+r.HTTPRequest.URL.EscapedPath())
			span.SetTag("out.host", r.HTTPRequest.URL.Hostname())
			span.SetTag("out.port", r.HTTPRequest.URL.Port())

			h.Fn(r)

			if r.HTTPResponse != nil {
				span.SetTag("http.status_code", r.HTTPResponse.StatusCode)
			}

			if r.Error != nil {
				span.SetTag(ext.Error, r.Error)
			}
		},
	}
}
1075814
func (dl *ConsoleLogger) Trace(message interface{}, params ...interface{}) {
	dl.logger.Tracef(fmt.Sprintf("%s %s", caller(), fmt.Sprint(message)), params...)
}
1148723
func WithExtractFailurePolicy(p ExtractFailurePolicy) TracerOption {
	return func(o *Tracer) error {
		if p < 0 || p > ExtractFailurePolicyTagAndRestart {
			return ErrInvalidExtractFailurePolicy
		}
		o.extractFailurePolicy = p
		return nil
	}
}
1131805
func (g *Group) TRACE(path string, h HandlerFunc, m ...MiddlewareFunc) *Route {
	return g.Add(http.MethodTrace, path, h, m...)
}
955905
func Trace(w io.Writer, msgs func() []string) {
	if w == nil {
		return
	}
	c <- &event{w, time.Now(), msgs}
}
1261152
func (e *Entry) Trace(msg string) *Entry {
	e.Info(msg)
	v := e.WithFields(e.Fields)
	v.Message = msg
	v.start = time.Now()
	return v
}
1016301
func NewTransportWith(logger *events.Logger, roundTripper http.RoundTripper) http.RoundTripper {
	return &transport{roundTripper, logger}
}
1027309
func (r *Router) TraceFunc(pattern string, fn http.HandlerFunc) Route {
	return r.Trace(pattern, http.HandlerFunc(fn))
}
433371
func WithIDGenerator(generator idgenerator.IDGenerator) TracerOption {
	return func(o *Tracer) error {
		o.generate = generator
		return nil
	}
}
533214
func WithTracing(s *session.Session) {
	// After adding these handlers, the "Send" handler list will look
	// something like:
	//
	//	opentracing.Start -> opentracing.RequestInfo -> opentracing.DynamoDBInfo -> core.ValidateReqSigHandler -> core.SendHandler
	s.Handlers.Send.PushFrontNamed(DynamoDBInfoHandler)
	s.Handlers.Send.PushFrontNamed(RequestInfoHandler)
	s.Handlers.Send.PushFrontNamed(StartHandler)

	s.Handlers.Complete.PushBackNamed(FinishHandler)
}
1208676
func WithTraceID128Bit(val bool) TracerOption {
	return func(o *Tracer) error {
		if val {
			o.generate = idgenerator.NewRandom128()
		} else {
			o.generate = idgenerator.NewRandom64()
		}
		return nil
	}
}
594182
func trace(ctx context.Context, subsystem, name string) (opentracing.Span, context.Context) {
	span, ctx := opentracing.StartSpanFromContext(ctx, name)

	span.SetTag("subsystem", subsystem)

	// This is slightly confusing: when tracing is disabled, trace spans
	// are still created - but the tracer used is a NOP. Therefore, only
	// display the message when tracing is really enabled.
	if tracing {
		agentLog.Debugf("created span %v", span)
	}

	return span, ctx
}
729562
func WithSampler(sampler trace.Sampler) TracerOption {
	return func(o *TracerOptions) {
		o.Sampler = sampler
	}
}
388871
func (s *Sensor) TracingHttpRequest(name string, parent, req *http.Request, client http.Client) (res *http.Response, err error) {
	var span ot.Span
	if parentSpan, ok := parent.Context().Value("parentSpan").(ot.Span); ok {
		span = s.tracer.StartSpan("client", ot.ChildOf(parentSpan.Context()))
	} else {
		span = s.tracer.StartSpan("client")
	}
	defer span.Finish()

	headersCarrier := ot.HTTPHeadersCarrier(req.Header)
	if err := s.tracer.Inject(span.Context(), ot.HTTPHeaders, headersCarrier); err != nil {
		return nil, err
	}

	res, err = client.Do(req.WithContext(context.Background()))

	span.SetTag(string(ext.SpanKind), string(ext.SpanKindRPCClientEnum))
	span.SetTag(string(ext.PeerHostname), req.Host)
	span.SetTag(string(ext.HTTPUrl), req.URL.String())
	span.SetTag(string(ext.HTTPMethod), req.Method)
	span.SetTag(string(ext.HTTPStatusCode), res.StatusCode)

	if err != nil {
		if e, ok := err.(error); ok {
			span.LogFields(otlog.Error(e))
		} else {
			span.LogFields(otlog.Object("error", err))
		}
	}
	return
}
658385
func (s *FunctionConfiguration) SetTracingConfig(v *TracingConfigResponse) *FunctionConfiguration {
	s.TracingConfig = v
	return s
}
831169
func (s *CreateStageInput) SetTracingEnabled(v bool) *CreateStageInput {
	s.TracingEnabled = &v
	return s
}
549030
func (l *Logger) Trace(msg string) *Entry {
	return NewEntry(l).Trace(msg)
}