Documentation
¶
Overview ¶
Package otel wires OpenTelemetry traces and logs for the MCP server.
OTel is opt-in: if neither CRDB_MCP_OTEL_FILE nor OTEL_EXPORTER_OTLP_ENDPOINT is set, Setup installs no exporters and the global providers stay no-op.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func AttachZapBridge ¶
AttachZapBridge wraps logger so each record is also exported as an OTel log record via the global LoggerProvider. Call only after Setup returned a non-nil shutdown (i.e. an exporter is actually configured).
func SafeSpanError ¶
SafeSpanError strips pgx error Message/Detail/Where fields, which can echo the offending SQL and user data into span events and status descriptions, undermining the query-text redaction applied to span attributes.
Types ¶
type ShutdownFunc ¶
ShutdownFunc flushes and closes any registered exporters.
func Setup ¶
func Setup( ctx context.Context, cfg *config.Config, serviceName, serviceVersion string, ) (ShutdownFunc, error)
Setup installs trace and log providers based on cfg:
- cfg.OTelFile set: stdout exporters write JSON to that file (good for local dev or file-based shippers like Filebeat, Vector).
- cfg.OTLPEndpoint set: OTLP gRPC exporters honor the standard OTEL_* env vars (Datadog Agent, OTel Collector, Tempo, Honeycomb, ELK).
- neither set: returns a no-op shutdown and the global providers stay no-op.
File mode takes precedence when both are configured.