Skip to content

Commit e18dd82

Browse files
feat: add configurable values for RED metric dimensions (#421)
1 parent 9f5efbf commit e18dd82

File tree

5 files changed

+26
-14
lines changed

5 files changed

+26
-14
lines changed

charts/agent/Chart.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ apiVersion: v2
22
name: agent
33
description: Chart to install K8s collection stack based on Observe Agent
44
type: application
5-
version: 0.70.3
5+
version: 0.71.0
66
appVersion: "2.8.1"
77
dependencies:
88
- name: opentelemetry-collector

charts/agent/README.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# agent
22

3-
![Version: 0.70.3](https://img.shields.io/badge/Version-0.70.3-informational?style=flat-square) ![Type: application](https://img.shields.io/badge/Type-application-informational?style=flat-square) ![AppVersion: 2.8.1](https://img.shields.io/badge/AppVersion-2.8.1-informational?style=flat-square)
3+
![Version: 0.71.0](https://img.shields.io/badge/Version-0.71.0-informational?style=flat-square) ![Type: application](https://img.shields.io/badge/Type-application-informational?style=flat-square) ![AppVersion: 2.8.1](https://img.shields.io/badge/AppVersion-2.8.1-informational?style=flat-square)
44

55
Chart to install K8s collection stack based on Observe Agent
66

@@ -76,6 +76,8 @@ This service is a *single-instance deployment*. It's critical that this service
7676
| agent.selfMonitor.enabled | bool | `true` | |
7777
| agent.selfMonitor.metrics.scrapeInterval | string | `"60s"` | |
7878
| application.REDMetrics.enabled | bool | `false` | Whether to enable generating RED metrics from spans. See https://github.com/open-telemetry/opentelemetry-collector-contrib/tree/main/connector/spanmetricsconnector#overview |
79+
| application.REDMetrics.resourceDimensions | list | `["service.namespace","service.version","deployment.environment","k8s.pod.name","k8s.namespace.name"]` | List of resource attributes to include as dimensions for RED metrics. See https://github.com/open-telemetry/opentelemetry-collector-contrib/tree/main/connector/spanmetricsconnector#overview |
80+
| application.REDMetrics.spanDimensions | list | `["peer.db.name","peer.messaging.system","otel.status_description","observe.status_code"]` | List of span attributes to include as dimensions for RED metrics. See https://github.com/open-telemetry/opentelemetry-collector-contrib/tree/main/connector/spanmetricsconnector#overview |
7981
| application.prometheusScrape.enabled | bool | `false` | |
8082
| application.prometheusScrape.independentDeployment | bool | `false` | |
8183
| application.prometheusScrape.interval | string | `"60s"` | |
Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
{{- define "config.connectors.spanmetrics" -}}
2-
{{/* Note: this must be kept in sync with the same variable in config.processors.RED_metrics */}}
3-
{{- $spanmetricsResourceAttributes := (list "service.namespace" "service.version" "deployment.environment" "k8s.pod.name" "k8s.namespace.name") -}}
2+
3+
{{- $fullDimensions := (concat .Values.application.REDMetrics.resourceDimensions .Values.application.REDMetrics.spanDimensions) -}}
4+
{{/* service.name is added automatically by the connector and errors when specified in the config */}}
5+
{{- $fullDimensions = (without $fullDimensions "service.name" | uniq) -}}
46

57
spanmetrics:
68
aggregation_temporality: AGGREGATION_TEMPORALITY_DELTA
@@ -10,11 +12,7 @@ spanmetrics:
1012
dimensions:
1113
# This connector implicitly adds: service.name, span.name, span.kind, and status.code (which we rename to otel.status_code)
1214
# https://github.com/open-telemetry/opentelemetry-collector-contrib/blob/main/connector/spanmetricsconnector/connector.go#L528-L540
13-
{{- range $tag := $spanmetricsResourceAttributes }}
15+
{{- range $tag := $fullDimensions }}
1416
- name: {{ $tag }}
1517
{{- end }}
16-
- name: peer.db.name
17-
- name: peer.messaging.system
18-
- name: otel.status_description
19-
- name: observe.status_code
2018
{{- end -}}

charts/agent/templates/_config-processors.tpl

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -166,8 +166,6 @@ transform/add_span_status_code:
166166
{{- end -}}
167167

168168
{{- define "config.processors.RED_metrics" -}}
169-
{{/* Note: this must be kept in sync with the same variable in config.connectors.spanmetrics */}}
170-
{{- $spanmetricsResourceAttributes := (list "service.namespace" "service.version" "deployment.environment" "k8s.pod.name" "k8s.namespace.name") -}}
171169

172170
attributes/debug_source_span_metrics:
173171
actions:
@@ -220,16 +218,17 @@ filter/drop_span_kinds_other_than_server_and_consumer_and_peer_client:
220218
- span.kind == SPAN_KIND_PRODUCER
221219
{{- end }}
222220

221+
{{- $resourceDims := (prepend .Values.application.REDMetrics.resourceDimensions "service.name" | uniq) }}
222+
223223
# The spanmetrics connector puts all dimensions as attributes on the datapoint, and copies the resource attributes from an arbitrary span's resource. This cleans that up as well as handling any other renaming.
224224
transform/fix_red_metrics_resource_attributes:
225225
error_mode: ignore
226226
metric_statements:
227227
# Drop all resource attributes that aren't dimensions in the spanmetrics connector.
228-
{{/* The service.name is implicit in the spanmetrics connector, so we can't include it in spanmetricsResourceAttributes and need to list it here. */}}
229-
- keep_matching_keys(resource.attributes, "^(service.name|{{ join "|" $spanmetricsResourceAttributes }})")
228+
- keep_matching_keys(resource.attributes, "^({{ join "|" $resourceDims }})")
230229

231230
# Drop all datapoint attributes that are resource attributes in the spans.
232-
- delete_matching_keys(datapoint.attributes, "^(service.name|{{ join "|" $spanmetricsResourceAttributes }})")
231+
- delete_matching_keys(datapoint.attributes, "^({{ join "|" $resourceDims }})")
233232

234233
# Rename status.code to response_status to be consistent with Trace Explorer and disambiguate from status_code (with an underscore).
235234
- set(datapoint.attributes["otel.status_code"], "OK") where datapoint.attributes["status.code"] == "STATUS_CODE_OK"

charts/agent/values.yaml

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -137,6 +137,19 @@ application:
137137
REDMetrics:
138138
# -- (bool) Whether to enable generating RED metrics from spans. See https://github.com/open-telemetry/opentelemetry-collector-contrib/tree/main/connector/spanmetricsconnector#overview
139139
enabled: false
140+
# -- (list) List of resource attributes to include as dimensions for RED metrics. See https://github.com/open-telemetry/opentelemetry-collector-contrib/tree/main/connector/spanmetricsconnector#overview
141+
resourceDimensions:
142+
- service.namespace
143+
- service.version
144+
- deployment.environment
145+
- k8s.pod.name
146+
- k8s.namespace.name
147+
# -- (list) List of span attributes to include as dimensions for RED metrics. See https://github.com/open-telemetry/opentelemetry-collector-contrib/tree/main/connector/spanmetricsconnector#overview
148+
spanDimensions:
149+
- peer.db.name
150+
- peer.messaging.system
151+
- otel.status_description
152+
- observe.status_code
140153

141154
gatewayDeployment:
142155
# -- (bool) Whether to enable the gateway deployment. The gateway is responsible for sampling and traces before sending them to Observe.

0 commit comments

Comments
 (0)