Documentation ¶
Overview ¶
Package http contains several http middlewares which can be used for instrumenting calls with Zipkin.
Index ¶
- Variables
- func Discard() *bool
- func NewServerMiddleware(t *zipkin.Tracer, options ...ServerOption) func(http.Handler) http.Handler
- func NewTransport(tracer *zipkin.Tracer, options ...TransportOption) (http.RoundTripper, error)
- func Sample() *bool
- type Client
- type ClientOption
- type ErrHandler
- type ErrResponseReader
- type RequestSamplerFunc
- type ServerOption
- func EnableBaggage(b middleware.BaggageHandler) ServerOption
- func RequestSampler(sampleFunc RequestSamplerFunc) ServerOption
- func ServerErrHandler(eh ErrHandler) ServerOption
- func ServerTags(tags map[string]string) ServerOption
- func SpanName(name string) ServerOption
- func TagResponseSize(enabled bool) ServerOption
- type TransportOption
- func RoundTripper(rt http.RoundTripper) TransportOption
- func TransportErrHandler(h ErrHandler) TransportOption
- func TransportErrResponseReader(r ErrResponseReader) TransportOption
- func TransportLogger(l *log.Logger) TransportOption
- func TransportRemoteEndpoint(remoteEndpoint *model.Endpoint) TransportOption
- func TransportRequestSampler(sampleFunc RequestSamplerFunc) TransportOption
- func TransportTags(tags map[string]string) TransportOption
- func TransportTrace(enable bool) TransportOption
Constants ¶
This section is empty.
Variables ¶
var ErrValidTracerRequired = errors.New("valid tracer required")
ErrValidTracerRequired error
Functions ¶
func Discard ¶ added in v0.2.1
func Discard() *bool
Discard is a convenience function that returns a pointer to a boolean false. Use this for RequestSamplerFuncs when wanting the RequestSampler to override the sampling decision to no.
func NewServerMiddleware ¶
func NewServerMiddleware(t *zipkin.Tracer, options ...ServerOption) func(http.Handler) http.Handler
NewServerMiddleware returns a http.Handler middleware with Zipkin tracing.
func NewTransport ¶
func NewTransport(tracer *zipkin.Tracer, options ...TransportOption) (http.RoundTripper, error)
NewTransport returns a new Zipkin instrumented http RoundTripper which can be used with a standard library http Client.
Types ¶
type Client ¶
Client holds a Zipkin instrumented HTTP Client.
func NewClient ¶
func NewClient(tracer *zipkin.Tracer, options ...ClientOption) (*Client, error)
NewClient returns an HTTP Client adding Zipkin instrumentation around an embedded standard Go http.Client.
type ClientOption ¶
type ClientOption func(*Client)
ClientOption allows optional configuration of Client.
func ClientTags ¶
func ClientTags(tags map[string]string) ClientOption
ClientTags adds default Tags to inject into client application spans.
func ClientTrace ¶
func ClientTrace(enabled bool) ClientOption
ClientTrace allows one to enable Go's net/http/httptrace.
func TransportOptions ¶
func TransportOptions(options ...TransportOption) ClientOption
TransportOptions passes optional Transport configuration to the internal transport used by Client.
func WithClient ¶
func WithClient(client *http.Client) ClientOption
WithClient allows one to add a custom configured http.Client to use.
func WithRemoteEndpoint ¶ added in v0.2.3
func WithRemoteEndpoint(remoteEndpoint *model.Endpoint) ClientOption
WithRemoteEndpoint will set the remote endpoint for all spans.
type ErrHandler ¶ added in v0.1.7
ErrHandler allows instrumentations to decide how to tag errors based on the response status code >399 and the error from the Transport.RoundTrip
type ErrResponseReader ¶ added in v0.1.7
ErrResponseReader allows instrumentations to read the error body and decide to obtain information to it and add it to the span i.e. tag the span with a more meaningful error code or with error details.
type RequestSamplerFunc ¶ added in v0.2.1
RequestSamplerFunc can be implemented for client and/or server side sampling decisions that can override the existing upstream sampling decision. If the implementation returns nil, the existing sampling decision stays as is.
type ServerOption ¶
type ServerOption func(*handler)
ServerOption allows Middleware to be optionally configured.
func EnableBaggage ¶ added in v0.4.0
func EnableBaggage(b middleware.BaggageHandler) ServerOption
EnableBaggage can be passed to NewServerHandler to enable propagation of registered fields through the SpanContext object.
func RequestSampler ¶ added in v0.1.1
func RequestSampler(sampleFunc RequestSamplerFunc) ServerOption
RequestSampler allows one to set the sampling decision based on the details found in the http.Request. If wanting to keep the existing sampling decision from upstream as is, this function should return nil.
func ServerErrHandler ¶ added in v0.1.7
func ServerErrHandler(eh ErrHandler) ServerOption
ServerErrHandler allows to pass a custom error handler for the server response
func ServerTags ¶
func ServerTags(tags map[string]string) ServerOption
ServerTags adds default Tags to inject into server spans.
func SpanName ¶
func SpanName(name string) ServerOption
SpanName sets the name of the spans the middleware creates. Use this if wrapping each endpoint with its own Middleware. If omitting the SpanName option, the middleware will use the http request method as span name.
func TagResponseSize ¶
func TagResponseSize(enabled bool) ServerOption
TagResponseSize will instruct the middleware to Tag the http response size in the server side span.
type TransportOption ¶
type TransportOption func(*transport)
TransportOption allows one to configure optional transport configuration.
func RoundTripper ¶
func RoundTripper(rt http.RoundTripper) TransportOption
RoundTripper adds the Transport RoundTripper to wrap.
func TransportErrHandler ¶ added in v0.1.7
func TransportErrHandler(h ErrHandler) TransportOption
TransportErrHandler allows to pass a custom error handler for the round trip
func TransportErrResponseReader ¶ added in v0.1.7
func TransportErrResponseReader(r ErrResponseReader) TransportOption
TransportErrResponseReader allows to pass a custom ErrResponseReader
func TransportLogger ¶ added in v0.1.7
func TransportLogger(l *log.Logger) TransportOption
TransportLogger allows to plug a logger into the transport
func TransportRemoteEndpoint ¶ added in v0.2.3
func TransportRemoteEndpoint(remoteEndpoint *model.Endpoint) TransportOption
TransportRemoteEndpoint will set the remote endpoint for all spans.
func TransportRequestSampler ¶ added in v0.1.7
func TransportRequestSampler(sampleFunc RequestSamplerFunc) TransportOption
TransportRequestSampler allows one to set the sampling decision based on the details found in the http.Request. It has preference over the existing sampling decision contained in the context. The function returns a *bool, if returning nil, sampling decision is not being changed whereas returning something else than nil is being used as sampling decision.
func TransportTags ¶
func TransportTags(tags map[string]string) TransportOption
TransportTags adds default Tags to inject into transport spans.
func TransportTrace ¶
func TransportTrace(enable bool) TransportOption
TransportTrace allows one to enable Go's net/http/httptrace.