Documentation
a project

tracing

Enables integration with OpenTelemetry tracing facilities, using opentelemetry-go .

When enabled, it will propagate an existing trace context or initialize a new one.

It uses gRPC as an exporter protocol and W3C tracecontext and baggage as propagators.

The trace ID is added to access logs as the standard traceID field. Additionally, the {http.vars.trace_id} placeholder is made available, for example to add the ID to a (request_header)[request_header] to pass it to your app.

Syntax

tracing {
	[span <span_name>]
}
  • <span_name> is a span name. Please see span naming guidelines.

    Placeholders may be used in span names; keep in mind that tracing happens as early as possible, so only request placeholders may be used, and not response placeholders.

Configuration

Environment variables

It can be configured using the environment variables defined by the OpenTelemetry Environment Variable Specification.

For the exporter configuration details, please see spec.

For example:

export OTEL_EXPORTER_OTLP_HEADERS="myAuthHeader=myToken,anotherHeader=value"
export OTEL_EXPORTER_OTLP_TRACES_ENDPOINT=https://my-otlp-endpoint:55680

Examples

Here is a Caddyfile example:

example.com {
	handle /api* {
		tracing {
			span api
		}
		request_header X-Trace-Id {http.vars.trace_id}
		reverse_proxy localhost:8081
	}

	handle {
		tracing {
			span app
		}
		reverse_proxy localhost:8080
	}
}