Skip to content

Commit 30f716e

Browse files
authored
Fix issue with traces getting agent's k8s.pod.uid (#88)
Fix issue with traces getting agent's k8s.pod.uid In change 3c312b6 we added some globally set resource attributes like k8s.pod.uid. The problem is these attributes would get set before k8s_tagger was run so you would get traces with the k8s.pod.uid of the agent itself instead of the pod the trace came from. Instead add a separate metrics pipeline that adds the agent k8s metadata only to prometheus metrics. * Remove usage of OTEL_RESOURCE_ATTRIBUTES in favor of processors (user can still set it) * Use insert for resource attribute updates to prevent overriding upstream values and consistency
1 parent 4fd9b41 commit 30f716e

File tree

3 files changed

+50
-16
lines changed

3 files changed

+50
-16
lines changed

helm-charts/splunk-otel-collector/Chart.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
apiVersion: v2
22
name: splunk-otel-collector
3-
version: 0.24.2
3+
version: 0.24.3
44
description: Splunk OpenTelemetry Connector for Kubernetes
55
type: application
66
keywords:

helm-charts/splunk-otel-collector/templates/config/_otel-agent.tpl

Lines changed: 49 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ extensions:
1515
receivers:
1616
{{- include "splunk-otel-collector.otelTraceReceivers" . | nindent 2 }}
1717
# Prometheus receiver scraping metrics from the pod itself
18-
prometheus:
18+
prometheus/agent:
1919
config:
2020
scrape_configs:
2121
- job_name: 'otel-agent'
@@ -114,23 +114,43 @@ processors:
114114
timeout: 200ms
115115
send_batch_size: 128
116116

117-
resource/add_cluster_name:
117+
resource:
118+
# General resource attributes that apply to all telemetry passing through the agent.
118119
attributes:
119-
- action: upsert
120-
value: {{ .Values.clusterName }}
120+
- action: insert
121+
key: host.name
122+
value: "${K8S_NODE_NAME}"
123+
- action: insert
124+
key: k8s.node.name
125+
value: "${K8S_NODE_NAME}"
126+
- action: insert
121127
key: k8s.cluster.name
128+
value: "{{ .Values.clusterName }}"
122129
{{- range .Values.extraAttributes.custom }}
123-
- action: upsert
124-
value: {{ .value }}
125-
key: {{ .name }}
130+
- action: insert
131+
key: "{{ .name }}"
132+
value: "{{ .value }}"
126133
{{- end }}
127134

135+
# Resource attributes specific to the agent itself.
136+
resource/add_agent_k8s:
137+
attributes:
138+
- action: insert
139+
key: k8s.pod.name
140+
value: "${K8S_POD_NAME}"
141+
- action: insert
142+
key: k8s.pod.uid
143+
value: "${K8S_POD_UID}"
144+
- action: insert
145+
key: k8s.namespace.name
146+
value: "${K8S_NAMESPACE}"
147+
128148
{{- if .Values.environment }}
129149
resource/add_environment:
130150
attributes:
131151
- action: insert
132-
value: {{ .Values.environment }}
133152
key: deployment.environment
153+
value: "{{ .Values.environment }}"
134154
{{- end }}
135155

136156
# By default only SAPM exporter enabled. It will be pointed to collector deployment if enabled,
@@ -168,9 +188,9 @@ service:
168188
receivers: [otlp, jaeger, zipkin]
169189
processors:
170190
- memory_limiter
191+
- resource
171192
- resourcedetection
172193
- k8s_tagger
173-
- resource/add_cluster_name
174194
{{- if .Values.environment }}
175195
- resource/add_environment
176196
{{- end }}
@@ -185,8 +205,26 @@ service:
185205

186206
# default metrics pipeline
187207
metrics:
188-
receivers: [hostmetrics, prometheus, kubeletstats, receiver_creator]
189-
processors: [memory_limiter, resource/add_cluster_name, resourcedetection]
208+
receivers: [hostmetrics, kubeletstats, receiver_creator]
209+
processors:
210+
- memory_limiter
211+
- resource
212+
- resourcedetection
213+
exporters:
214+
{{- if .Values.otelCollector.enabled }}
215+
- otlp
216+
{{- else }}
217+
- signalfx
218+
{{- end }}
219+
220+
# Pipeline for metrics collected about the agent pod itself.
221+
metrics/agent:
222+
receivers: [prometheus/agent]
223+
processors:
224+
- memory_limiter
225+
- resource
226+
- resource/add_agent_k8s
227+
- resourcedetection
190228
exporters:
191229
{{- if .Values.otelCollector.enabled }}
192230
- otlp

helm-charts/splunk-otel-collector/templates/daemonset.yaml

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -152,10 +152,6 @@ spec:
152152
value: /hostfs/run
153153
- name: HOST_DEV
154154
value: /hostfs/dev
155-
156-
# Host specific resource attributes
157-
- name: OTEL_RESOURCE_ATTRIBUTES
158-
value: host.name=$(K8S_NODE_NAME),k8s.node.name=$(K8S_NODE_NAME),k8s.pod.name=$(K8S_POD_NAME),k8s.pod.uid=$(K8S_POD_UID),k8s.namespace.name=$(K8S_NAMESPACE)
159155
{{- end }}
160156

161157
readinessProbe:

0 commit comments

Comments
 (0)