Documentation
¶
Overview ¶
Package tracing follows a request across nodes with OpenTelemetry.
Every request gets a W3C trace id: it is logged, returned to the client and passed on to the nodes the request reaches. Spans are only recorded and exported over OTLP/HTTP when tracing is enabled.
Index ¶
- Constants
- func Extract(ctx context.Context, header func(string) string) context.Context
- func SetStatus(span trace.Span, code int)
- func Start(ctx context.Context, cfg Config) (func(context.Context) error, error)
- func TraceID(ctx context.Context) string
- func Tracer() trace.Tracer
- func Transport(base http.RoundTripper) http.RoundTripper
- type Config
- type Hook
Constants ¶
const (
// TraceIDHeader returns the trace id to the client.
TraceIDHeader = "X-Trace-Id"
)
Variables ¶
This section is empty.
Functions ¶
func Start ¶
Start sets up tracing, it must run before the server serves requests. The returned function flushes buffered spans on shutdown.
func Transport ¶
func Transport(base http.RoundTripper) http.RoundTripper
Transport traces the requests sent to other nodes: one client span per request, ended when the response body is closed, and the trace context in the request headers. A nil base uses http.DefaultTransport.
Types ¶
type Config ¶
type Config struct {
// Enable records and exports spans.
Enable bool
// Endpoint is the full OTLP/HTTP traces URL, e.g.
// http://localhost:4318/v1/traces. Empty uses the
// OTEL_EXPORTER_OTLP_* environment, then localhost:4318.
Endpoint string
// Service and Version name this process, Node tells cluster nodes apart.
Service, Version, Node string
}
Config selects where spans go.