Skip to content

[service/internal/graph] Measure telemetry as it is passed between pipeline components #12812

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
May 12, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 32 additions & 0 deletions .chloggen/pipeline-component-metrics.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
# Use this changelog template to create an entry for release notes.

# One of 'breaking', 'deprecation', 'new_component', 'enhancement', 'bug_fix'
change_type: enhancement

# The name of the component, or a single word describing the area of concern, (e.g. otlpreceiver)
component: service

# A brief description of the change. Surround your text with quotes ("") if it needs to start with a backtick (`).
note: Add item count metrics defined in Pipeline Component Telemetry RFC

# One or more tracking issues or pull requests related to the change
issues: [12812]

# (Optional) One or more lines of additional information to render under the primary note.
# These lines will be padded with 2 spaces and then inserted directly into the document.
# Use pipe (|) for multiline entries.
subtext: |
See [Pipeline Component Telemetry RFC](https://github.com/open-telemetry/opentelemetry-collector/blob/main/docs/rfcs/component-universal-telemetry.md) for more details:
- `otelcol.receiver.produced.items`
- `otelcol.processor.consumed.items`
- `otelcol.processor.produced.items`
- `otelcol.connector.consumed.items`
- `otelcol.connector.produced.items`
- `otelcol.exporter.consumed.items`

# Optional: The change log or logs in which this entry should be included.
# e.g. '[user]' or '[user, api]'
# Include 'user' if the change is relevant to end users.
# Include 'api' if there is a change to a library API.
# Default: '[user]'
change_logs: []
3 changes: 3 additions & 0 deletions cmd/mdatagen/internal/metric.go
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,9 @@ type Metric struct {

// Attributes is the list of attributes that the metric emits.
Attributes []AttributeName `mapstructure:"attributes"`

// Override the default prefix for the metric name.
Prefix string `mapstructure:"prefix"`
}

type Stability struct {
Expand Down
2 changes: 1 addition & 1 deletion cmd/mdatagen/internal/templates/documentation.md.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@
{{- $metricName := . }}
{{- $metric := $metricName | telemetryInfo -}}

### otelcol_{{ $metricName }}
### {{ if $metric.Prefix -}}{{ $metric.Prefix }}{{- else -}}otelcol_{{- end -}}{{ $metricName }}

{{ $metric.Description }}{{ $metric.Stability }}

Expand Down
4 changes: 4 additions & 0 deletions cmd/mdatagen/internal/templates/telemetry.go.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,11 @@ func NewTelemetryBuilder(settings component.TelemetrySettings, options ...Teleme

{{- range $name, $metric := .Telemetry.Metrics }}
builder.{{ $name.Render }}, err = builder.meter.{{ $metric.Data.Instrument }}(
{{ if $metric.Prefix -}}
"{{ $metric.Prefix }}{{ $name }}",
{{ else -}}
"otelcol_{{ $name }}",
{{ end -}}
metric.WithDescription("{{ $metric.Description }}{{ $metric.Stability }}"),
metric.WithUnit("{{ $metric.Unit }}"),
{{ if eq $metric.Data.Type "Histogram" -}}
Expand Down
8 changes: 8 additions & 0 deletions cmd/mdatagen/internal/templates/telemetrytest.go.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,11 @@ return set

func AssertEqual{{ $name.Render }}(t *testing.T, tt *componenttest.Telemetry, dps []metricdata.{{- if eq $metric.Data.Type "Histogram" }} {{$metric.Data.Type}} {{- end }}DataPoint[{{ $metric.Data.BasicType }}], opts ...metricdatatest.Option) {
want := metricdata.Metrics{
{{ if $metric.Prefix -}}
Name: "{{ $metric.Prefix }}{{ $name }}",
{{ else -}}
Name: "otelcol_{{ $name }}",
{{ end -}}
Description: "{{ $metric.Description }}{{ $metric.Stability }}",
Unit: "{{ $metric.Unit }}",
Data: metricdata.{{ $metric.Data.Type }}[{{ $metric.Data.BasicType }}]{
Expand All @@ -45,7 +49,11 @@ func AssertEqual{{ $name.Render }}(t *testing.T, tt *componenttest.Telemetry, dp
DataPoints: dps,
},
}
{{ if $metric.Prefix -}}
got, err := tt.GetMetric("{{ $metric.Prefix }}{{ $name }}")
{{ else -}}
got, err := tt.GetMetric("otelcol_{{ $name }}")
{{ end -}}
require.NoError(t, err)
metricdatatest.AssertEqual(t, want, got, opts...)
}
Expand Down
48 changes: 48 additions & 0 deletions service/documentation.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,30 @@

The following telemetry is emitted by this component.

### otelcol.connector.consumed.items

Number of items passed to the connector.

| Unit | Metric Type | Value Type | Monotonic |
| ---- | ----------- | ---------- | --------- |
| {item} | Sum | Int | true |

### otelcol.connector.produced.items

Number of items emitted from the connector.

| Unit | Metric Type | Value Type | Monotonic |
| ---- | ----------- | ---------- | --------- |
| {item} | Sum | Int | true |

### otelcol.exporter.consumed.items

Number of items passed to the exporter.

| Unit | Metric Type | Value Type | Monotonic |
| ---- | ----------- | ---------- | --------- |
| {item} | Sum | Int | true |

### otelcol_process_cpu_seconds

Total CPU user and system time in seconds [alpha]
Expand Down Expand Up @@ -53,3 +77,27 @@ Uptime of the process [alpha]
| Unit | Metric Type | Value Type | Monotonic |
| ---- | ----------- | ---------- | --------- |
| s | Sum | Double | true |

### otelcol.processor.consumed.items

Number of items passed to the processor.

| Unit | Metric Type | Value Type | Monotonic |
| ---- | ----------- | ---------- | --------- |
| {item} | Sum | Int | true |

### otelcol.processor.produced.items

Number of items emitted from the processor.

| Unit | Metric Type | Value Type | Monotonic |
| ---- | ----------- | ---------- | --------- |
| {item} | Sum | Int | true |

### otelcol.receiver.produced.items

Number of items emitted from the receiver.

| Unit | Metric Type | Value Type | Monotonic |
| ---- | ----------- | ---------- | --------- |
| {item} | Sum | Int | true |
Loading
Loading