Documentation ¶
Index ¶
- func ContextWithSkipSpanCreating(ctx context.Context) context.Context
- func OperationNameFromRequest(request *http.Request) string
- func SkipSpanCreatingFromContext(ctx context.Context) bool
- type CreatorSpanner
- type HTTPHeadersInjector
- type Injector
- type InjectorFn
- type Spanner
- type StandardSpanner
- type Transport
- func (o *Transport) RoundTripper(next http.RoundTripper) http.RoundTripper
- func (o *Transport) WithInjector(injector Injector) *Transport
- func (o *Transport) WithInterruptOnError(flag bool) *Transport
- func (o *Transport) WithSpanner(spanner Spanner) *Transport
- func (o *Transport) WithTracer(tracer opentracing.Tracer) *Transport
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ContextWithSkipSpanCreating ¶
ContextWithSkipSpanCreating does not create a new span upon request, does not close the span upon response
func OperationNameFromRequest ¶
OperationNameFromRequest creates an operation name from the request
E.g.:
- out: [POST] /v1/users
- out: [GET] /v1/users
For RESTful, you will need to use your own implementation
func SkipSpanCreatingFromContext ¶
SkipSpanCreatingFromContext gets the flag
Types ¶
type CreatorSpanner ¶
type CreatorSpanner struct { // CreateRootSpanOnMissingParent creates a "root" span if the parent span is missing CreateRootSpanOnMissingParent bool // OperationNameFn function creates an operation name for the new span OperationNameFn func(r *http.Request) string StandardSpanner }
CreatorSpanner - extended standard spanner with one difference - it creates a new span on each request
func (*CreatorSpanner) OnRequest ¶
func (p *CreatorSpanner) OnRequest(tracer opentracing.Tracer, request *http.Request) opentracing.Span
OnRequest creates a new span and passes it to StandardSpanner
func (*CreatorSpanner) OnResponse ¶
func (p *CreatorSpanner) OnResponse(span opentracing.Span, response *http.Response, clientError error)
OnResponse passes a span to StandardSpanner
func (*CreatorSpanner) WithCreateRootSpanOnMissingParent ¶
func (p *CreatorSpanner) WithCreateRootSpanOnMissingParent(flag bool) *CreatorSpanner
WithCreateRootSpanOnMissingParent creates a "root" span if the parent span is missing
type HTTPHeadersInjector ¶
type HTTPHeadersInjector struct{}
HTTPHeadersInjector used by default, it injects a trace into the HTTP headers
type Injector ¶
type Injector interface {
Inject(tracer opentracing.Tracer, ctx opentracing.SpanContext, r **http.Request) error
}
Injector knows how to propagate a trace http.Request agrument should be immutable For any modifications, use a copy of the http.Request and replace the pointer
type InjectorFn ¶
type InjectorFn func(tracer opentracing.Tracer, ctx opentracing.SpanContext, r **http.Request) error
InjectorFn a wrapper for the Injector interface
type Spanner ¶
type Spanner interface { // OnRequest called on an HTTP request OnRequest(tracer opentracing.Tracer, request *http.Request) opentracing.Span // OnResponse called on an HTTP response OnResponse(span opentracing.Span, response *http.Response, clientError error) }
Spanner injects tags, logs and manages the lifecycle of a span
Tagging and logging specification: https://github.com/opentracing/specification/blob/master/semantic_conventions.md
type StandardSpanner ¶
type StandardSpanner struct{}
StandardSpanner is used by default It only works with the existing span and does not create a new one
func (StandardSpanner) OnRequest ¶
func (StandardSpanner) OnRequest(tracer opentracing.Tracer, request *http.Request) opentracing.Span
OnRequest adds tags to an existing span: span.kind, http.url, http.method
func (StandardSpanner) OnResponse ¶
func (StandardSpanner) OnResponse(span opentracing.Span, response *http.Response, clientError error)
OnResponse adds a "HTTPStatusCode" or "Error" tag to the existing span
type Transport ¶
type Transport struct { // InterruptOnError // E.g. HTTP request will be interrupted upon a tracer.Inject error InterruptOnError bool // contains filtered or unexported fields }
Transport is used for the HTTP Client transport, it implements the RoundTripper interface
func (*Transport) RoundTripper ¶
func (o *Transport) RoundTripper(next http.RoundTripper) http.RoundTripper
Transport middleware function
func (*Transport) WithInjector ¶
WithInjector sets an injector
func (*Transport) WithInterruptOnError ¶
WithInterruptOnError sets a flag
func (*Transport) WithSpanner ¶
WithSpanner sets a spanner
func (*Transport) WithTracer ¶
WithTracer sets a tracer