Generating metrics from traces with the span metrics connector

The span metrics connector turns every span into request rate, error and duration metrics before sampling drops most traces, so dashboards stay accurate at lower trace cost.

On this page

How the span metrics connector keeps dashboards accurate while most traces are dropped

Once head or tail sampling has cut trace volume, any dashboard that counts requests or errors from stored traces will undercount, because the dropped traces never reach the back end. The fix is to derive metrics from spans before the sampling decision removes them. The span metrics connector in the OpenTelemetry Collector does this: it reads spans flowing through a traces pipeline and emits request rate, error and duration metrics, so the numbers reflect all traffic while only a fraction of the trace bodies are kept. The connector sits between the traces pipeline and a metrics pipeline in the Collector configuration, and its output is a normal metric stream that your existing tools can query.

OpenTelemetry is not an observability backend, so the derived metrics still need a store and a visualization tool, such as Prometheus-compatible storage with Grafana or another system your team already runs. Confirm that your chosen back end accepts the metric names, units and labels the connector produces, and review the connector's README for the current configuration keys and stability level, since Collector components have mixed stability. Plan label cardinality early: span attributes such as user IDs or full URLs become metric labels unless you remove them, and that drives storage cost in the metrics back end.

Teams usually need this when they sample aggressively and still rely on traces for service-level dashboards or alerts. They usually do not need it when they keep all traces, when sampling is light, or when metrics already come from instrumented application code or infrastructure exporters that cover the same questions. Before you commit, ask the implementation team to compare derived counts against a known test load and to document which sampling stage sits before the connector, because that placement determines whether the metrics represent all requests or only the sampled ones.

Where span metrics are derived relative to sampling

The diagram starts at the instrumented applications, which send every span to a Collector agent or gateway. The span metrics connector sits on a branch that receives all spans before any sampling step, so request, error and duration metrics reflect full traffic. The second branch runs the tail sampling processor, and only the kept traces continue to the trace backend. Check that the connector sees spans before the sampler in your own pipeline configuration, because the ordering determines whether dashboards match real traffic.

Span metrics are computed from every span, while only kept traces reach the trace backend.

Configuration options and when each fits

This table compares the main span metrics connector settings: dimensions, histogram buckets, exemplars, namespace and temporality. Read each row for when the setting fits and what it adds to series count, then confirm the key names against the connector README for your Collector version.

SettingWhen it fitsCost in series and storageWhat to confirm
Dimensions: service onlyService-level request rate and error ratio dashboards where only a few owners need a breakdownLowest series count, one set of series per service and operation pair at mostDefault dimensions in the README for your release
Dimensions: span namePer-endpoint or per-operation views when span names are stable and boundedGrows with the number of distinct span names, so templated or ID-bearing names multiply seriesWhether span names are normalized before the connector sees them
Dimensions: status codeError rate panels and alerts that need to separate 4xx and 5xx or client and server errorsAdds a small multiplier per existing series, usually modestHow the connector maps status codes and span kind to error counts
Dimensions: selected attributesTeam or tenant breakdowns that answer a specific question, such as a region or payment providerEach added attribute multiplies series, and unbounded values such as user IDs can explode storageWhich attribute keys are allowed and how missing attributes are reported
Histogram buckets: defaultsEarly rollout when you need duration percentiles without tuningEach bucket is a series per label set, so the default bucket list sets a baseline costDefault bucket boundaries in the README for your version
Histogram buckets: custom boundariesLatency SLOs with thresholds your teams already measure, such as a target response timeMore buckets raise series count and back-end cost, fewer buckets lose percentile precisionWhether explicit bucket boundaries are supported and their units
ExemplarsJumping from a slow metric point to a representative trace during incident triageAdds data per sample rather than new series, but needs the trace backend to link backWhether exemplars are emitted and how the back end stores them
Metric namespaceKeeping derived metrics separate from metrics your SDKs already emit, avoiding name collisionsNo direct series cost, but a rename after dashboards exist breaks queriesThe namespace prefix setting and resulting metric names in your back end
Temporality: cumulativePrometheus-compatible back ends and most existing dashboards and alert rulesStable series over time, the usual default for pull-based scrapesWhich temporality your exporter and back end expect
Temporality: deltaPush-based back ends that aggregate deltas, or where you need per-interval countsSeries count is similar, but gaps and resets behave differently during restartsWhether your chosen exporter and back end accept delta metrics

How to set up span metrics in a Collector pipeline

This sequence turns spans into request rate, error and duration metrics inside the Collector, placed ahead of any sampling so the dashboards keep working after most traces are dropped. Each step ends with a check that tells you whether the pipeline is doing what the design says.

  1. Confirm the connector is in your Collector build

    Before writing any configuration, check that the Collector binary includes the span metrics connector. The contrib distribution from the OpenTelemetry Collector releases includes it, and a custom build made with the Collector builder must list it explicitly, so the platform engineer who owns the build should confirm this against the component list for the release in use. Run the binary's component listing command and confirm the connector appears under connectors. You are done when the connector is present in the running version, not only in the source configuration you plan to deploy.

  2. Define the metric dimensions and naming plan

    Decide which span attributes become metric labels before you touch the pipeline. Service name, span name or route, span kind and status code are common starting points, and each extra dimension multiplies the number of series the back end stores. Ask the application teams which attributes they filter on in dashboards and alerts, and keep the list short. Record the expected metric names and the label set in a short design note that the team can review. The step is complete when the note lists every dimension, the reason for it, and an owner who signs off on it.

  3. Place the connector ahead of sampling in the traces pipeline

    In the Collector configuration, add the connector as an exporter on the traces pipeline and as a receiver on a new metrics pipeline. The connector must sit before any tail sampling or filtering processor in the traces pipeline, because a processor that runs earlier removes spans the connector never sees. Keep the original trace exporter on the same pipeline so sampled traces still reach storage. The step is done when the configuration validates and the traces pipeline lists the connector before the sampling stage.

  4. Route connector output into a metrics pipeline

    Create a metrics pipeline that receives from the connector and exports to your metrics back end, which is usually a Prometheus-compatible store. Add any metric-level processors here, such as a batch processor, and avoid filters that would remove the derived series. Confirm that the metrics pipeline does not also receive the raw metrics from the same source through another path, since that creates duplicate series. The step is complete when the Collector starts cleanly and the back end shows the derived metric names within the time the Collector is configured to flush.

  5. Verify metric names and labels with a test load

    Send a known test load through the application or a synthetic trace generator. Use a small set of requests with known routes, status codes and durations, so you can predict what the output should show. Query the back end and compare the metric names, label keys and approximate counts against your design note. Look for missing dimensions, unexpected labels, and any counts that differ noticeably from the number of requests you sent. The step is done when the counts match the test load for the dimensions you chose.

  6. Check for duplicate metrics

    Query for the same metric name appearing from more than one source, and for series that differ only in a label you did not intend to add. Duplicates usually come from two pipelines both exporting to the same back end, or from an application that already emits a metric with the same name. Fix the pipeline so only one path produces each series, then rerun the test load. The check passes when every derived metric has a single series per label set for the test traffic.

  7. Check for dropped spans and series growth

    Review the Collector's own telemetry for dropped spans, refused data and exporter errors, which the Collector exposes through its internal metrics. Confirm that the span count seen by the connector matches the count received by the traces pipeline before sampling. Then watch the number of active series over several hours of normal traffic, and compare it to the series count in your design note. Ask the team to confirm which growth is expected and which signals a new high-cardinality attribute. The step is complete when drop counters stay flat under normal load and series growth matches the plan.

Cardinality and series growth risks to plan for

Deriving metrics from every span multiplies the number of time series, and each new attribute, span name or bucket adds to that count. The risks below share one cause, so plan the attribute list, span naming and Collector capacity together before the connector goes live.

High-cardinality span attributes

Dimensions such as user IDs, session IDs or full URLs with query strings create a new series for nearly every request. Only promote attributes that have a bounded set of values, such as route template, method, status class or service name. Review the connector's dimension list before rollout and confirm each entry against the span attributes your services actually emit.

Collector configuration docs

Unbounded span names

If span names include identifiers, such as GET /orders/83716, every distinct name becomes a separate metric series. Instrument services so span names use route templates, and confirm this in code review or in a sample of exported spans. Treat any span name that contains an ID as a defect to fix at the source, not something the connector should absorb.

Histogram bucket count

Duration histograms produce one series per bucket for every label combination, so the bucket boundaries multiply the cost of each dimension. Keep the bucket list short and aligned with the latency targets your team actually alerts on. Confirm the boundaries and the resulting series count in a test environment before expanding the dimension list.

Memory pressure in the Collector

The connector keeps state for each unique series in memory until the series expire, so a series explosion shows up first as Collector memory growth and restarts. Size the gateway for the expected series count, set memory limits on the processors that run before the connector, and alert on Collector memory before the restarts begin. Ask the team operating the Collector to confirm the limits in your environment.

Collector docs

Derived and sampled counts diverge

The connector counts every span before sampling, while trace backends only show the sampled traces. A request rate panel built from derived metrics will therefore not match the number of traces a team can open. Document this difference for on-call engineers, and check whether the sampling rate is applied to the derived counts in your setup.

Duplicate series from two pipelines

If two pipelines, such as an agent and a gateway, both run the connector on the same spans, the same metric is emitted twice and dashboards double-count traffic. Assign derivation to exactly one pipeline stage, and check the resulting series in the metrics backend for duplicate label sets after each configuration change.

Agent or gateway placement for span metrics

An agent runs beside each service, usually as a Collector on the same host, node or pod. When the span metrics connector runs here, each agent sees the spans its local services emit, so it can compute request, error and duration metrics before any sampling decision is made. The trade-off is completeness: a single agent only sees part of a distributed trace, so it cannot judge a whole request. That is acceptable for metrics derived from individual spans, because each span carries its own status and duration.

  • Local completeness: Each agent handles only the spans from its workloads, so derived metrics are correct per service but the agent cannot correlate spans across services.
  • Memory spread: Connector state is spread across many small processes, which keeps each footprint modest but multiplies the number of instances to size and monitor.
  • Metric series per instance: Each agent exports its own series, so the backend must merge them correctly, and attribute sets must stay identical across agents.
  • Upgrade surface: Agent configuration changes must reach every host or node, which raises the cost of version drift.
  • Failure isolation: A crashing agent affects only its host, but its unflushed metrics are lost with it.

Confirm that the connector configuration is identical across agents and that the metrics backend accepts the exporter your agents use.

Security and operational considerations for span metrics

The span metrics connector sits inside the Collector and sees every span, so the pipeline that produces these metrics carries the same security exposure as the telemetry it handles. The cards below cover how to lock down the Collector, protect its endpoints, keep sensitive attributes out of metric labels and verify what you deploy.

Store Collector configuration securely

The Collector configuration defines which pipelines exist, where data goes and which credentials it uses. Treat it as a sensitive artifact: keep it in version control with restricted access, inject secrets at runtime rather than writing them into files, and review changes to connector wiring as carefully as application code. A change that routes spans through the span metrics connector can alter what dashboards show, so require review before it ships.

Collector security practices

Authenticate receivers and exporters

Span data reaching the connector arrives through receivers, and the metrics it produces leave through exporters. Use authenticator extensions such as OIDC on receivers so only known services can send spans, and the oauth2client extension on exporters so outgoing requests carry credentials. Confirm which authenticators each receiver and exporter supports in the component README, because stability differs across components.

Encrypt every Collector endpoint

Span traffic often includes internal hostnames, user identifiers and request paths, so it should not cross networks in plain text. Enable TLS on OTLP receivers and exporters, restrict which networks can reach the Collector, and confirm certificate rotation is part of your operations plan. Ask your platform team which network segments carry span traffic and whether any cross a trust boundary.

Build only the components you need

The contrib distribution includes many receivers, processors and connectors. Build a custom Collector with the Collector Builder so that only the span metrics connector and the components in your pipelines are present. A smaller binary has less code to audit and fewer components to patch. Record the component list for each build so that security reviewers can match it to what is running.

Keep sensitive attributes out of metric labels

Span attributes can carry user identifiers, tokens in query strings or customer names. The connector turns selected attributes into metric dimensions, which then reach the metrics back end and persist there, often longer than traces are retained. Use the redaction processor before the connector to remove sensitive attributes, and limit dimensions to a short allowlist such as service name, route and status code. Confirm with your privacy team which attributes are regulated.

Questions teams ask before generating metrics from traces

What does it cost to generate metrics from traces with the span metrics connector?

The cost has two parts: the engineering work to design and build the pipeline, and the recurring cost of running it and storing the derived series. No supplied price applies, so DeployOpen does not quote a figure here; a written scope sets the fee. On the engineering side, the main drivers are how many services emit spans, how many span attributes you want to keep as metric dimensions, and how many back ends receive the output. On the running side, the derived metrics are time series, so the number of unique label combinations drives storage and query cost in your metrics back end. Ask for a quote that separates one-time build work from ongoing support, upgrades and testing, and that states which back end and attribute list it assumes.

How long does a first setup of the span metrics connector take?

Duration depends mainly on scope: how many services and clusters are involved, how consistent span naming and attributes are, and how many dashboards and alerts must be rebuilt on the derived metrics. A single collector pipeline feeding one back end is a much smaller job than a multi-cluster rollout across several teams. No supplied timeline applies to this work, so ask for a duration in the written scope, with the phases listed: design, pipeline build, validation against raw traffic, and dashboard cutover. Engagements are typically fixed scope, so the agreed timeline should follow directly from the scope document rather than from an open-ended estimate.

What must our team provide before the connector work starts?

Three inputs shape the design. First, trace topology: which services emit spans, which call each other, and where the collector sits as an agent or gateway. Second, an attribute inventory: the span attributes you want as metric dimensions, and the ones that must stay out because they create high cardinality, such as user IDs or full URLs. Third, back-end details: which metrics store receives the data, its authentication method, its retention and its query limits. Also provide the dashboards and alerts that depend on current metrics, so the team can check that derived values match them. Collector configuration is held to the security practices in OpenTelemetry's guidance, so ask how secrets and endpoints will be handled before any access is granted.

Can our own platform team build the span metrics pipeline without a partner?

Yes, a capable platform team can build it, provided it has experience running the OpenTelemetry Collector and owns the trace pipeline end to end. The OpenTelemetry Collector is Apache-2.0 licensed and vendor-agnostic, so there is no license cost for the component itself. The harder work is consistent instrumentation, attribute governance and validation, which takes time from engineers who already carry production duties. Partner help usually makes sense when the team lacks Collector experience, when many services must be onboarded at once, or when the metrics feed compliance or alerting that cannot tolerate gaps. Decide by comparing those needs with your team's capacity.

How does the span metrics connector work with tail sampling?

The connector sits in the pipeline so it can see spans before sampling discards them, which is what keeps request rate, error and duration figures accurate while most traces are dropped. The order matters. If tail sampling runs first, the connector only sees the retained traces and the derived metrics will undercount. Placing the connector ahead of the sampling step, and sending the raw span stream to it, preserves full coverage for the metrics. Confirm the exact ordering and the connector's current behavior against the component documentation for your collector version, because component stability varies and is documented per component. Test the order in a staging pipeline before changing production routing.

How do we check that derived metrics match raw traffic?

Compare the derived series against an independent count of the same traffic over the same window. Practical checks include: request counts per service and route from the connector versus counts from your load balancer or application logs; error rates from the derived metric versus the status codes in raw spans before any sampling; and latency percentiles from the histogram versus a sample of full traces. Run the comparison during normal load and during a deliberate error spike. Record the tolerance you accept, because histogram buckets and label filtering can cause small, explainable differences. Keep the check running after go-live, since a later attribute change can silently alter the numbers.

How DeployOpen scopes and delivers span metrics

DeployOpen plans, implements, tests and documents self-hosted OpenTelemetry Collector pipelines inside your own infrastructure, including the span metrics connector configuration that derives request, error and duration metrics from spans. The work runs in your cloud accounts, data centers or air-gapped networks, so the Collector, its configuration and the metrics it produces never leave your control. Most engagements are fixed-scope, and the scope is agreed in writing before work starts. That written scope names the services and pipelines in scope, the trace sources and sampling points the connector will read from, the metric names and dimensions, the back ends that will receive the output, and the deliverables and timelines.

A quote follows from that written scope rather than from a generic template. To get a comparable quote from any partner, ask for the list of pipelines and services included, the expected number of spans reaching the connector before sampling, the dimensions you want on each metric, and who signs off on the dashboard comparison. Ask also whether testing covers a side-by-side check of derived metrics against existing dashboards, and how the handover documentation records connector settings such as dimensions, histogram buckets and the metrics_flush_interval. Confirm these exact settings and their current behavior against the connector README in the release your Collector uses, since component stability differs across the Collector distribution.

Ongoing support is available as a retainer for teams that want help after go-live. A retainer typically covers upgrades to newer Collector releases, review of metric dimensions as services change, and retesting when sampling policies change upstream. Ask any partner to state in writing what the retainer includes, how changes are requested, and how upgrades are tested before they reach production. DeployOpen does not hold vendor partnership status for OpenTelemetry, and it does not publish a price list, so the written scope and the retainer terms are the documents to compare.

Sources and further reading

Talk to our team.

Tell us what you're working on, whether it's a deployment, an audit, a security test or a cyber range. You'll speak with an engineer who can help you scope it.

  • 30-minute call: free, with no obligation.
  • NDA on request: we can sign before you share details.
  • Clear next steps: a scope and plan after the call.