4. Monitoring, Logging and Statistics

openTelemetry

Version

OpenTelemetry is an open observability standard for distributed tracing. It tracks a request as it travels across services by passing a traceparent header from hop to hop and collecting timing data (spans) in a central backend such as Jaeger or Zipkin. Membrane supports OpenTelemetry by creating one INTERNAL span per request: it extracts the incoming W3C trace context from request headers, opens the span, and injects the updated traceparent into the forwarded request so downstream services join the same trace. HTTP headers are recorded as http.header.* attributes, the response status as http.status_code, and for API proxies the OpenAPI title as openapi.title. The traceId and spanId are written into SLF4J MDC automatically so every log line carries them. Aborted exchanges are marked ERROR. Declare the plugin in global: to instrument all APIs at once. See tutorials/operation/40-OpenTelemetry.yaml for a runnable multi-hop example with Jaeger, and examples/monitoring-tracing/opentelemetry for screenshots.
 openTelemetry:
   [ sampleRate: 0.0..1.0 ]        # default: 1.0
   [ logBody: true | false ]        # default: false
   [ otlpExporter: ... ]            # defaults to localhost:4317 over gRPC
   [ customAttribute:
       - name: key
         value: val
       ... ]
 

Example Configuration

global:
- openTelemetry:
sampleRate: 1.0
otlpExporter:
host: localhost
port: 4317
transport: grpc
global:
   - openTelemetry:
       sampleRate: 1.0
       otlpExporter:
         host: localhost
         port: 4317
         transport: grpc

Syntax

openTelemetry:
customAttributes:
- <customAttribute>
logBody: <boolean>
otlpExporter: {}
sampleRate: <number>
openTelemetry:
  customAttributes:
    - <customAttribute>
  logBody: <boolean>
  otlpExporter: {}
  sampleRate: <number>

Attributes

NameRequiredDefaultDescriptionExamples
logBodyfalsefalseWhen true, records request and response bodies as span events. Reads the entire body into memory; avoid on large or streaming payloads.-
sampleRatefalse1.0Fraction of requests to sample, between 0.0 (none) and 1.0 (all).-

Child Structure

ElementCardinalityDescription
customAttribute0..*Static key-value pairs attached as attributes to every span. Useful for tagging traces with environment, region, or deployment metadata.
otlpExporter0..1Exports spans to an OpenTelemetry collector using the OTLP protocol over gRPC or HTTP. Defaults to gRPC on localhost:4317. Switch to HTTP by setting transport: http (default port 4318, default path /v1/traces). Set secured: true to use HTTPS. Custom request headers can be added for hosted collectors that require authorization.

Can be used in