Skip to content
All flows
traces
metrics

Span Metrics (RED)

Generates RED metrics from spans with the spanmetrics connector — explicit latency buckets, HTTP dimensions, exemplars, and a 10k cardinality cap — after normalizing span names so route explosions don't inflate the metric space.

Turns spans into RED metrics with the spanmetrics connector: explicit histogram buckets from 2ms to 15s, `http.request.method` and `http.response.status_code` dimensions, exemplars for jumping from a latency spike straight to a trace, and an aggregation cardinality cap of 10,000 series as a blast-radius limit. `resource_metrics_key_attributes` pins series identity to service name, namespace, and SDK language so pod churn doesn't fragment the metrics. Span names are normalized to semantic-conventions 1.37.0 with `set_semconv_span_name` before metrics are generated — high-cardinality span names are the classic way spanmetrics blows up. Traces continue to your trace backend over OTLP; the generated metrics go to your OTLP/HTTP endpoint via `OTLP_GATEWAY_ENDPOINT`.

Before you use this

Sends data to

otlp
otlphttp

You'll need to set these before it runs

OTLP_GATEWAY_ENDPOINT

The configuration

collector v0.147.0
# OpenTelemetry Collector Configuration
# Generated by Telflo

receivers:
  otlp:
    protocols:
      grpc:
        endpoint: '0.0.0.0:4317'
      http:
        endpoint: '0.0.0.0:4318'
processors:
  memory_limiter:
    check_interval: '1s'
    limit_percentage: 80
    spike_limit_percentage: 25
  transform/sanitize_spans:
    error_mode: 'ignore'
    trace_statements:
      - context: 'span'
        statements:
          - 'set_semconv_span_name("1.37.0")'
  batch:
    timeout: '10s'
exporters:
  otlp:
    endpoint: 'tempo.example.internal:4317'
    tls:
      insecure: true
  otlphttp:
    endpoint: '${env:OTLP_GATEWAY_ENDPOINT}' # e.g. https://otlp-gateway-<stack>.grafana.net/otlp
connectors:
  spanmetrics:
    histogram:
      explicit:
        buckets:
          - '2ms'
          - '4ms'
          - '6ms'
          - '8ms'
          - '10ms'
          - '50ms'
          - '100ms'
          - '200ms'
          - '400ms'
          - '800ms'
          - '1s'
          - '1400ms'
          - '2s'
          - '5s'
          - '10s'
          - '15s'
    dimensions:
      - name: 'http.request.method'
        default: 'GET'
      - name: 'http.response.status_code'
    exclude_dimensions:
      - 'span.kind'
    exemplars:
      enabled: true
    aggregation_cardinality_limit: 10000
    metrics_flush_interval: '15s'
    resource_metrics_key_attributes:
      - 'service.name'
      - 'service.namespace'
      - 'telemetry.sdk.language'
service:
  pipelines:
    traces:
      receivers: [otlp]
      processors: [memory_limiter, transform/sanitize_spans, batch]
      exporters: [otlp, spanmetrics]
    metrics:
      receivers: [spanmetrics]
      processors: [batch]
      exporters: [otlphttp]

Validated against otelcol-contrib v0.147.0. Fill in the ${env:…} placeholders before running it.

spanmetrics
traces
metrics