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 {
142139func (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
152149func (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
162159func (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
172169func (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
505460func intFromAttribute (val pcommon.Value ) (int , error ) {
506461 switch val .Type () {
0 commit comments