Documentation
¶
Overview ¶
Package tracing sets up OpenTelemetry tracing for the server and the demo programs from the standard OTEL_* environment variables (design §18.3). The Go SDK never imports it: libraries leave exporter setup to the application.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Enabled ¶
Enabled reports whether an OTLP endpoint is configured and tracing is not switched off. The standard OTEL_SDK_DISABLED=true and OTEL_TRACES_EXPORTER=none win over an endpoint, so an operator can turn tracing off without removing the endpoint from a shared environment.
func ParentOnly ¶
func ParentOnly(next pgx.QueryTracer) pgx.QueryTracer
ParentOnly passes a query to next only when the context already carries a span: queries made for an RPC nest under its span, while the reaper, pruner and depth refresh, which run every second or minute with no job in them, create no traces (design §18.1, decision 2).
func Setup ¶
func Setup(ctx context.Context, getenv func(string) string, serviceName string) (trace.TracerProvider, func(context.Context) error, error)
Setup returns a tracer provider and a shutdown function that flushes buffered spans. Without an OTLP endpoint the provider is a no-op and costs nothing. Otherwise spans go to the endpoint over OTLP/gRPC in batches; the exporter, the sampler (OTEL_TRACES_SAMPLER, default parentbased_always_on) and OTEL_SERVICE_NAME are read from the environment by the OpenTelemetry SDK itself. serviceName is the default when OTEL_SERVICE_NAME is unset.
Types ¶
type LogHandler ¶
LogHandler adds trace_id and span_id to records logged with a context that carries a span, so a log line can be found from its trace and back.