Documentation
¶
Index ¶
- func DiscardSpanInContext(ctx context.Context) context.Context
- func InitializeTracerProvider(ctx context.Context, serviceName string) (trace.TracerProvider, io.Closer, error)
- func IsSampled(ctx context.Context) bool
- func NewGRPCClientStatsHandler(opts ...otelgrpc.Option) stats.Handler
- func NewGRPCServerStatsHandler(opts ...otelgrpc.Option) stats.Handler
- func PropagateFromEnv(envs []string) (context.Context, error)
- func StartSpan(ctx context.Context, spanName string, attrs []attribute.KeyValue, ...) (trace.Span, context.Context)
- func StartSpanIfHasParent(ctx context.Context, spanName string, attrs []attribute.KeyValue, ...) (trace.Span, context.Context)
- func StreamPassthroughInterceptor(contextToInject context.Context) grpc.StreamClientInterceptor
- func UnaryPassthroughInterceptor(contextToInject context.Context) grpc.UnaryClientInterceptor
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func DiscardSpanInContext ¶
DiscardSpanInContext discards the current active span in the context by replacing it with a non-recording span. If the context does not contain any active span, it is left intact. This function is helpful when the current code path enters an area shared by other code paths. Git catfile cache is a good example of this type of span.
func InitializeTracerProvider ¶
func InitializeTracerProvider(ctx context.Context, serviceName string) (trace.TracerProvider, io.Closer, error)
InitializeTracerProvider creates an OpenTelemetry tracer provider. The configuration is coming from the GITLAB_TRACING environment variable in the form of a connection string. It has two format: 1. opentracing://jaeger?host=localhost:1234&opt1=val1&opt2=val2 2. otlp-<grpc|http>:host:port?opt1=val2&opt2=val2 The function returns a TracerProvider, an io.Closer to close the TracerProvider and an error. NOTE: If an error occurs, the returned tracer provider is a Noop Tracer Provider. Thus, it is always safe to register the returned tracer, even in case of an error. This allows to return non-critical errors that can be logged by the caller to debug tracer misconfiguration.
func NewGRPCClientStatsHandler ¶
NewGRPCClientStatsHandler is an OTEL instrumented middleware for gRPC client. It returns a stats.Handler as recommended by the OTEL project after deprecating the UnaryClientInterceptor. See: https://pkg.go.dev/go.opentelemetry.io/contrib/instrumentation/google.golang.org/grpc/otelgrpc@v0.54.0#UnaryServerInterceptor
func NewGRPCServerStatsHandler ¶
NewGRPCServerStatsHandler is an OTEL instrumented middleware for gRPC servers. It returns a stats.Handler as recommended by the OTEL project after deprecating the UnaryServerInterceptor. See: https://pkg.go.dev/go.opentelemetry.io/contrib/instrumentation/google.golang.org/grpc/otelgrpc@v0.54.0#UnaryServerInterceptor
func PropagateFromEnv ¶
PropagateFromEnv propagates the SpanContext extracted from environment variables into a new context that can later be used to create child spans.
func StartSpan ¶
func StartSpan(ctx context.Context, spanName string, attrs []attribute.KeyValue, opts ...trace.SpanStartOption) (trace.Span, context.Context)
StartSpan creates a new span with name, attributes and options. This function is a wrapper for underlying tracing libraries. This method should only be used at the entrypoint of the program.
func StartSpanIfHasParent ¶
func StartSpanIfHasParent(ctx context.Context, spanName string, attrs []attribute.KeyValue, opts ...trace.SpanStartOption) (trace.Span, context.Context)
StartSpanIfHasParent creates a new span if the context already has an existing span. This function adds a simple validation to prevent orphan spans outside interested code paths. It returns a dummy span, which acts as normal span, but does absolutely nothing and is not recorded later.
func StreamPassthroughInterceptor ¶
func StreamPassthroughInterceptor(contextToInject context.Context) grpc.StreamClientInterceptor
StreamPassthroughInterceptor is equivalent to UnaryPassthroughInterceptor, but for streaming gRPC calls.
func UnaryPassthroughInterceptor ¶
func UnaryPassthroughInterceptor(contextToInject context.Context) grpc.UnaryClientInterceptor
UnaryPassthroughInterceptor is a client gRPC unary interceptor that injects a span context into the outgoing context of the call. It is useful to propagate span context between processes that do not have automatic span propagation between them.
Types ¶
This section is empty.