Tracing block

Cerbos supports distributed tracing to provide insights into application performance and request lifecycle. To enable tracing, set sampleProbability to a value between 0.0 and 1.0. Setting the probability to 1.0 makes Cerbos capture tracing information for all requests and setting it to 0.0 disables capturing any traces.

The system to export the trace data must be specified using the exporter setting. Currently only Jaeger is supported. Traces can be sent to either Jaeger Agent (compact Thrift format) or Jaeger Collector (Thrift format).

OpenTelemetry

OpenTelemetry is the evolving standard for observability. Cerbos supports OpenTelemetry with a few caveats due to limitations in the current Go implementation of OpenTelemetry.

  • Traces must be in one of W3C Trace Context or B3 propagation formats in order for distributed tracing to work. You must configure this using tracing.propagationFormat configuration key (see below). The default is w3c-tracecontext.

    In Go applications, the propagation format can be set using one of the following code snippets. For other languages, refer to the relevant OpenTelemetry library documentation.

    // W3C Trace Context
    otel.SetTextMapPropagator(propagation.TraceContext{})
    
    // B3
    otel.SetTextMapPropagator(b3.New(b3.WithInjectEncoding(b3.B3MultipleHeader | b3.B3SingleHeader)))
  • gRPC clients should use the OpenCensus binary propagation format for distributed traces.

  • Metrics are not yet supported.

Jaeger

Send trace data to Jaeger Agent (compact Thrift)
tracing:
  sampleProbability: 0.5
  propagationFormat: b3
  exporter: jaeger
  jaeger:
    serviceName: cerbos
    agentEndpoint: "localhost:6831"
Send trace data to Jaeger Collector (Thrift)
tracing:
  sampleProbability: 0.5
  exporter: jaeger
  jaeger:
    serviceName: cerbos
    collectorEndpoint: "http://localhost:14268/api/traces"