Documentation ¶
Overview ¶
Package opencensus provides Go kit integration to the OpenCensus project. OpenCensus is a single distribution of libraries for metrics and distributed tracing with minimal overhead that allows you to export data to multiple backends. The Go kit OpenCencus package as provided here contains middlewares for tracing.
Index ¶
- Constants
- func GRPCClientTrace[REQ any, RES any](options ...TracerOption) kitgrpc.ClientOption[REQ, RES]
- func GRPCServerTrace[REQ any, RES any](options ...TracerOption) kitgrpc.ServerOption[REQ, RES]
- func HTTPClientTrace[REQ any, RES any](options ...TracerOption) kithttp.ClientOption[REQ, RES]
- func HTTPServerTrace[REQ any, RES any](options ...TracerOption) kithttp.ServerOption[REQ, RES]
- func JSONRPCClientTrace[REQ any, RES any](options ...TracerOption) jsonrpc.ClientOption[REQ, RES]
- func JSONRPCServerTrace(options ...TracerOption) jsonrpc.ServerOption
- func TraceEndpoint[REQ any, RES any](name string, options ...EndpointOption) endpoint.Middleware[REQ, RES]
- type EndpointOption
- func WithEndpointAttributes(attrs ...trace.Attribute) EndpointOption
- func WithEndpointConfig(options EndpointOptions) EndpointOption
- func WithIgnoreBusinessError(val bool) EndpointOption
- func WithSpanAttributes(fn func(ctx context.Context) []trace.Attribute) EndpointOption
- func WithSpanName(fn func(ctx context.Context, name string) string) EndpointOption
- type EndpointOptions
- type TracerOption
- type TracerOptions
Constants ¶
const TraceEndpointDefaultName = "gokit/endpoint"
TraceEndpointDefaultName is the default endpoint span name to use.
Variables ¶
This section is empty.
Functions ¶
func GRPCClientTrace ¶
func GRPCClientTrace[REQ any, RES any](options ...TracerOption) kitgrpc.ClientOption[REQ, RES]
GRPCClientTrace enables OpenCensus tracing of a Go kit gRPC transport client.
func GRPCServerTrace ¶
func GRPCServerTrace[REQ any, RES any](options ...TracerOption) kitgrpc.ServerOption[REQ, RES]
GRPCServerTrace enables OpenCensus tracing of a Go kit gRPC transport server.
func HTTPClientTrace ¶
func HTTPClientTrace[REQ any, RES any](options ...TracerOption) kithttp.ClientOption[REQ, RES]
HTTPClientTrace enables OpenCensus tracing of a Go kit HTTP transport client.
func HTTPServerTrace ¶
func HTTPServerTrace[REQ any, RES any](options ...TracerOption) kithttp.ServerOption[REQ, RES]
HTTPServerTrace enables OpenCensus tracing of a Go kit HTTP transport server.
func JSONRPCClientTrace ¶ added in v0.18.0
func JSONRPCClientTrace[REQ any, RES any](options ...TracerOption) jsonrpc.ClientOption[REQ, RES]
JSONRPCClientTrace enables OpenCensus tracing of a Go kit JSONRPC transport client.
func JSONRPCServerTrace ¶ added in v0.18.0
func JSONRPCServerTrace(options ...TracerOption) jsonrpc.ServerOption
JSONRPCServerTrace enables OpenCensus tracing of a Go kit JSONRPC transport server.
func TraceEndpoint ¶
func TraceEndpoint[REQ any, RES any](name string, options ...EndpointOption) endpoint.Middleware[REQ, RES]
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, generic OpenCensus transport middleware or custom before and after transport functions as service propagation of SpanContext is not provided in this middleware.
Types ¶
type EndpointOption ¶
type EndpointOption func(*EndpointOptions)
EndpointOption allows for functional options to our OpenCensus endpoint tracing middleware.
func WithEndpointAttributes ¶
func WithEndpointAttributes(attrs ...trace.Attribute) EndpointOption
WithEndpointAttributes sets the default attributes for the spans created by the Endpoint tracer.
func WithEndpointConfig ¶
func WithEndpointConfig(options EndpointOptions) EndpointOption
WithEndpointConfig sets all configuration options at once by use of the EndpointOptions struct.
func WithIgnoreBusinessError ¶
func WithIgnoreBusinessError(val bool) EndpointOption
WithIgnoreBusinessError if set to true will not treat a business error identified through the endpoint.Failer interface as a span error.
func WithSpanAttributes ¶ added in v0.18.0
func WithSpanAttributes(fn func(ctx context.Context) []trace.Attribute) EndpointOption
WithSpanAttributes extracts additional attributes from the request context.
func WithSpanName ¶ added in v0.18.0
func WithSpanName(fn func(ctx context.Context, name string) string) EndpointOption
WithSpanName extracts additional attributes from the request context.
type EndpointOptions ¶
type EndpointOptions struct { // IgnoreBusinessError if set to true will not treat a business error // identified through the endpoint.Failer interface as a span error. IgnoreBusinessError bool // Attributes holds the default attributes which will be set on span // creation by our Endpoint middleware. Attributes []trace.Attribute // GetName is an optional function that can set the span name based on the existing name // for the endpoint and information in the context. // // If the function is nil, or the returned name is empty, the existing name for the endpoint is used. GetName func(ctx context.Context, name string) string // GetAttributes is an optional function that can extract trace attributes // from the context and add them to the span. GetAttributes func(ctx context.Context) []trace.Attribute }
EndpointOptions holds the options for tracing an endpoint
type TracerOption ¶
type TracerOption func(o *TracerOptions)
TracerOption allows for functional options to our OpenCensus tracing middleware.
func IsPublic ¶
func IsPublic(isPublic bool) TracerOption
IsPublic should be set to true for publicly accessible servers and for clients that should not propagate their current trace metadata. On the server side a new trace will always be started regardless of any trace metadata being found in the incoming request. If any trace metadata is found, it will be added as a linked trace instead.
func WithHTTPPropagation ¶
func WithHTTPPropagation(p propagation.HTTPFormat) TracerOption
WithHTTPPropagation sets the propagation handlers for the HTTP transport middlewares. If used on a non HTTP transport this is a noop.
func WithName ¶
func WithName(name string) TracerOption
WithName 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 WithSampler ¶
func WithSampler(sampler trace.Sampler) TracerOption
WithSampler sets the sampler to use by our OpenCensus Tracer.
func WithTracerConfig ¶
func WithTracerConfig(options TracerOptions) TracerOption
WithTracerConfig sets all configuration options at once.
type TracerOptions ¶
type TracerOptions struct { Sampler trace.Sampler Name string Public bool HTTPPropagate propagation.HTTPFormat }
TracerOptions holds configuration for our tracing middlewares