Skip to main content

Count Connector

Status Available in: contrib, k8s Maintainers: @akats7 Source: opentelemetry-collector-contrib

Overview

The count connector can be used to count spans, span events, metrics, data points, and log records.

Configuration

If you are not already familiar with connectors, you may find it helpful to first visit the Connectors README.

Default Configuration

The count connector may be used without any configuration settings. The following table describes the default behavior of the connector. For example, in the following configuration the connector will count spans and span events from the traces/in pipeline and emit metrics called trace.span.count and trace.span.event.count onto the metrics/out pipeline.

Custom Counts

Optionally, emit custom counts by defining metrics under one or more of the following sections:
  • spans
  • spanevents
  • metrics
  • datapoints
  • logs
Optionally, specify a description for the metric. Note: If any custom metrics are defined for a data type, the default metric will not be emitted.

Conditions

Conditions may be specified for custom metrics. If specified, data that matches any one of the conditions will be counted. i.e. Conditions are ORed together.

Attributes

spans, spanevents, datapoints, and logs may be counted according to attributes. In such cases, attribute precedence follows this order: span(logRecord, DataPoint, profile) attributes > scope attributes > resource attributes. If attributes are specified for custom metrics, a separate count will be generated for each unique set of attribute values. Each count will be emitted as a data point on the same metric. Optionally, include a default_value for an attribute, to count data that does not contain the attribute. The default_value value can be of type string, integer, or float.

Example Usage

Count spans and span events, only exporting the count metrics.
Count spans and span events, exporting both the original traces and the count metrics.
Count spans, span events, metrics, data points, and log records, exporting count metrics to a separate backend.
Count logs with a severity of ERROR or higher.
Count logs with a severity of ERROR or higher. Maintain a separate count for each environment.
Count all spans and span events (default behavior). Count metrics and data points based on the env attribute.

Configuration

Example Configuration


Last generated: 2026-08-24