tracing

package
v11.3.4 Latest Latest
Warning

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

Go to latest
Published: Dec 14, 2022 License: Apache-2.0 Imports: 11 Imported by: 0

Documentation

Index

Constants

View Source
const TraceParent = "traceparent"

TraceParent is the name of the header or query parameter that contains tracing context across service boundaries.

Variables

This section is empty.

Functions

func DefaultProvider

func DefaultProvider() oteltrace.TracerProvider

DefaultProvider returns the global default TracerProvider.

func HTTPHandlerFormatter

func HTTPHandlerFormatter(operation string, r *http.Request) string

HTTPHandlerFormatter is a span formatter that may be provided to otelhttp.WithSpanNameFormatter to include the component and url path in the span names generated by otelhttp.NewHandler

func HTTPTransportFormatter

func HTTPTransportFormatter(_ string, r *http.Request) string

HTTPTransportFormatter is a span formatter that may be provided to otelhttp.WithSpanNameFormatter to include the url path in the span names generated by an otelhttp.Transport

func WithPropagationContext

func WithPropagationContext(ctx context.Context, pc PropagationContext, opts ...Option) context.Context

WithPropagationContext injects any tracing information from the given PropagationContext into the given context.Context.

Types

type Client

type Client struct {
	otlptrace.Client
	// contains filtered or unexported fields
}

Client is a wrapper around an otlptrace.Client that provides a mechanism to close the underlying grpc.ClientConn. When an otlpgrpc.Client is constructed with the WithGRPCConn option, it is up to the caller to close the provided grpc.ClientConn. As such, we wrap and implement io.Closer to allow users to have a way to close the connection.

In the event the client receives a trace.NotImplemented error when uploading spans, it will prevent any future spans from being sent. The server receiving the span is not going to change for the life of the grpc.ClientConn. In an effort to reduce wasted bandwidth, the client merely drops any spans in that case and returns nil.

func NewClient

func NewClient(conn *grpc.ClientConn) *Client

NewClient returns a new Client that uses the provided grpc.ClientConn to connect to the OpenTelemetry exporter.

func (*Client) Close

func (c *Client) Close() error

Close closes the underlying grpc.ClientConn. This is required since when using otlptracegrpc.WithGRPCConn the otlptrace.Client does not close the connection when Shutdown is called.

func (*Client) UploadTraces

func (c *Client) UploadTraces(ctx context.Context, protoSpans []*otlp.ResourceSpans) error

type Config

type Config struct {
	TracerProvider    oteltrace.TracerProvider
	TextMapPropagator propagation.TextMapPropagator
}

Config stores tracing related properties to customize creating Tracers and extracting TraceContext

func NewConfig

func NewConfig(opts []Option) *Config

NewConfig returns a Config configured with all the passed Option.

type Option

type Option interface {
	// contains filtered or unexported methods
}

Option applies an option value for a Config.

func WithTextMapPropagator

func WithTextMapPropagator(p propagation.TextMapPropagator) Option

WithTextMapPropagator returns an Option to use the propagation.TextMapPropagator when extracting and injecting trace context.

func WithTracerProvider

func WithTracerProvider(tp oteltrace.TracerProvider) Option

WithTracerProvider returns an Option to use the trace.TracerProvider when creating a trace.Tracer.

type PropagationContext

type PropagationContext map[string]string

PropagationContext contains tracing information to be passed across service boundaries

func PropagationContextFromContext

func PropagationContextFromContext(ctx context.Context, opts ...Option) PropagationContext

PropagationContextFromContext creates a PropagationContext from the given context.Context. If the context does not contain any tracing information, the PropagationContext will be empty.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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