Skip to content

Metrics

A metric is a stream of measurements with a name, such as http.server.request.duration. Each distinct set of attribute values is a series. For example, http.route=/orders and http.route=/cart are two series of one metric. The SDK combines measurements in memory and exports them once per interval. Each series sends one value per interval, however many measurements it received.

Metrics › Captured lists what each service records, with each metric’s kind, series and attribute keys.

A metric’s kind decides how its measurements combine.

A total that only goes up, such as requests served. Each measurement adds to it, and each interval exports the total so far. Graph its rate.

A total that goes down as well as up, such as open connections or queued jobs. Each measurement adds or takes away.

A reading taken now and then, such as CPU or memory use. Readings aren’t added together. Each interval exports only the latest one.

A distribution, such as request durations. Each value is counted in the bucket it falls into. The count, sum, min and max are kept alongside, so you can estimate percentiles.

A View reshapes a service’s metrics before they’re exported. A View matches metrics by name and scope (with * and ? globs), kind, and unit, then changes them. You set Views per service or as project defaults, and switch them on per environment. A View’s name is optional. An unnamed View uses a title based on what it does, such as v8js.gc.*: drop.

Views apply in order: a service’s Views come before the project’s. Each setting comes from the first matching View that sets it. A service View can therefore override one part of a project View and inherit the rest. If any matching View drops a metric, the metric is dropped.

Sends nothing for matching metrics.

Keep only the listed keys, or Drop them. Series that differ only in removed keys merge into one, and their values combine. Dropping keys is the main way to cut series. For example, a user.id on a request counter creates a series per user.

Rewrites an attribute’s values, so fewer distinct values and fewer series are sent. Series that end up with the same values merge.

  • Status class turns a status code into its class: 404 → 4xx.
  • Replace rewrites values with a regex. For example, it can turn IDs in a path: /users/\d+ → /users/:id.
  • Allow list keeps the listed values and turns any other into one catch-all, _OTHER unless you name another.

Attributes and value mappings merge series. For counters, up-down counters and histograms that the app records directly, a merged series combines the measurements. Observable instruments work differently. They report one value per series each time they’re collected. By default, a merged series keeps just one of those values.

Sum merged series makes a merged series report the total of its values. For example, v8js.memory.heap.space.available_size reports one gauge per heap space. If you drop v8js.heap.space.name with this on, you get the total heap available. Without it, you get whichever space was read last.

Observable counters and up-down counters always sum. The setting matters only for observable gauges, where a total isn’t always meaningful. Per-core CPU use, for example, doesn’t add up to anything. To get one value you choose, use a filter instead.

A filter sends only the measurements whose attribute has one of the values you list, and discards the rest. A measurement without the attribute is also discarded. With several keys, a measurement must match each one. Filters run before every other setting, so a View can keep a few values and then sum them.

For example, to send only the old generation’s heap, filter v8js.heap.space.name to old_space, then drop v8js.heap.space.name.

On Metrics › Captured, an attribute’s Drop attribute menu has two choices:

  • Sum the values (Combine the values for a histogram) drops the attribute and merges its series. On a gauge, it also turns on Sum merged series, so it’s offered only for gauges the SDK reports as observable.
  • Keep only… filters the attribute to the values you pick. Keep one and the attribute is dropped too, so the metric has one series. Keep several and each keeps its own series. The same dialog has a checkbox, Sum the rest into one series (for a histogram, Combine the rest into one histogram). It keeps the values you pick and sends the others as one _OTHER series instead of discarding them. It uses an allow-list value mapping. On a gauge, it sums with Sum merged series, so the gauge must be observable.

Once a View drops an attribute, its row says how the values combine, such as “dropped by a View · values summed”.

Changes how measurements combine.

  • Explicit histogram counts values in buckets, with boundaries you choose.
  • Exponential histogram uses buckets whose bounds grow by powers of two. It rescales them to fit the values, up to a maximum count of 160 by default. You don’t choose boundaries.
  • Sum keeps only the running total.
  • Last value keeps only the latest value in each interval.

Caps the number of series a metric keeps. Once the cap is reached, every new combination of attributes goes into one series marked otel.metric.overflow=true. An unexpected high-cardinality attribute therefore can’t grow the metric without bound.

Exports the metric under a new name or description. To rename a metric, the View must match one exact name, with no * or ?.

A span metric is a counter or histogram built from spans. SpanSlice records it for every matching span as the span ends, or once per trace when the root span ends. It records before sampling and drop rules run, so it counts everything the service did, not just what was kept.

Record for Value Records
Each span Count 1 per matching span
Each span Duration the span’s duration, in ms
Each span Attribute value a numeric attribute; spans without it record none
Each trace Count of matching spans how many matching spans ended before the trace did
Each trace Trace duration the root span’s duration

Group by splits a span metric into series by attribute keys, or by span.name, span.kind and span.status. SpanSlice reads these from the span, or from the root span for a per-trace metric. Span metrics appear on Captured under the spanslice.span_metrics scope. Views can reshape them like any other metric.