opentracing

package
v0.13.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 29, 2023 License: MIT Imports: 14 Imported by: 705

Documentation

Overview

Package opentracing provides Go kit integration to the OpenTracing project. OpenTracing implements a general purpose interface that microservices can program against, and which adapts to all major distributed tracing systems.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ContextToGRPC added in v0.6.0

func ContextToGRPC(tracer opentracing.Tracer, logger log.Logger) func(ctx context.Context, md *metadata.MD) context.Context

ContextToGRPC returns a grpc RequestFunc that injects an OpenTracing Span found in `ctx` into the grpc Metadata. If no such Span can be found, the RequestFunc is a noop.

func ContextToHTTP added in v0.6.0

func ContextToHTTP(tracer opentracing.Tracer, logger log.Logger) kithttp.RequestFunc

ContextToHTTP returns an http RequestFunc that injects an OpenTracing Span found in `ctx` into the http headers. If no such Span can be found, the RequestFunc is a noop.

func GRPCToContext added in v0.6.0

func GRPCToContext(tracer opentracing.Tracer, operationName string, logger log.Logger) func(ctx context.Context, md metadata.MD) context.Context

GRPCToContext returns a grpc RequestFunc that tries to join with an OpenTracing trace found in `req` and starts a new Span called `operationName` accordingly. If no trace could be found in `req`, the Span will be a trace root. The Span is incorporated in the returned Context and can be retrieved with opentracing.SpanFromContext(ctx).

func HTTPToContext added in v0.6.0

func HTTPToContext(tracer opentracing.Tracer, operationName string, logger log.Logger) kithttp.RequestFunc

HTTPToContext returns an http RequestFunc that tries to join with an OpenTracing trace found in `req` and starts a new Span called `operationName` accordingly. If no trace could be found in `req`, the Span will be a trace root. The Span is incorporated in the returned Context and can be retrieved with opentracing.SpanFromContext(ctx).

func TraceClient

func TraceClient(tracer opentracing.Tracer, operationName string, opts ...EndpointOption) endpoint.Middleware

TraceClient returns a Middleware that wraps the `next` Endpoint in an OpenTracing Span called `operationName` with client span.kind tag.

func TraceEndpoint added in v0.11.0

func TraceEndpoint(tracer opentracing.Tracer, operationName string, opts ...EndpointOption) endpoint.Middleware

TraceEndpoint returns a Middleware that wraps the `next` Endpoint in an OpenTracing Span called `operationName`.

If `ctx` already has a Span, child span is created from it. If `ctx` doesn't yet have a Span, the new one is created.

func TraceServer

func TraceServer(tracer opentracing.Tracer, operationName string, opts ...EndpointOption) endpoint.Middleware

TraceServer returns a Middleware that wraps the `next` Endpoint in an OpenTracing Span called `operationName` with server span.kind tag..

Types

type EndpointOption added in v0.11.0

type EndpointOption func(*EndpointOptions)

EndpointOption allows for functional options to endpoint tracing middleware.

func WithIgnoreBusinessError added in v0.11.0

func WithIgnoreBusinessError(ignoreBusinessError bool) EndpointOption

WithIgnoreBusinessError if set to true will not treat a business error identified through the endpoint.Failer interface as a span error.

func WithOperationNameFunc added in v0.11.0

func WithOperationNameFunc(getOperationName func(ctx context.Context, name string) string) EndpointOption

WithOperationNameFunc allows to set function that can set the span operation name based on the existing one for the endpoint and information in the context.

func WithOptions added in v0.11.0

func WithOptions(options EndpointOptions) EndpointOption

WithOptions sets all configuration options at once by use of the EndpointOptions struct.

func WithTags added in v0.11.0

func WithTags(tags opentracing.Tags) EndpointOption

WithTags adds default tags for the spans created by the Endpoint tracer.

func WithTagsFunc added in v0.11.0

func WithTagsFunc(getTags func(ctx context.Context) opentracing.Tags) EndpointOption

WithTagsFunc set the func to extracts additional tags from the context.

type EndpointOptions added in v0.11.0

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

	// GetOperationName is an optional function that can set the span operation name based on the existing one
	// 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.
	GetOperationName func(ctx context.Context, name string) string

	// Tags holds the default tags which will be set on span
	// creation by our Endpoint middleware.
	Tags opentracing.Tags

	// GetTags is an optional function that can extract tags
	// from the context and add them to the span.
	GetTags func(ctx context.Context) opentracing.Tags
}

EndpointOptions holds the options for tracing an endpoint

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL