Documentation ¶
Overview ¶
Package zipkin provides Go kit integration to the OpenZipkin project through the use of zipkin-go, the official OpenZipkin tracer implementation for Go. OpenZipkin is the most used open source distributed tracing ecosystem with many different libraries and interoperability options.
Index ¶
- func GRPCClientTrace[Request, Response any](tracer *zipkin.Tracer, options ...TracerOption) kitgrpc.ClientOption[Request, Response]
- func GRPCServerTrace[Request, Response any](tracer *zipkin.Tracer, options ...TracerOption) kitgrpc.ServerOption[Request, Response]
- func HTTPClientTrace[Request, Response any](tracer *zipkin.Tracer, options ...TracerOption) kithttp.ClientOption[Request, Response]
- func HTTPServerTrace[Request, Response any](tracer *zipkin.Tracer, options ...TracerOption) kithttp.ServerOption[Request, Response]
- func TraceEndpoint[Request, Response any](tracer *zipkin.Tracer, name string) endpoint.Middleware[Request, Response]
- type TracerOption
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func GRPCClientTrace ¶
func GRPCClientTrace[Request, Response any](tracer *zipkin.Tracer, options ...TracerOption) kitgrpc.ClientOption[Request, Response]
GRPCClientTrace enables native Zipkin tracing of a Go kit gRPC transport Client.
Go kit creates gRPC transport clients per remote endpoint. This middleware can be set-up individually by adding the endpoint name for each of the Go kit transport clients using the Name() TracerOption. If wanting to use the gRPC FullMethod (/service/method) as Span name you can create a global client tracer omitting the Name() TracerOption, which you can then feed to each Go kit gRPC transport client. If instrumenting a client to an external (not on your platform) service, you will probably want to disallow propagation of SpanContext using the AllowPropagation TracerOption and setting it to false.
func GRPCServerTrace ¶
func GRPCServerTrace[Request, Response any](tracer *zipkin.Tracer, options ...TracerOption) kitgrpc.ServerOption[Request, Response]
GRPCServerTrace enables native Zipkin tracing of a Go kit gRPC transport Server.
Go kit creates gRPC transport servers per gRPC method. This middleware can be set-up individually by adding the method name for each of the Go kit method servers using the Name() TracerOption. If wanting to use the gRPC FullMethod (/service/method) as Span name you can create a global server tracer omitting the Name() TracerOption, which you can then feed to each Go kit method server. For this to work you will need to wire the Go kit gRPC Interceptor too. If instrumenting a service to external (not on your platform) clients, you will probably want to disallow propagation of a client SpanContext using the AllowPropagation TracerOption and setting it to false.
func HTTPClientTrace ¶
func HTTPClientTrace[Request, Response any](tracer *zipkin.Tracer, options ...TracerOption) kithttp.ClientOption[Request, Response]
HTTPClientTrace enables native Zipkin tracing of a Go kit HTTP transport Client.
Go kit creates HTTP transport clients per remote endpoint. This middleware can be set-up individually by adding the endpoint name for each of the Go kit transport clients using the Name() TracerOption. If wanting to use the HTTP Method (Get, Post, Put, etc.) as Span name you can create a global client tracer omitting the Name() TracerOption, which you can then feed to each Go kit transport client. If instrumenting a client to an external (not on your platform) service, you will probably want to disallow propagation of SpanContext using the AllowPropagation TracerOption and setting it to false.
func HTTPServerTrace ¶
func HTTPServerTrace[Request, Response any](tracer *zipkin.Tracer, options ...TracerOption) kithttp.ServerOption[Request, Response]
HTTPServerTrace enables native Zipkin tracing of a Go kit HTTP transport Server.
Go kit creates HTTP transport servers per HTTP endpoint. This middleware can be set-up individually by adding the method name for each of the Go kit method servers using the Name() TracerOption. If wanting to use the HTTP method (Get, Post, Put, etc.) as Span name you can create a global server tracer omitting the Name() TracerOption, which you can then feed to each Go kit method server.
If instrumenting a service to external (not on your platform) clients, you will probably want to disallow propagation of a client SpanContext using the AllowPropagation TracerOption and setting it to false.
func TraceEndpoint ¶
func TraceEndpoint[Request, Response any](tracer *zipkin.Tracer, name string) endpoint.Middleware[Request, Response]
TraceEndpoint returns an Endpoint middleware, tracing a Go kit endpoint. This endpoint tracer should be used in combination with a Go kit Transport tracing middleware or custom before and after transport functions as propagation of SpanContext is not provided in this middleware.
Types ¶
type TracerOption ¶
type TracerOption func(o *tracerOptions)
TracerOption allows for functional options to our Zipkin tracing middleware.
func AllowPropagation ¶
func AllowPropagation(propagate bool) TracerOption
AllowPropagation instructs the tracer to allow or deny propagation of the span context between this instrumented client or service and its peers. If the instrumented client connects to services outside its own platform or if the instrumented service receives requests from untrusted clients it is strongly advised to disallow propagation. Propagation between services inside your own platform benefit from propagation. Default for both TraceClient and TraceServer is to allow propagation.
func Logger ¶
func Logger(logger log.Logger) TracerOption
Logger adds a Go kit logger to our Zipkin Middleware to log SpanContext extract / inject errors if they occur. Default is Noop.
func Name ¶
func Name(name string) TracerOption
Name sets the name for an instrumented transport endpoint. If name is omitted at tracing middleware creation, the method of the transport or transport rpc name is used.
func RequestSampler ¶
func RequestSampler(sampleFunc func(r *http.Request) bool) TracerOption
RequestSampler allows one to set the sampling decision based on the details found in the http.Request.
func Tags ¶
func Tags(tags map[string]string) TracerOption
Tags adds default tags to our Zipkin transport spans.