Skip to content

Commit f608be1

Browse files
authored
[k8sattributes] Disable otelcol.k8s.pod.association metric until pod_identifier attribute is properly calculated (#47798)
<!--Ex. Fixing a bug - Describe the bug and how this fixes the issue. Ex. Adding a feature - Explain what this achieves.--> #### Description Disabling the `otelcol.k8s.pod.association` for now until we can properly provide the `pod_identifier` attribute without causing high cardinality as explained by #47669 (comment). The metric was recently introduced and is still in development hence we can revert its usage temporarily until we have a proper fix. Signed-off-by: ChrsMark <chrismarkou92@gmail.com>
1 parent ce69d07 commit f608be1

3 files changed

Lines changed: 39 additions & 50 deletions

File tree

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
# Use this changelog template to create an entry for release notes.
2+
3+
# One of 'breaking', 'deprecation', 'new_component', 'enhancement', 'bug_fix'
4+
change_type: breaking
5+
6+
# The name of the component, or a single word describing the area of concern, (e.g. receiver/filelog)
7+
component: processor/k8s_attributes
8+
9+
# A brief description of the change. Surround your text with quotes ("") if it needs to start with a backtick (`).
10+
note: Disable otelcol.k8s.pod.association metric until pod_identifier attribute is properly calculated
11+
12+
# Mandatory: One or more tracking issues related to the change. You can use the PR number here if no issue exists.
13+
issues: [47669]
14+
15+
# (Optional) One or more lines of additional information to render under the primary note.
16+
# These lines will be padded with 2 spaces and then inserted directly into the document.
17+
# Use pipe (|) for multiline entries.
18+
subtext:
19+
20+
# If your change doesn't affect end users or the exported elements of any package,
21+
# you should instead start your pull request title with [chore] or use the "Skip Changelog" label.
22+
# Optional: The change log or logs in which this entry should be included.
23+
# e.g. '[user]' or '[user, api]'
24+
# Include 'user' if the change is relevant to end users.
25+
# Include 'api' if there is a change to a library API.
26+
# Default: '[user]'
27+
change_logs: []

processor/k8sattributesprocessor/metadata.yaml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -203,6 +203,13 @@ attributes:
203203

204204
telemetry:
205205
metrics:
206+
# The metric is not in use currently.
207+
# It can be used once pod_identifier attribute is properly calculated
208+
# ensuring that it doesn't cause high cardinality issues.
209+
# If each unique value of pod_identifier creates a new metric time series,
210+
# memory grows proportionally to the number of distinct pods seen over the collector's lifetime
211+
# impacting the component's performance.
212+
# See https://github.com/open-telemetry/opentelemetry-collector-contrib/issues/47669
206213
k8s.pod.association:
207214
prefix: otelcol.
208215
enabled: false

processor/k8sattributesprocessor/processor.go

Lines changed: 5 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@ import (
88
"errors"
99
"fmt"
1010
"strconv"
11-
"strings"
1211
"time"
1312

1413
"go.opentelemetry.io/collector/component"
@@ -18,8 +17,6 @@ import (
1817
"go.opentelemetry.io/collector/pdata/pmetric"
1918
"go.opentelemetry.io/collector/pdata/pprofile"
2019
"go.opentelemetry.io/collector/pdata/ptrace"
21-
"go.opentelemetry.io/otel/attribute"
22-
"go.opentelemetry.io/otel/metric"
2320
conventions "go.opentelemetry.io/otel/semconv/v1.40.0"
2421
"go.uber.org/zap"
2522

@@ -142,7 +139,7 @@ func (kp *kubernetesprocessor) Shutdown(context.Context) error {
142139
func (kp *kubernetesprocessor) processTraces(ctx context.Context, td ptrace.Traces) (ptrace.Traces, error) {
143140
rss := td.ResourceSpans()
144141
for i := 0; i < rss.Len(); i++ {
145-
kp.processResource(ctx, rss.At(i).Resource(), "traces")
142+
kp.processResource(ctx, rss.At(i).Resource())
146143
}
147144

148145
return td, nil
@@ -152,7 +149,7 @@ func (kp *kubernetesprocessor) processTraces(ctx context.Context, td ptrace.Trac
152149
func (kp *kubernetesprocessor) processMetrics(ctx context.Context, md pmetric.Metrics) (pmetric.Metrics, error) {
153150
rm := md.ResourceMetrics()
154151
for i := 0; i < rm.Len(); i++ {
155-
kp.processResource(ctx, rm.At(i).Resource(), "metrics")
152+
kp.processResource(ctx, rm.At(i).Resource())
156153
}
157154

158155
return md, nil
@@ -162,7 +159,7 @@ func (kp *kubernetesprocessor) processMetrics(ctx context.Context, md pmetric.Me
162159
func (kp *kubernetesprocessor) processLogs(ctx context.Context, ld plog.Logs) (plog.Logs, error) {
163160
rl := ld.ResourceLogs()
164161
for i := 0; i < rl.Len(); i++ {
165-
kp.processResource(ctx, rl.At(i).Resource(), "logs")
162+
kp.processResource(ctx, rl.At(i).Resource())
166163
}
167164

168165
return ld, nil
@@ -172,14 +169,14 @@ func (kp *kubernetesprocessor) processLogs(ctx context.Context, ld plog.Logs) (p
172169
func (kp *kubernetesprocessor) processProfiles(ctx context.Context, pd pprofile.Profiles) (pprofile.Profiles, error) {
173170
rp := pd.ResourceProfiles()
174171
for i := 0; i < rp.Len(); i++ {
175-
kp.processResource(ctx, rp.At(i).Resource(), "profiles")
172+
kp.processResource(ctx, rp.At(i).Resource())
176173
}
177174

178175
return pd, nil
179176
}
180177

181178
// processResource adds Pod metadata tags to resource based on pod association configuration
182-
func (kp *kubernetesprocessor) processResource(ctx context.Context, resource pcommon.Resource, signalType string) {
179+
func (kp *kubernetesprocessor) processResource(ctx context.Context, resource pcommon.Resource) {
183180
podIdentifierValue := extractPodID(ctx, resource.Attributes(), kp.podAssociations)
184181
kp.logger.Debug("evaluating pod identifier", zap.Any("value", podIdentifierValue))
185182

@@ -197,48 +194,20 @@ func (kp *kubernetesprocessor) processResource(ctx context.Context, resource pco
197194

198195
var pod *kube.Pod
199196
var podFound bool
200-
podIdentifierStr := buildPodIdentifierString(podIdentifierValue)
201197
if podIdentifierValue.IsNotEmpty() {
202198
if pod, podFound = kp.kc.GetPod(podIdentifierValue); podFound {
203199
kp.logger.Debug("getting the pod", zap.Any("pod", pod))
204-
205-
// Record successful pod association
206-
if kp.telemetry != nil {
207-
successAttr := metric.WithAttributes(
208-
attribute.String("status", "success"),
209-
attribute.String("pod_identifier", podIdentifierStr),
210-
attribute.String("otelcol.signal", signalType),
211-
)
212-
kp.telemetry.K8sPodAssociation.Add(ctx, 1, successAttr)
213-
}
214-
215200
for key, val := range pod.Attributes {
216201
setResourceAttribute(resource.Attributes(), key, val)
217202
}
218203
kp.addContainerAttributes(resource.Attributes(), pod)
219204
} else {
220205
// Record failed pod association
221206
kp.logger.Debug("pod not found", zap.Any("podIdentifier", podIdentifierValue))
222-
if kp.telemetry != nil {
223-
errorAttr := metric.WithAttributes(
224-
attribute.String("status", "error"),
225-
attribute.String("pod_identifier", podIdentifierStr),
226-
attribute.String("otelcol.signal", signalType),
227-
)
228-
kp.telemetry.K8sPodAssociation.Add(ctx, 1, errorAttr)
229-
}
230207
}
231208
} else {
232209
// Record failed pod association when no identifier found
233210
kp.logger.Debug("no pod identifier found")
234-
if kp.telemetry != nil {
235-
errorAttr := metric.WithAttributes(
236-
attribute.String("status", "error"),
237-
attribute.String("pod_identifier", podIdentifierStr),
238-
attribute.String("otelcol.signal", signalType),
239-
)
240-
kp.telemetry.K8sPodAssociation.Add(ctx, 1, errorAttr)
241-
}
242211
}
243212

244213
namespace := getNamespace(pod, resource.Attributes())
@@ -487,20 +456,6 @@ func (kp *kubernetesprocessor) getUIDForPodsNode(nodeName string) string {
487456
return node.NodeUID
488457
}
489458

490-
// buildPodIdentifierString combines all identifier values into a comma-separated string
491-
func buildPodIdentifierString(podIdentifierValue kube.PodIdentifier) string {
492-
var identifiers []string
493-
for i := range podIdentifierValue {
494-
if podIdentifierValue[i].Value != "" {
495-
identifiers = append(identifiers, podIdentifierValue[i].Value)
496-
}
497-
}
498-
if len(identifiers) > 0 {
499-
return strings.Join(identifiers, ",")
500-
}
501-
return "unknown"
502-
}
503-
504459
// intFromAttribute extracts int value from an attribute stored as string or int
505460
func intFromAttribute(val pcommon.Value) (int, error) {
506461
switch val.Type() {

0 commit comments

Comments
 (0)