tracing

package
v0.2.3 Latest Latest
Warning

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

Go to latest
Published: Sep 17, 2026 License: Apache-2.0 Imports: 18 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GRPCStreamServerInterceptor

func GRPCStreamServerInterceptor(tp trace.TracerProvider, propagator propagation.TextMapPropagator, outboundProp propagation.TextMapPropagator) grpc.StreamServerInterceptor

GRPCStreamServerInterceptor returns a stream server interceptor for passive OpenTelemetry trace participation. outboundProp is stored on the stream context so gRPC stream handlers that make outbound calls can retrieve the configured propagator via OutboundPropagatorFromContext without touching those handlers' signatures.

func GRPCUnaryServerInterceptor

func GRPCUnaryServerInterceptor(tp trace.TracerProvider, propagator propagation.TextMapPropagator, outboundProp propagation.TextMapPropagator) grpc.UnaryServerInterceptor

GRPCUnaryServerInterceptor returns a unary server interceptor for passive OpenTelemetry trace participation. outboundProp is stored on the request context so gRPC handlers that make outbound calls (e.g. StartSourceURLAttachmentDownload) can retrieve the configured propagator via OutboundPropagatorFromContext without touching those handlers' signatures.

func HTTPMiddleware

HTTPMiddleware creates a Gin middleware for passive OpenTelemetry trace participation. outboundProp is stored on the request context so per-request handlers that make outbound calls (e.g. source-URL attachment downloads) can retrieve the configured propagator via OutboundPropagatorFromContext without touching the signature of those handlers.

func IsParticipating

func IsParticipating(ctx context.Context) bool

IsParticipating returns true if the context is participating in an upstream trace.

func MarkParticipating

func MarkParticipating(ctx context.Context) context.Context

MarkParticipating marks the context as an active participant in an upstream trace.

func NewParticipatingPropagator

func NewParticipatingPropagator(base propagation.TextMapPropagator) propagation.TextMapPropagator

NewParticipatingPropagator creates a new ParticipatingPropagator.

func OutboundPropagatorFromContext

func OutboundPropagatorFromContext(ctx context.Context) propagation.TextMapPropagator

OutboundPropagatorFromContext retrieves the outbound propagator stored by WithOutboundPropagatorContext. Returns a TraceContext-only participating propagator if none was stored, preserving the pre-fix behaviour.

func ProviderFromContext

func ProviderFromContext(ctx context.Context) trace.TracerProvider

ProviderFromContext retrieves the TracerProvider stored by WithProviderContext. Returns nil if none was stored.

func ProviderFromContextOrNoop

func ProviderFromContextOrNoop(ctx context.Context) trace.TracerProvider

ProviderFromContextOrNoop retrieves the TracerProvider stored by WithProviderContext. Returns a noop TracerProvider if ctx is nil or none was stored.

func TraceContextFromContext

func TraceContextFromContext(ctx context.Context) (traceID string, spanID string)

TraceContextFromContext returns the active traceID and spanID only if the context is participating and valid.

func WithNoBaggage

WithNoBaggage wraps prop so its Inject never writes the "baggage" key. Use this to thread a configured trace propagator into outbound clients that must not forward internal baggage to third-party services (OpenAI, Qdrant, etc.).

func WithOutboundPropagatorContext

func WithOutboundPropagatorContext(ctx context.Context, prop propagation.TextMapPropagator) context.Context

WithOutboundPropagatorContext stores the outbound propagator in ctx so plugin loaders can retrieve it via OutboundPropagatorFromContext. The outbound propagator is the configured inbound propagator with baggage stripped, wrapped in ParticipatingPropagator, so it honours OTEL_PROPAGATORS on outbound calls.

func WithProviderContext

func WithProviderContext(ctx context.Context, tp trace.TracerProvider) context.Context

WithProviderContext stores the given TracerProvider in ctx so plugin loaders can retrieve it via ProviderFromContext.

Types

type ParticipatingPropagator

type ParticipatingPropagator struct {
	// contains filtered or unexported fields
}

ParticipatingPropagator wraps a TextMapPropagator, making Inject a no-op unless IsParticipating(ctx) is true.

func (*ParticipatingPropagator) Extract

Extract delegates directly to the underlying propagator.

func (*ParticipatingPropagator) Fields

func (p *ParticipatingPropagator) Fields() []string

Fields returns the underlying propagator fields.

func (*ParticipatingPropagator) Inject

Inject writes the trace context if the context is participating in an upstream trace.

type QueryRedactingExporter

type QueryRedactingExporter struct {
	// contains filtered or unexported fields
}

QueryRedactingExporter wraps a SpanExporter and strips RawQuery from the url.full attribute of every span before forwarding to the delegate.

Motivation: otelhttp records url.full as req.URL.String(), which includes any query string. Memory-service source URLs may carry presigned S3 signatures or OAuth tokens as query parameters. Stripping RawQuery before export prevents those credentials from reaching the trace backend.

Intentional tradeoff: all query strings are stripped from every url.full in every exported span, including benign parameters such as pagination cursors and filter keys. We cannot distinguish a presigned signature from a page number at export time, so blanket stripping is the correct call. Traces will show bare paths (e.g. "https://host/path") without query detail — this is expected and deliberate.

Placement: register this wrapper around the real exporter in buildTracerProvider (internal/cmd/serve/server.go). Issue 5 rewrites that function to honour standard OTEL_ env vars; it must preserve this wrapper around whatever exporter it constructs. When no exporter is configured (the noop path) this wrapper is never constructed, so there is nothing to sanitise and nothing leaks.

Scope: applied at the provider level, this covers all five outbound HTTP clients uniformly — not just the attachment downloader.

func NewQueryRedactingExporter

func NewQueryRedactingExporter(delegate sdktrace.SpanExporter) *QueryRedactingExporter

NewQueryRedactingExporter returns a QueryRedactingExporter that sanitises url.full on every span before forwarding to delegate.

func (*QueryRedactingExporter) ExportSpans

func (e *QueryRedactingExporter) ExportSpans(ctx context.Context, spans []sdktrace.ReadOnlySpan) error

ExportSpans sanitises url.full on each span then delegates to the wrapped exporter.

func (*QueryRedactingExporter) Shutdown

func (e *QueryRedactingExporter) Shutdown(ctx context.Context) error

Shutdown forwards to the delegate.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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