From 88844c106c42697a9da2abc916f9961f41496bc4 Mon Sep 17 00:00:00 2001 From: Dmitry Date: Tue, 3 May 2022 22:28:18 -0700 Subject: [PATCH] Remove usages of deprecated Map.Delete method To resolve the latest core build issues in core --- internal/coreinternal/attraction/attraction.go | 2 +- pkg/translator/jaeger/jaegerproto_to_traces.go | 16 ++++++++-------- processor/groupbyattrsprocessor/processor.go | 2 +- 3 files changed, 10 insertions(+), 10 deletions(-) diff --git a/internal/coreinternal/attraction/attraction.go b/internal/coreinternal/attraction/attraction.go index b0941595f03f..31b79888325a 100644 --- a/internal/coreinternal/attraction/attraction.go +++ b/internal/coreinternal/attraction/attraction.go @@ -281,7 +281,7 @@ func (ap *AttrProc) Process(ctx context.Context, logger *zap.Logger, attrs pcomm // and could impact performance. switch action.Action { case DELETE: - attrs.Delete(action.Key) + attrs.Remove(action.Key) case INSERT: av, found := getSourceAttributeValue(ctx, action, attrs) if !found { diff --git a/pkg/translator/jaeger/jaegerproto_to_traces.go b/pkg/translator/jaeger/jaegerproto_to_traces.go index c272ec942ed6..97ca56f4ca38 100644 --- a/pkg/translator/jaeger/jaegerproto_to_traces.go +++ b/pkg/translator/jaeger/jaegerproto_to_traces.go @@ -107,7 +107,7 @@ func translateHostnameAttr(attrs pcommon.Map) { _, convHostNameFound := attrs.Get(conventions.AttributeHostName) if hostnameFound && !convHostNameFound { attrs.Insert(conventions.AttributeHostName, hostname) - attrs.Delete("hostname") + attrs.Remove("hostname") } } @@ -117,7 +117,7 @@ func translateJaegerVersionAttr(attrs pcommon.Map) { _, exporterVersionFound := attrs.Get(occonventions.AttributeExporterVersion) if jaegerVersionFound && !exporterVersionFound { attrs.InsertString(occonventions.AttributeExporterVersion, "Jaeger-"+jaegerVersion.StringVal()) - attrs.Delete("jaeger.version") + attrs.Remove("jaeger.version") } } @@ -163,7 +163,7 @@ func jSpanToInternal(span *model.Span, spansByLibrary map[instrumentationLibrary setInternalSpanStatus(attrs, dest.Status()) if spanKindAttr, ok := attrs.Get(tracetranslator.TagSpanKind); ok { dest.SetKind(jSpanKindToInternal(spanKindAttr.StringVal())) - attrs.Delete(tracetranslator.TagSpanKind) + attrs.Remove(tracetranslator.TagSpanKind) } dest.SetTraceState(getTraceStateFromAttrs(attrs)) @@ -204,7 +204,7 @@ func setInternalSpanStatus(attrs pcommon.Map, dest ptrace.SpanStatus) { if errorVal, ok := attrs.Get(tracetranslator.TagError); ok { if errorVal.BoolVal() { statusCode = ptrace.StatusCodeError - attrs.Delete(tracetranslator.TagError) + attrs.Remove(tracetranslator.TagError) statusExists = true if desc, ok := extractStatusDescFromAttr(attrs); ok { @@ -235,7 +235,7 @@ func setInternalSpanStatus(attrs pcommon.Map, dest ptrace.SpanStatus) { // Regardless of error tag value, remove the otel.status_code tag. The // otel.status_message tag will have already been removed if // statusExists is true. - attrs.Delete(conventions.OtelStatusCode) + attrs.Remove(conventions.OtelStatusCode) } else if httpCodeAttr, ok := attrs.Get(conventions.AttributeHTTPStatusCode); !statusExists && ok { // Fallback to introspecting if this span represents a failed HTTP // request or response, but again, only do so if the `error` tag was @@ -265,7 +265,7 @@ func setInternalSpanStatus(attrs pcommon.Map, dest ptrace.SpanStatus) { func extractStatusDescFromAttr(attrs pcommon.Map) (string, bool) { if msgAttr, ok := attrs.Get(conventions.OtelStatusDescription); ok { msg := msgAttr.StringVal() - attrs.Delete(conventions.OtelStatusDescription) + attrs.Remove(conventions.OtelStatusDescription) return msg, true } return "", false @@ -342,7 +342,7 @@ func jLogsToSpanEvents(logs []model.Log, dest ptrace.SpanEventSlice) { jTagsToInternalAttributes(log.Fields, attrs) if name, ok := attrs.Get(tracetranslator.TagMessage); ok { event.SetName(name.StringVal()) - attrs.Delete(tracetranslator.TagMessage) + attrs.Remove(tracetranslator.TagMessage) } } } @@ -370,7 +370,7 @@ func getTraceStateFromAttrs(attrs pcommon.Map) ptrace.TraceState { // TODO Bring this inline with solution for jaegertracing/jaeger-client-java #702 once available if attr, ok := attrs.Get(tracetranslator.TagW3CTraceState); ok { traceState = ptrace.TraceState(attr.StringVal()) - attrs.Delete(tracetranslator.TagW3CTraceState) + attrs.Remove(tracetranslator.TagW3CTraceState) } return traceState } diff --git a/processor/groupbyattrsprocessor/processor.go b/processor/groupbyattrsprocessor/processor.go index c819a7c661a4..95548a9b141f 100644 --- a/processor/groupbyattrsprocessor/processor.go +++ b/processor/groupbyattrsprocessor/processor.go @@ -177,7 +177,7 @@ func (gap *groupByAttrsProcessor) processMetrics(ctx context.Context, md pmetric func deleteAttributes(attrsForRemoval, targetAttrs pcommon.Map) { attrsForRemoval.Range(func(key string, _ pcommon.Value) bool { - targetAttrs.Delete(key) + targetAttrs.Remove(key) return true }) }