Documentation ¶
Index ¶
- Constants
- func DefaultProvider() oteltrace.TracerProvider
- func EndSpan(span oteltrace.Span, err error)
- func NewTracer(name string) oteltrace.Tracer
- func WithPropagationContext(ctx context.Context, pc PropagationContext, opts ...Option) context.Context
- type Client
- type Config
- type Option
- type PropagationContext
Constants ¶
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 EndSpan ¶
EndSpan ends the given span and if an error has occurred, set's the span's status to error and additionally records the error.
Example usage:
func myFunc() (err error) { ctx, span := tracer.Start(ctx, "myFunc") defer func() { tracing.EndSpan(span, err) }() ... }
func NewTracer ¶
NewTracer creates a new oteltrace.Tracer from the global default oteltrace.TracerProvider with the provided name.
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 ¶
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 ¶
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 ¶
type Config ¶
type Config struct { TracerProvider oteltrace.TracerProvider TextMapPropagator propagation.TextMapPropagator }
Config stores tracing related properties to customize creating Tracers and extracting TraceContext
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 ¶
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.