From 70959e8a2871b86d40922275264adda28ac07c5c Mon Sep 17 00:00:00 2001 From: Greg Kalapos Date: Tue, 14 Jan 2025 19:38:41 +0100 Subject: [PATCH 1/8] Add common module for reuse --- common/attributes.go | 58 ++++++++++++++++++++++++++++++++++++++++++++ common/go.mod | 3 +++ 2 files changed, 61 insertions(+) create mode 100644 common/attributes.go create mode 100644 common/go.mod diff --git a/common/attributes.go b/common/attributes.go new file mode 100644 index 0000000..51abdc1 --- /dev/null +++ b/common/attributes.go @@ -0,0 +1,58 @@ +// Licensed to Elasticsearch B.V. under one or more contributor +// license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright +// ownership. Elasticsearch B.V. licenses this file to you under +// the Apache License, Version 2.0 (the "License"); you may +// not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. + +package common + +const ( + // resource attributes + AttributeAgentName = "agent.name" + AttributeAgentVersion = "agent.version" + + // scope attributes + AttributeServiceFrameworkName = "service.framework.name" + AttributeServiceFrameworkVersion = "service.framework.version" + + // span attributes + AttributeTimestampUs = "timestamp.us" + AttributeProcessorEvent = "processor.event" + AttributeTransactionSampled = "transaction.sampled" + AttributeTransactionID = "transaction.id" + AttributeTransactionRoot = "transaction.root" + AttributeTransactionName = "transaction.name" + AttributeTransactionType = "transaction.type" + AttributeTransactionDurationUs = "transaction.duration.us" + AttributeTransactionResult = "transaction.result" + AttributeTransactionRepresentativeCount = "transaction.representative_count" + AttributeSpanName = "span.name" + AttributeSpanType = "span.type" + AttributeSpanSubtype = "span.subtype" + AttributeEventOutcome = "event.outcome" + AttributeSuccessCount = "event.success_count" + AttributeServiceTargetType = "service.target.type" + AttributeServiceTargetName = "service.target.name" + AttributeSpanDestinationServiceResource = "span.destination.service.resource" + AttributeSpanDurationUs = "span.duration.us" + AttributeSpanRepresentativeCount = "span.representative_count" + AttributeChildIDs = "child.id" + + // span event attributes + AttributeParentID = "parent.id" + AttributeErrorID = "error.id" + AttributeErrorExceptionHandled = "error.exception.handled" + AttributeErrorGroupingKey = "error.grouping_key" + AttributeErrorGroupingName = "error.grouping_name" +) diff --git a/common/go.mod b/common/go.mod new file mode 100644 index 0000000..5b049bb --- /dev/null +++ b/common/go.mod @@ -0,0 +1,3 @@ +module github.com/elastic/opentelemetry-lib/common + +go 1.22.7 From 6ee211c92b1510939b21e55eb0c21c2133541848 Mon Sep 17 00:00:00 2001 From: Greg Kalapos Date: Tue, 14 Jan 2025 20:19:52 +0100 Subject: [PATCH 2/8] Move attributes to common --- .../trace/internal/elastic/attributes.go | 58 -- .../trace/internal/elastic/resource.go | 6 +- .../trace/internal/elastic/resource_test.go | 45 +- enrichments/trace/internal/elastic/scope.go | 5 +- .../trace/internal/elastic/scope_test.go | 9 +- enrichments/trace/internal/elastic/span.go | 63 +- .../trace/internal/elastic/span_test.go | 715 +++++++++--------- go.mod | 1 + go.sum | 2 + 9 files changed, 428 insertions(+), 476 deletions(-) delete mode 100644 enrichments/trace/internal/elastic/attributes.go diff --git a/enrichments/trace/internal/elastic/attributes.go b/enrichments/trace/internal/elastic/attributes.go deleted file mode 100644 index 67d7353..0000000 --- a/enrichments/trace/internal/elastic/attributes.go +++ /dev/null @@ -1,58 +0,0 @@ -// Licensed to Elasticsearch B.V. under one or more contributor -// license agreements. See the NOTICE file distributed with -// this work for additional information regarding copyright -// ownership. Elasticsearch B.V. licenses this file to you under -// the Apache License, Version 2.0 (the "License"); you may -// not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, -// software distributed under the License is distributed on an -// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -// KIND, either express or implied. See the License for the -// specific language governing permissions and limitations -// under the License. - -package elastic - -const ( - // resource attributes - AttributeAgentName = "agent.name" - AttributeAgentVersion = "agent.version" - - // scope attributes - AttributeServiceFrameworkName = "service.framework.name" - AttributeServiceFrameworkVersion = "service.framework.version" - - // span attributes - AttributeTimestampUs = "timestamp.us" - AttributeProcessorEvent = "processor.event" - AttributeTransactionSampled = "transaction.sampled" - AttributeTransactionID = "transaction.id" - AttributeTransactionRoot = "transaction.root" - AttributeTransactionName = "transaction.name" - AttributeTransactionType = "transaction.type" - AttributeTransactionDurationUs = "transaction.duration.us" - AttributeTransactionResult = "transaction.result" - AttributeTransactionRepresentativeCount = "transaction.representative_count" - AttributeSpanName = "span.name" - AttributeSpanType = "span.type" - AttributeSpanSubtype = "span.subtype" - AttributeEventOutcome = "event.outcome" - AttributeSuccessCount = "event.success_count" - AttributeServiceTargetType = "service.target.type" - AttributeServiceTargetName = "service.target.name" - AttributeSpanDestinationServiceResource = "span.destination.service.resource" - AttributeSpanDurationUs = "span.duration.us" - AttributeSpanRepresentativeCount = "span.representative_count" - AttributeChildIDs = "child.id" - - // span event attributes - AttributeParentID = "parent.id" - AttributeErrorID = "error.id" - AttributeErrorExceptionHandled = "error.exception.handled" - AttributeErrorGroupingKey = "error.grouping_key" - AttributeErrorGroupingName = "error.grouping_name" -) diff --git a/enrichments/trace/internal/elastic/resource.go b/enrichments/trace/internal/elastic/resource.go index 031f636..8a19e8c 100644 --- a/enrichments/trace/internal/elastic/resource.go +++ b/enrichments/trace/internal/elastic/resource.go @@ -20,6 +20,7 @@ package elastic import ( "fmt" + "github.com/elastic/opentelemetry-lib/common" "github.com/elastic/opentelemetry-lib/enrichments/trace/config" "go.opentelemetry.io/collector/pdata/pcommon" semconv "go.opentelemetry.io/collector/semconv/v1.25.0" @@ -98,7 +99,8 @@ func (s *resourceEnrichmentContext) setAgentName(resource pcommon.Resource) { s.telemetrySDKLanguage, ) } - resource.Attributes().PutStr(AttributeAgentName, agentName) + + resource.Attributes().PutStr(common.AttributeAgentName, agentName) } func (s *resourceEnrichmentContext) setAgentVersion(resource pcommon.Resource) { @@ -113,7 +115,7 @@ func (s *resourceEnrichmentContext) setAgentVersion(resource pcommon.Resource) { case s.telemetrySDKVersion != "": agentVersion = s.telemetrySDKVersion } - resource.Attributes().PutStr(AttributeAgentVersion, agentVersion) + resource.Attributes().PutStr(common.AttributeAgentVersion, agentVersion) } func (s *resourceEnrichmentContext) overrideHostNameWithK8sNodeName(resource pcommon.Resource) { diff --git a/enrichments/trace/internal/elastic/resource_test.go b/enrichments/trace/internal/elastic/resource_test.go index 04eb20c..7dcdc8b 100644 --- a/enrichments/trace/internal/elastic/resource_test.go +++ b/enrichments/trace/internal/elastic/resource_test.go @@ -20,6 +20,7 @@ package elastic import ( "testing" + "github.com/elastic/opentelemetry-lib/common" "github.com/elastic/opentelemetry-lib/enrichments/trace/config" "github.com/google/go-cmp/cmp" "github.com/stretchr/testify/assert" @@ -44,8 +45,8 @@ func TestResourceEnrich(t *testing.T) { input: pcommon.NewResource(), config: config.Enabled().Resource, enrichedAttrs: map[string]any{ - AttributeAgentName: "otlp", - AttributeAgentVersion: "unknown", + common.AttributeAgentName: "otlp", + common.AttributeAgentVersion: "unknown", }, }, { @@ -57,8 +58,8 @@ func TestResourceEnrich(t *testing.T) { }(), config: config.Enabled().Resource, enrichedAttrs: map[string]any{ - AttributeAgentName: "customflavor", - AttributeAgentVersion: "unknown", + common.AttributeAgentName: "customflavor", + common.AttributeAgentVersion: "unknown", }, }, { @@ -71,8 +72,8 @@ func TestResourceEnrich(t *testing.T) { }(), config: config.Enabled().Resource, enrichedAttrs: map[string]any{ - AttributeAgentName: "customflavor/unknown/elastic", - AttributeAgentVersion: "unknown", + common.AttributeAgentName: "customflavor/unknown/elastic", + common.AttributeAgentVersion: "unknown", }, }, { @@ -86,8 +87,8 @@ func TestResourceEnrich(t *testing.T) { }(), config: config.Enabled().Resource, enrichedAttrs: map[string]any{ - AttributeAgentName: "customflavor/cpp/elastic", - AttributeAgentVersion: "unknown", + common.AttributeAgentName: "customflavor/cpp/elastic", + common.AttributeAgentVersion: "unknown", }, }, { @@ -99,8 +100,8 @@ func TestResourceEnrich(t *testing.T) { }(), config: config.Enabled().Resource, enrichedAttrs: map[string]any{ - AttributeAgentName: "otlp/cpp", - AttributeAgentVersion: "unknown", + common.AttributeAgentName: "otlp/cpp", + common.AttributeAgentVersion: "unknown", }, }, { @@ -113,8 +114,8 @@ func TestResourceEnrich(t *testing.T) { }(), config: config.Enabled().Resource, enrichedAttrs: map[string]any{ - AttributeAgentName: "customflavor/cpp", - AttributeAgentVersion: "unknown", + common.AttributeAgentName: "customflavor/cpp", + common.AttributeAgentVersion: "unknown", }, }, { @@ -127,8 +128,8 @@ func TestResourceEnrich(t *testing.T) { }(), config: config.Enabled().Resource, enrichedAttrs: map[string]any{ - AttributeAgentName: "customflavor", - AttributeAgentVersion: "9.999.9", + common.AttributeAgentName: "customflavor", + common.AttributeAgentVersion: "9.999.9", }, }, { @@ -142,8 +143,8 @@ func TestResourceEnrich(t *testing.T) { }(), config: config.Enabled().Resource, enrichedAttrs: map[string]any{ - AttributeAgentName: "customflavor/unknown/elastic", - AttributeAgentVersion: "unknown", + common.AttributeAgentName: "customflavor/unknown/elastic", + common.AttributeAgentVersion: "unknown", }, }, { @@ -158,8 +159,8 @@ func TestResourceEnrich(t *testing.T) { }(), config: config.Enabled().Resource, enrichedAttrs: map[string]any{ - AttributeAgentName: "customflavor/unknown/elastic", - AttributeAgentVersion: "1.2.3", + common.AttributeAgentName: "customflavor/unknown/elastic", + common.AttributeAgentVersion: "1.2.3", }, }, { @@ -174,8 +175,8 @@ func TestResourceEnrich(t *testing.T) { enrichedAttrs: map[string]any{ semconv.AttributeHostName: "k8s-node", semconv.AttributeK8SNodeName: "k8s-node", - AttributeAgentName: "otlp", - AttributeAgentVersion: "unknown", + common.AttributeAgentName: "otlp", + common.AttributeAgentVersion: "unknown", }, }, { @@ -189,8 +190,8 @@ func TestResourceEnrich(t *testing.T) { enrichedAttrs: map[string]any{ semconv.AttributeHostName: "k8s-node", semconv.AttributeK8SNodeName: "k8s-node", - AttributeAgentName: "otlp", - AttributeAgentVersion: "unknown", + common.AttributeAgentName: "otlp", + common.AttributeAgentVersion: "unknown", }, }, } { diff --git a/enrichments/trace/internal/elastic/scope.go b/enrichments/trace/internal/elastic/scope.go index 69a664c..647a32b 100644 --- a/enrichments/trace/internal/elastic/scope.go +++ b/enrichments/trace/internal/elastic/scope.go @@ -18,6 +18,7 @@ package elastic import ( + "github.com/elastic/opentelemetry-lib/common" "github.com/elastic/opentelemetry-lib/enrichments/trace/config" "go.opentelemetry.io/collector/pdata/pcommon" ) @@ -27,8 +28,8 @@ func EnrichScope(scope pcommon.InstrumentationScope, cfg config.Config) { attrs := scope.Attributes() if cfg.Scope.ServiceFrameworkName.Enabled { if name := scope.Name(); name != "" { - attrs.PutStr(AttributeServiceFrameworkName, name) - attrs.PutStr(AttributeServiceFrameworkVersion, scope.Version()) + attrs.PutStr(common.AttributeServiceFrameworkName, name) + attrs.PutStr(common.AttributeServiceFrameworkVersion, scope.Version()) } } } diff --git a/enrichments/trace/internal/elastic/scope_test.go b/enrichments/trace/internal/elastic/scope_test.go index 7aa0500..f6c46cd 100644 --- a/enrichments/trace/internal/elastic/scope_test.go +++ b/enrichments/trace/internal/elastic/scope_test.go @@ -20,6 +20,7 @@ package elastic import ( "testing" + "github.com/elastic/opentelemetry-lib/common" "github.com/elastic/opentelemetry-lib/enrichments/trace/config" "github.com/google/go-cmp/cmp" "github.com/stretchr/testify/assert" @@ -47,8 +48,8 @@ func TestScopeEnrich(t *testing.T) { }(), config: config.Enabled().Scope, enrichedAttrs: map[string]any{ - AttributeServiceFrameworkName: "test", - AttributeServiceFrameworkVersion: "", + common.AttributeServiceFrameworkName: "test", + common.AttributeServiceFrameworkVersion: "", }, }, { @@ -61,8 +62,8 @@ func TestScopeEnrich(t *testing.T) { }(), config: config.Enabled().Scope, enrichedAttrs: map[string]any{ - AttributeServiceFrameworkName: "test", - AttributeServiceFrameworkVersion: "v1.0.0", + common.AttributeServiceFrameworkName: "test", + common.AttributeServiceFrameworkVersion: "v1.0.0", }, }, } { diff --git a/enrichments/trace/internal/elastic/span.go b/enrichments/trace/internal/elastic/span.go index ce8e25d..d8b5b6a 100644 --- a/enrichments/trace/internal/elastic/span.go +++ b/enrichments/trace/internal/elastic/span.go @@ -30,6 +30,7 @@ import ( "strconv" "strings" + "github.com/elastic/opentelemetry-lib/common" "github.com/elastic/opentelemetry-lib/enrichments/trace/config" "go.opentelemetry.io/collector/pdata/pcommon" "go.opentelemetry.io/collector/pdata/ptrace" @@ -205,32 +206,32 @@ func (s *spanEnrichmentContext) enrichTransaction( cfg config.ElasticTransactionConfig, ) { if cfg.TimestampUs.Enabled { - span.Attributes().PutInt(AttributeTimestampUs, getTimestampUs(span.StartTimestamp())) + span.Attributes().PutInt(common.AttributeTimestampUs, getTimestampUs(span.StartTimestamp())) } if cfg.Sampled.Enabled { - span.Attributes().PutBool(AttributeTransactionSampled, s.getSampled()) + span.Attributes().PutBool(common.AttributeTransactionSampled, s.getSampled()) } if cfg.ID.Enabled { - span.Attributes().PutStr(AttributeTransactionID, span.SpanID().String()) + span.Attributes().PutStr(common.AttributeTransactionID, span.SpanID().String()) } if cfg.Root.Enabled { - span.Attributes().PutBool(AttributeTransactionRoot, isTraceRoot(span)) + span.Attributes().PutBool(common.AttributeTransactionRoot, isTraceRoot(span)) } if cfg.Name.Enabled { - span.Attributes().PutStr(AttributeTransactionName, span.Name()) + span.Attributes().PutStr(common.AttributeTransactionName, span.Name()) } if cfg.ProcessorEvent.Enabled { - span.Attributes().PutStr(AttributeProcessorEvent, "transaction") + span.Attributes().PutStr(common.AttributeProcessorEvent, "transaction") } if cfg.RepresentativeCount.Enabled { repCount := getRepresentativeCount(span.TraceState().AsRaw()) - span.Attributes().PutDouble(AttributeTransactionRepresentativeCount, repCount) + span.Attributes().PutDouble(common.AttributeTransactionRepresentativeCount, repCount) } if cfg.DurationUs.Enabled { - span.Attributes().PutInt(AttributeTransactionDurationUs, getDurationUs(span)) + span.Attributes().PutInt(common.AttributeTransactionDurationUs, getDurationUs(span)) } if cfg.Type.Enabled { - span.Attributes().PutStr(AttributeTransactionType, s.getTxnType()) + span.Attributes().PutStr(common.AttributeTransactionType, s.getTxnType()) } if cfg.Result.Enabled { s.setTxnResult(span) @@ -248,17 +249,17 @@ func (s *spanEnrichmentContext) enrichSpan( cfg config.ElasticSpanConfig, ) { if cfg.TimestampUs.Enabled { - span.Attributes().PutInt(AttributeTimestampUs, getTimestampUs(span.StartTimestamp())) + span.Attributes().PutInt(common.AttributeTimestampUs, getTimestampUs(span.StartTimestamp())) } if cfg.Name.Enabled { - span.Attributes().PutStr(AttributeSpanName, span.Name()) + span.Attributes().PutStr(common.AttributeSpanName, span.Name()) } if cfg.ProcessorEvent.Enabled { - span.Attributes().PutStr(AttributeProcessorEvent, "span") + span.Attributes().PutStr(common.AttributeProcessorEvent, "span") } if cfg.RepresentativeCount.Enabled { repCount := getRepresentativeCount(span.TraceState().AsRaw()) - span.Attributes().PutDouble(AttributeSpanRepresentativeCount, repCount) + span.Attributes().PutDouble(common.AttributeSpanRepresentativeCount, repCount) } if cfg.TypeSubtype.Enabled { s.setSpanTypeSubtype(span) @@ -267,7 +268,7 @@ func (s *spanEnrichmentContext) enrichSpan( s.setEventOutcome(span) } if cfg.DurationUs.Enabled { - span.Attributes().PutInt(AttributeSpanDurationUs, getDurationUs(span)) + span.Attributes().PutInt(common.AttributeSpanDurationUs, getDurationUs(span)) } if cfg.ServiceTarget.Enabled { s.setServiceTarget(span) @@ -328,7 +329,7 @@ func (s *spanEnrichmentContext) setTxnResult(span ptrace.Span) { } } - span.Attributes().PutStr(AttributeTransactionResult, result) + span.Attributes().PutStr(common.AttributeTransactionResult, result) } func (s *spanEnrichmentContext) setEventOutcome(span ptrace.Span) { @@ -347,8 +348,8 @@ func (s *spanEnrichmentContext) setEventOutcome(span ptrace.Span) { outcome = "failure" successCount = 0 } - span.Attributes().PutStr(AttributeEventOutcome, outcome) - span.Attributes().PutInt(AttributeSuccessCount, int64(successCount)) + span.Attributes().PutStr(common.AttributeEventOutcome, outcome) + span.Attributes().PutInt(common.AttributeSuccessCount, int64(successCount)) } func (s *spanEnrichmentContext) setSpanTypeSubtype(span ptrace.Span) { @@ -380,9 +381,9 @@ func (s *spanEnrichmentContext) setSpanTypeSubtype(span ptrace.Span) { } } - span.Attributes().PutStr(AttributeSpanType, spanType) + span.Attributes().PutStr(common.AttributeSpanType, spanType) if spanSubtype != "" { - span.Attributes().PutStr(AttributeSpanSubtype, spanSubtype) + span.Attributes().PutStr(common.AttributeSpanSubtype, spanSubtype) } } @@ -429,8 +430,8 @@ func (s *spanEnrichmentContext) setServiceTarget(span ptrace.Span) { } if targetType != "" || targetName != "" { - span.Attributes().PutStr(AttributeServiceTargetType, targetType) - span.Attributes().PutStr(AttributeServiceTargetName, targetName) + span.Attributes().PutStr(common.AttributeServiceTargetType, targetType) + span.Attributes().PutStr(common.AttributeServiceTargetName, targetName) } } @@ -467,7 +468,7 @@ func (s *spanEnrichmentContext) setDestinationService(span ptrace.Span) { } if destnResource != "" { - span.Attributes().PutStr(AttributeSpanDestinationServiceResource, destnResource) + span.Attributes().PutStr(common.AttributeSpanDestinationServiceResource, destnResource) } } @@ -491,7 +492,7 @@ func (s *spanEnrichmentContext) setInferredSpans(span ptrace.Span) { }) if childIDs.Len() > 0 { - childIDs.MoveAndAppendTo(span.Attributes().PutEmptySlice(AttributeChildIDs)) + childIDs.MoveAndAppendTo(span.Attributes().PutEmptySlice(common.AttributeChildIDs)) } } @@ -526,10 +527,10 @@ func (s *spanEventEnrichmentContext) enrich( // Enrich span event attributes. if cfg.TimestampUs.Enabled { - se.Attributes().PutInt(AttributeTimestampUs, getTimestampUs(se.Timestamp())) + se.Attributes().PutInt(common.AttributeTimestampUs, getTimestampUs(se.Timestamp())) } if cfg.ProcessorEvent.Enabled && s.exception { - se.Attributes().PutStr(AttributeProcessorEvent, "error") + se.Attributes().PutStr(common.AttributeProcessorEvent, "error") } if s.exceptionType == "" && s.exceptionMessage == "" { // Span event does not represent an exception @@ -539,11 +540,11 @@ func (s *spanEventEnrichmentContext) enrich( // Span event represents exception if cfg.ErrorID.Enabled { if id, err := newUniqueID(); err == nil { - se.Attributes().PutStr(AttributeErrorID, id) + se.Attributes().PutStr(common.AttributeErrorID, id) } } if cfg.ErrorExceptionHandled.Enabled { - se.Attributes().PutBool(AttributeErrorExceptionHandled, !s.exceptionEscaped) + se.Attributes().PutBool(common.AttributeErrorExceptionHandled, !s.exceptionEscaped) } if cfg.ErrorGroupingKey.Enabled { // See https://github.com/elastic/apm-data/issues/299 @@ -554,21 +555,21 @@ func (s *spanEventEnrichmentContext) enrich( } else if s.exceptionMessage != "" { io.WriteString(hash, s.exceptionMessage) } - se.Attributes().PutStr(AttributeErrorGroupingKey, hex.EncodeToString(hash.Sum(nil))) + se.Attributes().PutStr(common.AttributeErrorGroupingKey, hex.EncodeToString(hash.Sum(nil))) } if cfg.ErrorGroupingName.Enabled { if s.exceptionMessage != "" { - se.Attributes().PutStr(AttributeErrorGroupingName, s.exceptionMessage) + se.Attributes().PutStr(common.AttributeErrorGroupingName, s.exceptionMessage) } } // Transaction type and sampled are added as span event enrichment only for errors if parentCtx.isTransaction && s.exception { if cfg.TransactionSampled.Enabled { - se.Attributes().PutBool(AttributeTransactionSampled, parentCtx.getSampled()) + se.Attributes().PutBool(common.AttributeTransactionSampled, parentCtx.getSampled()) } if cfg.TransactionType.Enabled { - se.Attributes().PutStr(AttributeTransactionType, parentCtx.getTxnType()) + se.Attributes().PutStr(common.AttributeTransactionType, parentCtx.getTxnType()) } } } diff --git a/enrichments/trace/internal/elastic/span_test.go b/enrichments/trace/internal/elastic/span_test.go index 3dff12c..a80cae7 100644 --- a/enrichments/trace/internal/elastic/span_test.go +++ b/enrichments/trace/internal/elastic/span_test.go @@ -24,6 +24,7 @@ import ( "testing" "time" + "github.com/elastic/opentelemetry-lib/common" "github.com/elastic/opentelemetry-lib/enrichments/trace/config" "github.com/google/go-cmp/cmp" "github.com/open-telemetry/opentelemetry-collector-contrib/pkg/pdatatest/ptracetest" @@ -62,18 +63,18 @@ func TestElasticTransactionEnrich(t *testing.T) { input: ptrace.NewSpan(), config: config.Enabled().Transaction, enrichedAttrs: map[string]any{ - AttributeTimestampUs: int64(0), - AttributeTransactionSampled: true, - AttributeTransactionRoot: true, - AttributeTransactionID: "", - AttributeTransactionName: "", - AttributeProcessorEvent: "transaction", - AttributeTransactionRepresentativeCount: float64(1), - AttributeTransactionDurationUs: int64(0), - AttributeEventOutcome: "success", - AttributeSuccessCount: int64(1), - AttributeTransactionResult: "Success", - AttributeTransactionType: "unknown", + common.AttributeTimestampUs: int64(0), + common.AttributeTransactionSampled: true, + common.AttributeTransactionRoot: true, + common.AttributeTransactionID: "", + common.AttributeTransactionName: "", + common.AttributeProcessorEvent: "transaction", + common.AttributeTransactionRepresentativeCount: float64(1), + common.AttributeTransactionDurationUs: int64(0), + common.AttributeEventOutcome: "success", + common.AttributeSuccessCount: int64(1), + common.AttributeTransactionResult: "Success", + common.AttributeTransactionType: "unknown", }, }, { @@ -90,18 +91,18 @@ func TestElasticTransactionEnrich(t *testing.T) { }(), config: config.Enabled().Transaction, enrichedAttrs: map[string]any{ - AttributeTimestampUs: int64(0), - AttributeTransactionSampled: true, - AttributeTransactionRoot: true, - AttributeTransactionID: "", - AttributeTransactionName: "", - AttributeProcessorEvent: "transaction", - AttributeTransactionRepresentativeCount: float64(256), - AttributeTransactionDurationUs: int64(0), - AttributeEventOutcome: "success", - AttributeSuccessCount: int64(256), - AttributeTransactionResult: "Success", - AttributeTransactionType: "unknown", + common.AttributeTimestampUs: int64(0), + common.AttributeTransactionSampled: true, + common.AttributeTransactionRoot: true, + common.AttributeTransactionID: "", + common.AttributeTransactionName: "", + common.AttributeProcessorEvent: "transaction", + common.AttributeTransactionRepresentativeCount: float64(256), + common.AttributeTransactionDurationUs: int64(0), + common.AttributeEventOutcome: "success", + common.AttributeSuccessCount: int64(256), + common.AttributeTransactionResult: "Success", + common.AttributeTransactionType: "unknown", }, }, { @@ -114,18 +115,18 @@ func TestElasticTransactionEnrich(t *testing.T) { }(), config: config.Enabled().Transaction, enrichedAttrs: map[string]any{ - AttributeTimestampUs: startTs.AsTime().UnixMicro(), - AttributeTransactionSampled: true, - AttributeTransactionRoot: true, - AttributeTransactionID: "0100000000000000", - AttributeTransactionName: "testtxn", - AttributeProcessorEvent: "transaction", - AttributeTransactionRepresentativeCount: float64(1), - AttributeTransactionDurationUs: expectedDuration.Microseconds(), - AttributeEventOutcome: "success", - AttributeSuccessCount: int64(1), - AttributeTransactionResult: "HTTP 2xx", - AttributeTransactionType: "request", + common.AttributeTimestampUs: startTs.AsTime().UnixMicro(), + common.AttributeTransactionSampled: true, + common.AttributeTransactionRoot: true, + common.AttributeTransactionID: "0100000000000000", + common.AttributeTransactionName: "testtxn", + common.AttributeProcessorEvent: "transaction", + common.AttributeTransactionRepresentativeCount: float64(1), + common.AttributeTransactionDurationUs: expectedDuration.Microseconds(), + common.AttributeEventOutcome: "success", + common.AttributeSuccessCount: int64(1), + common.AttributeTransactionResult: "HTTP 2xx", + common.AttributeTransactionType: "request", }, }, { @@ -144,18 +145,18 @@ func TestElasticTransactionEnrich(t *testing.T) { }(), config: config.Enabled().Transaction, enrichedAttrs: map[string]any{ - AttributeTimestampUs: startTs.AsTime().UnixMicro(), - AttributeTransactionSampled: true, - AttributeTransactionRoot: true, - AttributeTransactionID: "0100000000000000", - AttributeTransactionName: "testtxn", - AttributeProcessorEvent: "transaction", - AttributeTransactionRepresentativeCount: float64(1), - AttributeTransactionDurationUs: expectedDuration.Microseconds(), - AttributeEventOutcome: "success", - AttributeSuccessCount: int64(1), - AttributeTransactionResult: "HTTP 1xx", - AttributeTransactionType: "request", + common.AttributeTimestampUs: startTs.AsTime().UnixMicro(), + common.AttributeTransactionSampled: true, + common.AttributeTransactionRoot: true, + common.AttributeTransactionID: "0100000000000000", + common.AttributeTransactionName: "testtxn", + common.AttributeProcessorEvent: "transaction", + common.AttributeTransactionRepresentativeCount: float64(1), + common.AttributeTransactionDurationUs: expectedDuration.Microseconds(), + common.AttributeEventOutcome: "success", + common.AttributeSuccessCount: int64(1), + common.AttributeTransactionResult: "HTTP 1xx", + common.AttributeTransactionType: "request", }, }, { @@ -173,18 +174,18 @@ func TestElasticTransactionEnrich(t *testing.T) { }(), config: config.Enabled().Transaction, enrichedAttrs: map[string]any{ - AttributeTimestampUs: startTs.AsTime().UnixMicro(), - AttributeTransactionSampled: true, - AttributeTransactionRoot: true, - AttributeTransactionID: "0100000000000000", - AttributeTransactionName: "testtxn", - AttributeProcessorEvent: "transaction", - AttributeTransactionRepresentativeCount: float64(1), - AttributeTransactionDurationUs: expectedDuration.Microseconds(), - AttributeEventOutcome: "success", - AttributeSuccessCount: int64(1), - AttributeTransactionResult: "HTTP 5xx", - AttributeTransactionType: "request", + common.AttributeTimestampUs: startTs.AsTime().UnixMicro(), + common.AttributeTransactionSampled: true, + common.AttributeTransactionRoot: true, + common.AttributeTransactionID: "0100000000000000", + common.AttributeTransactionName: "testtxn", + common.AttributeProcessorEvent: "transaction", + common.AttributeTransactionRepresentativeCount: float64(1), + common.AttributeTransactionDurationUs: expectedDuration.Microseconds(), + common.AttributeEventOutcome: "success", + common.AttributeSuccessCount: int64(1), + common.AttributeTransactionResult: "HTTP 5xx", + common.AttributeTransactionType: "request", }, }, { @@ -203,18 +204,18 @@ func TestElasticTransactionEnrich(t *testing.T) { }(), config: config.Enabled().Transaction, enrichedAttrs: map[string]any{ - AttributeTimestampUs: startTs.AsTime().UnixMicro(), - AttributeTransactionSampled: true, - AttributeTransactionRoot: true, - AttributeTransactionID: "0100000000000000", - AttributeTransactionName: "testtxn", - AttributeProcessorEvent: "transaction", - AttributeTransactionRepresentativeCount: float64(1), - AttributeTransactionDurationUs: expectedDuration.Microseconds(), - AttributeEventOutcome: "success", - AttributeSuccessCount: int64(1), - AttributeTransactionResult: "OK", - AttributeTransactionType: "request", + common.AttributeTimestampUs: startTs.AsTime().UnixMicro(), + common.AttributeTransactionSampled: true, + common.AttributeTransactionRoot: true, + common.AttributeTransactionID: "0100000000000000", + common.AttributeTransactionName: "testtxn", + common.AttributeProcessorEvent: "transaction", + common.AttributeTransactionRepresentativeCount: float64(1), + common.AttributeTransactionDurationUs: expectedDuration.Microseconds(), + common.AttributeEventOutcome: "success", + common.AttributeSuccessCount: int64(1), + common.AttributeTransactionResult: "OK", + common.AttributeTransactionType: "request", }, }, { @@ -233,18 +234,18 @@ func TestElasticTransactionEnrich(t *testing.T) { }(), config: config.Enabled().Transaction, enrichedAttrs: map[string]any{ - AttributeTimestampUs: startTs.AsTime().UnixMicro(), - AttributeTransactionSampled: true, - AttributeTransactionRoot: true, - AttributeTransactionID: "0100000000000000", - AttributeTransactionName: "testtxn", - AttributeProcessorEvent: "transaction", - AttributeTransactionRepresentativeCount: float64(1), - AttributeTransactionDurationUs: expectedDuration.Microseconds(), - AttributeEventOutcome: "success", - AttributeSuccessCount: int64(1), - AttributeTransactionResult: "Internal", - AttributeTransactionType: "request", + common.AttributeTimestampUs: startTs.AsTime().UnixMicro(), + common.AttributeTransactionSampled: true, + common.AttributeTransactionRoot: true, + common.AttributeTransactionID: "0100000000000000", + common.AttributeTransactionName: "testtxn", + common.AttributeProcessorEvent: "transaction", + common.AttributeTransactionRepresentativeCount: float64(1), + common.AttributeTransactionDurationUs: expectedDuration.Microseconds(), + common.AttributeEventOutcome: "success", + common.AttributeSuccessCount: int64(1), + common.AttributeTransactionResult: "Internal", + common.AttributeTransactionType: "request", }, }, { @@ -258,18 +259,18 @@ func TestElasticTransactionEnrich(t *testing.T) { }(), config: config.Enabled().Transaction, enrichedAttrs: map[string]any{ - AttributeTimestampUs: startTs.AsTime().UnixMicro(), - AttributeTransactionSampled: true, - AttributeTransactionRoot: true, - AttributeTransactionID: "0100000000000000", - AttributeTransactionName: "testtxn", - AttributeProcessorEvent: "transaction", - AttributeTransactionRepresentativeCount: float64(1), - AttributeTransactionDurationUs: expectedDuration.Microseconds(), - AttributeEventOutcome: "success", - AttributeSuccessCount: int64(1), - AttributeTransactionResult: "Success", - AttributeTransactionType: "unknown", + common.AttributeTimestampUs: startTs.AsTime().UnixMicro(), + common.AttributeTransactionSampled: true, + common.AttributeTransactionRoot: true, + common.AttributeTransactionID: "0100000000000000", + common.AttributeTransactionName: "testtxn", + common.AttributeProcessorEvent: "transaction", + common.AttributeTransactionRepresentativeCount: float64(1), + common.AttributeTransactionDurationUs: expectedDuration.Microseconds(), + common.AttributeEventOutcome: "success", + common.AttributeSuccessCount: int64(1), + common.AttributeTransactionResult: "Success", + common.AttributeTransactionType: "unknown", }, }, { @@ -283,18 +284,18 @@ func TestElasticTransactionEnrich(t *testing.T) { }(), config: config.Enabled().Transaction, enrichedAttrs: map[string]any{ - AttributeTimestampUs: startTs.AsTime().UnixMicro(), - AttributeTransactionSampled: true, - AttributeTransactionRoot: true, - AttributeTransactionID: "0100000000000000", - AttributeTransactionName: "testtxn", - AttributeProcessorEvent: "transaction", - AttributeTransactionRepresentativeCount: float64(1), - AttributeTransactionDurationUs: expectedDuration.Microseconds(), - AttributeEventOutcome: "failure", - AttributeSuccessCount: int64(0), - AttributeTransactionResult: "Error", - AttributeTransactionType: "unknown", + common.AttributeTimestampUs: startTs.AsTime().UnixMicro(), + common.AttributeTransactionSampled: true, + common.AttributeTransactionRoot: true, + common.AttributeTransactionID: "0100000000000000", + common.AttributeTransactionName: "testtxn", + common.AttributeProcessorEvent: "transaction", + common.AttributeTransactionRepresentativeCount: float64(1), + common.AttributeTransactionDurationUs: expectedDuration.Microseconds(), + common.AttributeEventOutcome: "failure", + common.AttributeSuccessCount: int64(0), + common.AttributeTransactionResult: "Error", + common.AttributeTransactionType: "unknown", }, }, { @@ -308,18 +309,18 @@ func TestElasticTransactionEnrich(t *testing.T) { }(), config: config.Enabled().Transaction, enrichedAttrs: map[string]any{ - AttributeTimestampUs: startTs.AsTime().UnixMicro(), - AttributeTransactionSampled: true, - AttributeTransactionRoot: true, - AttributeTransactionID: "0100000000000000", - AttributeTransactionName: "testtxn", - AttributeProcessorEvent: "transaction", - AttributeTransactionRepresentativeCount: float64(1), - AttributeTransactionDurationUs: expectedDuration.Microseconds(), - AttributeEventOutcome: "success", - AttributeSuccessCount: int64(1), - AttributeTransactionResult: "Success", - AttributeTransactionType: "messaging", + common.AttributeTimestampUs: startTs.AsTime().UnixMicro(), + common.AttributeTransactionSampled: true, + common.AttributeTransactionRoot: true, + common.AttributeTransactionID: "0100000000000000", + common.AttributeTransactionName: "testtxn", + common.AttributeProcessorEvent: "transaction", + common.AttributeTransactionRepresentativeCount: float64(1), + common.AttributeTransactionDurationUs: expectedDuration.Microseconds(), + common.AttributeEventOutcome: "success", + common.AttributeSuccessCount: int64(1), + common.AttributeTransactionResult: "Success", + common.AttributeTransactionType: "messaging", }, }, { @@ -342,19 +343,19 @@ func TestElasticTransactionEnrich(t *testing.T) { }(), config: config.Enabled().Transaction, enrichedAttrs: map[string]any{ - AttributeTimestampUs: startTs.AsTime().UnixMicro(), - AttributeTransactionSampled: true, - AttributeTransactionRoot: true, - AttributeTransactionID: "0100000000000000", - AttributeTransactionName: "testtxn", - AttributeProcessorEvent: "transaction", - AttributeTransactionRepresentativeCount: float64(1), - AttributeTransactionDurationUs: expectedDuration.Microseconds(), - AttributeEventOutcome: "success", - AttributeSuccessCount: int64(1), - AttributeTransactionResult: "Success", - AttributeTransactionType: "unknown", - AttributeChildIDs: []any{"0300000000000000", "0400000000000000"}, + common.AttributeTimestampUs: startTs.AsTime().UnixMicro(), + common.AttributeTransactionSampled: true, + common.AttributeTransactionRoot: true, + common.AttributeTransactionID: "0100000000000000", + common.AttributeTransactionName: "testtxn", + common.AttributeProcessorEvent: "transaction", + common.AttributeTransactionRepresentativeCount: float64(1), + common.AttributeTransactionDurationUs: expectedDuration.Microseconds(), + common.AttributeEventOutcome: "success", + common.AttributeSuccessCount: int64(1), + common.AttributeTransactionResult: "Success", + common.AttributeTransactionType: "unknown", + common.AttributeChildIDs: []any{"0300000000000000", "0400000000000000"}, }, expectedSpanLinks: func() *ptrace.SpanLinkSlice { spanLinks := ptrace.NewSpanLinkSlice() @@ -417,14 +418,14 @@ func TestElasticSpanEnrich(t *testing.T) { }(), config: config.Enabled().Span, enrichedAttrs: map[string]any{ - AttributeTimestampUs: int64(0), - AttributeSpanName: "", - AttributeProcessorEvent: "span", - AttributeSpanRepresentativeCount: float64(1), - AttributeSpanType: "unknown", - AttributeSpanDurationUs: int64(0), - AttributeEventOutcome: "success", - AttributeSuccessCount: int64(1), + common.AttributeTimestampUs: int64(0), + common.AttributeSpanName: "", + common.AttributeProcessorEvent: "span", + common.AttributeSpanRepresentativeCount: float64(1), + common.AttributeSpanType: "unknown", + common.AttributeSpanDurationUs: int64(0), + common.AttributeEventOutcome: "success", + common.AttributeSuccessCount: int64(1), }, }, { @@ -442,15 +443,15 @@ func TestElasticSpanEnrich(t *testing.T) { }(), config: config.Enabled().Span, enrichedAttrs: map[string]any{ - AttributeTimestampUs: int64(0), - AttributeSpanName: "", - AttributeProcessorEvent: "span", - AttributeSpanRepresentativeCount: float64(1), - AttributeSpanType: "app", - AttributeSpanSubtype: "internal", - AttributeSpanDurationUs: int64(0), - AttributeEventOutcome: "success", - AttributeSuccessCount: int64(1), + common.AttributeTimestampUs: int64(0), + common.AttributeSpanName: "", + common.AttributeProcessorEvent: "span", + common.AttributeSpanRepresentativeCount: float64(1), + common.AttributeSpanType: "app", + common.AttributeSpanSubtype: "internal", + common.AttributeSpanDurationUs: int64(0), + common.AttributeEventOutcome: "success", + common.AttributeSuccessCount: int64(1), }, }, { @@ -463,17 +464,17 @@ func TestElasticSpanEnrich(t *testing.T) { }(), config: config.Enabled().Span, enrichedAttrs: map[string]any{ - AttributeTimestampUs: startTs.AsTime().UnixMicro(), - AttributeSpanName: "testspan", - AttributeProcessorEvent: "span", - AttributeSpanRepresentativeCount: float64(1), - AttributeSpanType: "unknown", - AttributeSpanDurationUs: expectedDuration.Microseconds(), - AttributeEventOutcome: "success", - AttributeSuccessCount: int64(1), - AttributeServiceTargetName: "testsvc", - AttributeServiceTargetType: "", - AttributeSpanDestinationServiceResource: "testsvc", + common.AttributeTimestampUs: startTs.AsTime().UnixMicro(), + common.AttributeSpanName: "testspan", + common.AttributeProcessorEvent: "span", + common.AttributeSpanRepresentativeCount: float64(1), + common.AttributeSpanType: "unknown", + common.AttributeSpanDurationUs: expectedDuration.Microseconds(), + common.AttributeEventOutcome: "success", + common.AttributeSuccessCount: int64(1), + common.AttributeServiceTargetName: "testsvc", + common.AttributeServiceTargetType: "", + common.AttributeSpanDestinationServiceResource: "testsvc", }, }, { @@ -490,18 +491,18 @@ func TestElasticSpanEnrich(t *testing.T) { }(), config: config.Enabled().Span, enrichedAttrs: map[string]any{ - AttributeTimestampUs: startTs.AsTime().UnixMicro(), - AttributeSpanName: "testspan", - AttributeProcessorEvent: "span", - AttributeSpanRepresentativeCount: float64(1), - AttributeSpanType: "external", - AttributeSpanSubtype: "http", - AttributeSpanDurationUs: expectedDuration.Microseconds(), - AttributeEventOutcome: "success", - AttributeSuccessCount: int64(1), - AttributeServiceTargetType: "http", - AttributeServiceTargetName: "testsvc", - AttributeSpanDestinationServiceResource: "testsvc", + common.AttributeTimestampUs: startTs.AsTime().UnixMicro(), + common.AttributeSpanName: "testspan", + common.AttributeProcessorEvent: "span", + common.AttributeSpanRepresentativeCount: float64(1), + common.AttributeSpanType: "external", + common.AttributeSpanSubtype: "http", + common.AttributeSpanDurationUs: expectedDuration.Microseconds(), + common.AttributeEventOutcome: "success", + common.AttributeSuccessCount: int64(1), + common.AttributeServiceTargetType: "http", + common.AttributeServiceTargetName: "testsvc", + common.AttributeSpanDestinationServiceResource: "testsvc", }, }, { @@ -524,18 +525,18 @@ func TestElasticSpanEnrich(t *testing.T) { }(), config: config.Enabled().Span, enrichedAttrs: map[string]any{ - AttributeTimestampUs: startTs.AsTime().UnixMicro(), - AttributeSpanName: "testspan", - AttributeProcessorEvent: "span", - AttributeSpanRepresentativeCount: float64(1), - AttributeSpanType: "external", - AttributeSpanSubtype: "http", - AttributeSpanDurationUs: expectedDuration.Microseconds(), - AttributeEventOutcome: "success", - AttributeSuccessCount: int64(1), - AttributeServiceTargetType: "http", - AttributeServiceTargetName: "www.foo.bar:443", - AttributeSpanDestinationServiceResource: "testsvc", + common.AttributeTimestampUs: startTs.AsTime().UnixMicro(), + common.AttributeSpanName: "testspan", + common.AttributeProcessorEvent: "span", + common.AttributeSpanRepresentativeCount: float64(1), + common.AttributeSpanType: "external", + common.AttributeSpanSubtype: "http", + common.AttributeSpanDurationUs: expectedDuration.Microseconds(), + common.AttributeEventOutcome: "success", + common.AttributeSuccessCount: int64(1), + common.AttributeServiceTargetType: "http", + common.AttributeServiceTargetName: "www.foo.bar:443", + common.AttributeSpanDestinationServiceResource: "testsvc", }, }, { @@ -558,18 +559,18 @@ func TestElasticSpanEnrich(t *testing.T) { }(), config: config.Enabled().Span, enrichedAttrs: map[string]any{ - AttributeTimestampUs: startTs.AsTime().UnixMicro(), - AttributeSpanName: "testspan", - AttributeProcessorEvent: "span", - AttributeSpanRepresentativeCount: float64(1), - AttributeSpanType: "external", - AttributeSpanSubtype: "http", - AttributeSpanDurationUs: expectedDuration.Microseconds(), - AttributeEventOutcome: "success", - AttributeSuccessCount: int64(1), - AttributeServiceTargetType: "http", - AttributeServiceTargetName: "www.foo.bar:443", - AttributeSpanDestinationServiceResource: "testsvc", + common.AttributeTimestampUs: startTs.AsTime().UnixMicro(), + common.AttributeSpanName: "testspan", + common.AttributeProcessorEvent: "span", + common.AttributeSpanRepresentativeCount: float64(1), + common.AttributeSpanType: "external", + common.AttributeSpanSubtype: "http", + common.AttributeSpanDurationUs: expectedDuration.Microseconds(), + common.AttributeEventOutcome: "success", + common.AttributeSuccessCount: int64(1), + common.AttributeServiceTargetType: "http", + common.AttributeServiceTargetName: "www.foo.bar:443", + common.AttributeSpanDestinationServiceResource: "testsvc", }, }, { @@ -590,18 +591,18 @@ func TestElasticSpanEnrich(t *testing.T) { }(), config: config.Enabled().Span, enrichedAttrs: map[string]any{ - AttributeTimestampUs: startTs.AsTime().UnixMicro(), - AttributeSpanName: "testspan", - AttributeProcessorEvent: "span", - AttributeSpanRepresentativeCount: float64(1), - AttributeSpanType: "external", - AttributeSpanSubtype: "http", - AttributeSpanDurationUs: expectedDuration.Microseconds(), - AttributeEventOutcome: "success", - AttributeSuccessCount: int64(1), - AttributeServiceTargetType: "http", - AttributeServiceTargetName: "www.foo.bar:443", - AttributeSpanDestinationServiceResource: "testsvc", + common.AttributeTimestampUs: startTs.AsTime().UnixMicro(), + common.AttributeSpanName: "testspan", + common.AttributeProcessorEvent: "span", + common.AttributeSpanRepresentativeCount: float64(1), + common.AttributeSpanType: "external", + common.AttributeSpanSubtype: "http", + common.AttributeSpanDurationUs: expectedDuration.Microseconds(), + common.AttributeEventOutcome: "success", + common.AttributeSuccessCount: int64(1), + common.AttributeServiceTargetType: "http", + common.AttributeServiceTargetName: "www.foo.bar:443", + common.AttributeSpanDestinationServiceResource: "testsvc", }, }, { @@ -618,18 +619,18 @@ func TestElasticSpanEnrich(t *testing.T) { }(), config: config.Enabled().Span, enrichedAttrs: map[string]any{ - AttributeTimestampUs: startTs.AsTime().UnixMicro(), - AttributeSpanName: "testspan", - AttributeProcessorEvent: "span", - AttributeSpanRepresentativeCount: float64(1), - AttributeSpanType: "external", - AttributeSpanSubtype: "grpc", - AttributeSpanDurationUs: expectedDuration.Microseconds(), - AttributeEventOutcome: "success", - AttributeSuccessCount: int64(1), - AttributeServiceTargetType: "grpc", - AttributeServiceTargetName: "testsvc", - AttributeSpanDestinationServiceResource: "testsvc", + common.AttributeTimestampUs: startTs.AsTime().UnixMicro(), + common.AttributeSpanName: "testspan", + common.AttributeProcessorEvent: "span", + common.AttributeSpanRepresentativeCount: float64(1), + common.AttributeSpanType: "external", + common.AttributeSpanSubtype: "grpc", + common.AttributeSpanDurationUs: expectedDuration.Microseconds(), + common.AttributeEventOutcome: "success", + common.AttributeSuccessCount: int64(1), + common.AttributeServiceTargetType: "grpc", + common.AttributeServiceTargetName: "testsvc", + common.AttributeSpanDestinationServiceResource: "testsvc", }, }, { @@ -643,18 +644,18 @@ func TestElasticSpanEnrich(t *testing.T) { }(), config: config.Enabled().Span, enrichedAttrs: map[string]any{ - AttributeTimestampUs: startTs.AsTime().UnixMicro(), - AttributeSpanName: "testspan", - AttributeProcessorEvent: "span", - AttributeSpanRepresentativeCount: float64(1), - AttributeSpanType: "external", - AttributeSpanSubtype: "xmlrpc", - AttributeSpanDurationUs: expectedDuration.Microseconds(), - AttributeEventOutcome: "success", - AttributeSuccessCount: int64(1), - AttributeServiceTargetType: "xmlrpc", - AttributeServiceTargetName: "testsvc", - AttributeSpanDestinationServiceResource: "testsvc", + common.AttributeTimestampUs: startTs.AsTime().UnixMicro(), + common.AttributeSpanName: "testspan", + common.AttributeProcessorEvent: "span", + common.AttributeSpanRepresentativeCount: float64(1), + common.AttributeSpanType: "external", + common.AttributeSpanSubtype: "xmlrpc", + common.AttributeSpanDurationUs: expectedDuration.Microseconds(), + common.AttributeEventOutcome: "success", + common.AttributeSuccessCount: int64(1), + common.AttributeServiceTargetType: "xmlrpc", + common.AttributeServiceTargetName: "testsvc", + common.AttributeSpanDestinationServiceResource: "testsvc", }, }, { @@ -670,17 +671,17 @@ func TestElasticSpanEnrich(t *testing.T) { }(), config: config.Enabled().Span, enrichedAttrs: map[string]any{ - AttributeTimestampUs: startTs.AsTime().UnixMicro(), - AttributeSpanName: "testspan", - AttributeProcessorEvent: "span", - AttributeSpanRepresentativeCount: float64(1), - AttributeSpanType: "external", - AttributeSpanDurationUs: expectedDuration.Microseconds(), - AttributeEventOutcome: "success", - AttributeSuccessCount: int64(1), - AttributeServiceTargetType: "external", - AttributeServiceTargetName: "service.Test", - AttributeSpanDestinationServiceResource: "testsvc", + common.AttributeTimestampUs: startTs.AsTime().UnixMicro(), + common.AttributeSpanName: "testspan", + common.AttributeProcessorEvent: "span", + common.AttributeSpanRepresentativeCount: float64(1), + common.AttributeSpanType: "external", + common.AttributeSpanDurationUs: expectedDuration.Microseconds(), + common.AttributeEventOutcome: "success", + common.AttributeSuccessCount: int64(1), + common.AttributeServiceTargetType: "external", + common.AttributeServiceTargetName: "service.Test", + common.AttributeSpanDestinationServiceResource: "testsvc", }, }, { @@ -696,17 +697,17 @@ func TestElasticSpanEnrich(t *testing.T) { }(), config: config.Enabled().Span, enrichedAttrs: map[string]any{ - AttributeTimestampUs: startTs.AsTime().UnixMicro(), - AttributeSpanName: "testspan", - AttributeProcessorEvent: "span", - AttributeSpanRepresentativeCount: float64(1), - AttributeSpanType: "external", - AttributeSpanDurationUs: expectedDuration.Microseconds(), - AttributeEventOutcome: "success", - AttributeSuccessCount: int64(1), - AttributeServiceTargetType: "external", - AttributeServiceTargetName: "service.Test", - AttributeSpanDestinationServiceResource: "10.2.20.18:8081", + common.AttributeTimestampUs: startTs.AsTime().UnixMicro(), + common.AttributeSpanName: "testspan", + common.AttributeProcessorEvent: "span", + common.AttributeSpanRepresentativeCount: float64(1), + common.AttributeSpanType: "external", + common.AttributeSpanDurationUs: expectedDuration.Microseconds(), + common.AttributeEventOutcome: "success", + common.AttributeSuccessCount: int64(1), + common.AttributeServiceTargetType: "external", + common.AttributeServiceTargetName: "service.Test", + common.AttributeSpanDestinationServiceResource: "10.2.20.18:8081", }, }, { @@ -722,17 +723,17 @@ func TestElasticSpanEnrich(t *testing.T) { }(), config: config.Enabled().Span, enrichedAttrs: map[string]any{ - AttributeTimestampUs: startTs.AsTime().UnixMicro(), - AttributeSpanName: "testspan", - AttributeProcessorEvent: "span", - AttributeSpanRepresentativeCount: float64(1), - AttributeSpanType: "external", - AttributeSpanDurationUs: expectedDuration.Microseconds(), - AttributeEventOutcome: "success", - AttributeSuccessCount: int64(1), - AttributeServiceTargetType: "external", - AttributeServiceTargetName: "service.Test", - AttributeSpanDestinationServiceResource: "10.2.20.18:8081", + common.AttributeTimestampUs: startTs.AsTime().UnixMicro(), + common.AttributeSpanName: "testspan", + common.AttributeProcessorEvent: "span", + common.AttributeSpanRepresentativeCount: float64(1), + common.AttributeSpanType: "external", + common.AttributeSpanDurationUs: expectedDuration.Microseconds(), + common.AttributeEventOutcome: "success", + common.AttributeSuccessCount: int64(1), + common.AttributeServiceTargetType: "external", + common.AttributeServiceTargetName: "service.Test", + common.AttributeSpanDestinationServiceResource: "10.2.20.18:8081", }, }, { @@ -746,18 +747,18 @@ func TestElasticSpanEnrich(t *testing.T) { }(), config: config.Enabled().Span, enrichedAttrs: map[string]any{ - AttributeTimestampUs: startTs.AsTime().UnixMicro(), - AttributeSpanName: "testspan", - AttributeProcessorEvent: "span", - AttributeSpanRepresentativeCount: float64(1), - AttributeSpanType: "messaging", - AttributeSpanSubtype: "kafka", - AttributeSpanDurationUs: expectedDuration.Microseconds(), - AttributeEventOutcome: "success", - AttributeSuccessCount: int64(1), - AttributeServiceTargetType: "kafka", - AttributeServiceTargetName: "testsvc", - AttributeSpanDestinationServiceResource: "testsvc", + common.AttributeTimestampUs: startTs.AsTime().UnixMicro(), + common.AttributeSpanName: "testspan", + common.AttributeProcessorEvent: "span", + common.AttributeSpanRepresentativeCount: float64(1), + common.AttributeSpanType: "messaging", + common.AttributeSpanSubtype: "kafka", + common.AttributeSpanDurationUs: expectedDuration.Microseconds(), + common.AttributeEventOutcome: "success", + common.AttributeSuccessCount: int64(1), + common.AttributeServiceTargetType: "kafka", + common.AttributeServiceTargetName: "testsvc", + common.AttributeSpanDestinationServiceResource: "testsvc", }, }, { @@ -771,17 +772,17 @@ func TestElasticSpanEnrich(t *testing.T) { }(), config: config.Enabled().Span, enrichedAttrs: map[string]any{ - AttributeTimestampUs: startTs.AsTime().UnixMicro(), - AttributeSpanName: "testspan", - AttributeProcessorEvent: "span", - AttributeSpanRepresentativeCount: float64(1), - AttributeSpanType: "messaging", - AttributeSpanDurationUs: expectedDuration.Microseconds(), - AttributeEventOutcome: "success", - AttributeSuccessCount: int64(1), - AttributeServiceTargetType: "messaging", - AttributeServiceTargetName: "t1", - AttributeSpanDestinationServiceResource: "testsvc/t1", + common.AttributeTimestampUs: startTs.AsTime().UnixMicro(), + common.AttributeSpanName: "testspan", + common.AttributeProcessorEvent: "span", + common.AttributeSpanRepresentativeCount: float64(1), + common.AttributeSpanType: "messaging", + common.AttributeSpanDurationUs: expectedDuration.Microseconds(), + common.AttributeEventOutcome: "success", + common.AttributeSuccessCount: int64(1), + common.AttributeServiceTargetType: "messaging", + common.AttributeServiceTargetName: "t1", + common.AttributeSpanDestinationServiceResource: "testsvc/t1", }, }, { @@ -796,17 +797,17 @@ func TestElasticSpanEnrich(t *testing.T) { }(), config: config.Enabled().Span, enrichedAttrs: map[string]any{ - AttributeTimestampUs: startTs.AsTime().UnixMicro(), - AttributeSpanName: "testspan", - AttributeProcessorEvent: "span", - AttributeSpanRepresentativeCount: float64(1), - AttributeSpanType: "messaging", - AttributeSpanDurationUs: expectedDuration.Microseconds(), - AttributeEventOutcome: "success", - AttributeSuccessCount: int64(1), - AttributeServiceTargetType: "messaging", - AttributeServiceTargetName: "testsvc", - AttributeSpanDestinationServiceResource: "testsvc/t1", + common.AttributeTimestampUs: startTs.AsTime().UnixMicro(), + common.AttributeSpanName: "testspan", + common.AttributeProcessorEvent: "span", + common.AttributeSpanRepresentativeCount: float64(1), + common.AttributeSpanType: "messaging", + common.AttributeSpanDurationUs: expectedDuration.Microseconds(), + common.AttributeEventOutcome: "success", + common.AttributeSuccessCount: int64(1), + common.AttributeServiceTargetType: "messaging", + common.AttributeServiceTargetName: "testsvc", + common.AttributeSpanDestinationServiceResource: "testsvc/t1", }, }, { @@ -827,18 +828,18 @@ func TestElasticSpanEnrich(t *testing.T) { }(), config: config.Enabled().Span, enrichedAttrs: map[string]any{ - AttributeTimestampUs: startTs.AsTime().UnixMicro(), - AttributeSpanName: "testspan", - AttributeProcessorEvent: "span", - AttributeSpanRepresentativeCount: float64(1), - AttributeSpanType: "db", - AttributeSpanSubtype: "elasticsearch", - AttributeSpanDurationUs: expectedDuration.Microseconds(), - AttributeEventOutcome: "success", - AttributeSuccessCount: int64(1), - AttributeServiceTargetType: "elasticsearch", - AttributeServiceTargetName: "testsvc", - AttributeSpanDestinationServiceResource: "testsvc", + common.AttributeTimestampUs: startTs.AsTime().UnixMicro(), + common.AttributeSpanName: "testspan", + common.AttributeProcessorEvent: "span", + common.AttributeSpanRepresentativeCount: float64(1), + common.AttributeSpanType: "db", + common.AttributeSpanSubtype: "elasticsearch", + common.AttributeSpanDurationUs: expectedDuration.Microseconds(), + common.AttributeEventOutcome: "success", + common.AttributeSuccessCount: int64(1), + common.AttributeServiceTargetType: "elasticsearch", + common.AttributeServiceTargetName: "testsvc", + common.AttributeSpanDestinationServiceResource: "testsvc", }, }, { @@ -864,18 +865,18 @@ func TestElasticSpanEnrich(t *testing.T) { }(), config: config.Enabled().Span, enrichedAttrs: map[string]any{ - AttributeTimestampUs: startTs.AsTime().UnixMicro(), - AttributeSpanName: "testspan", - AttributeProcessorEvent: "span", - AttributeSpanRepresentativeCount: float64(1), - AttributeSpanType: "db", - AttributeSpanSubtype: "cassandra", - AttributeSpanDurationUs: expectedDuration.Microseconds(), - AttributeEventOutcome: "success", - AttributeSuccessCount: int64(1), - AttributeServiceTargetType: "cassandra", - AttributeServiceTargetName: "testsvc", - AttributeSpanDestinationServiceResource: "testsvc", + common.AttributeTimestampUs: startTs.AsTime().UnixMicro(), + common.AttributeSpanName: "testspan", + common.AttributeProcessorEvent: "span", + common.AttributeSpanRepresentativeCount: float64(1), + common.AttributeSpanType: "db", + common.AttributeSpanSubtype: "cassandra", + common.AttributeSpanDurationUs: expectedDuration.Microseconds(), + common.AttributeEventOutcome: "success", + common.AttributeSuccessCount: int64(1), + common.AttributeServiceTargetType: "cassandra", + common.AttributeServiceTargetName: "testsvc", + common.AttributeSpanDestinationServiceResource: "testsvc", }, }, { @@ -898,15 +899,15 @@ func TestElasticSpanEnrich(t *testing.T) { }(), config: config.Enabled().Span, enrichedAttrs: map[string]any{ - AttributeTimestampUs: startTs.AsTime().UnixMicro(), - AttributeSpanName: "testspan", - AttributeProcessorEvent: "span", - AttributeSpanRepresentativeCount: float64(1), - AttributeSpanType: "unknown", - AttributeSpanDurationUs: expectedDuration.Microseconds(), - AttributeEventOutcome: "success", - AttributeSuccessCount: int64(1), - AttributeChildIDs: []any{"0300000000000000", "0400000000000000"}, + common.AttributeTimestampUs: startTs.AsTime().UnixMicro(), + common.AttributeSpanName: "testspan", + common.AttributeProcessorEvent: "span", + common.AttributeSpanRepresentativeCount: float64(1), + common.AttributeSpanType: "unknown", + common.AttributeSpanDurationUs: expectedDuration.Microseconds(), + common.AttributeEventOutcome: "success", + common.AttributeSuccessCount: int64(1), + common.AttributeChildIDs: []any{"0300000000000000", "0400000000000000"}, }, expectedSpanLinks: func() *ptrace.SpanLinkSlice { spanLinks := ptrace.NewSpanLinkSlice() @@ -926,15 +927,15 @@ func TestElasticSpanEnrich(t *testing.T) { }(), config: config.Enabled().Span, enrichedAttrs: map[string]any{ - AttributeTimestampUs: startTs.AsTime().UnixMicro(), - AttributeSpanName: "testspan", - AttributeProcessorEvent: "span", - AttributeSpanRepresentativeCount: float64(1), - AttributeSpanType: "genai", - AttributeSpanSubtype: "openai", - AttributeSpanDurationUs: expectedDuration.Microseconds(), - AttributeEventOutcome: "success", - AttributeSuccessCount: int64(1), + common.AttributeTimestampUs: startTs.AsTime().UnixMicro(), + common.AttributeSpanName: "testspan", + common.AttributeProcessorEvent: "span", + common.AttributeSpanRepresentativeCount: float64(1), + common.AttributeSpanType: "genai", + common.AttributeSpanSubtype: "openai", + common.AttributeSpanDurationUs: expectedDuration.Microseconds(), + common.AttributeEventOutcome: "success", + common.AttributeSuccessCount: int64(1), }, }, } { @@ -983,7 +984,7 @@ func TestSpanEventEnrich(t *testing.T) { config: config.Enabled().SpanEvent, errorID: false, // error ID is only present for exceptions enrichedAttrs: map[string]any{ - AttributeTimestampUs: ts.AsTime().UnixMicro(), + common.AttributeTimestampUs: ts.AsTime().UnixMicro(), }, }, { @@ -1005,17 +1006,17 @@ func TestSpanEventEnrich(t *testing.T) { config: config.Enabled().SpanEvent, errorID: true, enrichedAttrs: map[string]any{ - AttributeTimestampUs: ts.AsTime().UnixMicro(), - AttributeProcessorEvent: "error", - AttributeErrorExceptionHandled: true, - AttributeErrorGroupingKey: func() string { + common.AttributeTimestampUs: ts.AsTime().UnixMicro(), + common.AttributeProcessorEvent: "error", + common.AttributeErrorExceptionHandled: true, + common.AttributeErrorGroupingKey: func() string { hash := md5.New() hash.Write([]byte("java.net.ConnectionError")) return hex.EncodeToString(hash.Sum(nil)) }(), - AttributeErrorGroupingName: "something is wrong", - AttributeTransactionSampled: true, - AttributeTransactionType: "unknown", + common.AttributeErrorGroupingName: "something is wrong", + common.AttributeTransactionSampled: true, + common.AttributeTransactionType: "unknown", }, }, { @@ -1038,15 +1039,15 @@ func TestSpanEventEnrich(t *testing.T) { config: config.Enabled().SpanEvent, errorID: true, enrichedAttrs: map[string]any{ - AttributeTimestampUs: ts.AsTime().UnixMicro(), - AttributeProcessorEvent: "error", - AttributeErrorExceptionHandled: true, - AttributeErrorGroupingKey: func() string { + common.AttributeTimestampUs: ts.AsTime().UnixMicro(), + common.AttributeProcessorEvent: "error", + common.AttributeErrorExceptionHandled: true, + common.AttributeErrorGroupingKey: func() string { hash := md5.New() hash.Write([]byte("java.net.ConnectionError")) return hex.EncodeToString(hash.Sum(nil)) }(), - AttributeErrorGroupingName: "something is wrong", + common.AttributeErrorGroupingName: "something is wrong", }, }, } { @@ -1064,13 +1065,13 @@ func TestSpanEventEnrich(t *testing.T) { }) actual := tc.parent.Events().At(0).Attributes() - errorID, ok := actual.Get(AttributeErrorID) + errorID, ok := actual.Get(common.AttributeErrorID) assert.Equal(t, tc.errorID, ok, "error_id must be present for exception and must not be present for non-exception") if tc.errorID { assert.NotEmpty(t, errorID, "error_id must not be empty") } // Ignore error in actual diff since it is randomly generated - actual.Remove(AttributeErrorID) + actual.Remove(common.AttributeErrorID) assert.Empty(t, cmp.Diff(expectedAttrs, actual.AsRaw())) }) } diff --git a/go.mod b/go.mod index cd7e117..41f3a45 100644 --- a/go.mod +++ b/go.mod @@ -4,6 +4,7 @@ go 1.22.7 require ( github.com/elastic/go-elasticsearch/v8 v8.17.0 + github.com/elastic/opentelemetry-lib/common v0.1.0 github.com/google/go-cmp v0.6.0 github.com/open-telemetry/opentelemetry-collector-contrib/pkg/golden v0.117.0 github.com/open-telemetry/opentelemetry-collector-contrib/pkg/pdatatest v0.117.0 diff --git a/go.sum b/go.sum index 42281c5..6eb9ff9 100644 --- a/go.sum +++ b/go.sum @@ -8,6 +8,8 @@ github.com/elastic/elastic-transport-go/v8 v8.6.0/go.mod h1:YLHer5cj0csTzNFXoNQ8 github.com/elastic/go-elasticsearch/v8 v8.17.0 h1:e9cWksE/Fr7urDRmGPGp47Nsp4/mvNOrU8As1l2HQQ0= github.com/elastic/go-elasticsearch/v8 v8.17.0/go.mod h1:lGMlgKIbYoRvay3xWBeKahAiJOgmFDsjZC39nmO3H64= github.com/go-logr/logr v1.2.2/go.mod h1:jdQByPbusPIv2/zmleS9BjJVeZ6kBagPoEUsqbVz/1A= +github.com/elastic/opentelemetry-lib/common v0.1.0 h1:oZxb1CGzmc8md6Up0orgdc/2M1LpnGgjpvj50br/jE4= +github.com/elastic/opentelemetry-lib/common v0.1.0/go.mod h1:8uIzkjcq5I3ZEtblW+TOIJLJgj1t3VH+O/Uw1rqKPq4= github.com/go-logr/logr v1.4.2 h1:6pFjapn8bFcIbiKo3XT4j/BhANplGihG6tvd+8rYgrY= github.com/go-logr/logr v1.4.2/go.mod h1:9T104GzyrTigFIr8wt5mBrctHMim0Nb2HLGrmQ40KvY= github.com/go-logr/stdr v1.2.2 h1:hSWxHoqTgW2S2qGc0LTAI563KZ5YKYRhT3MFKZMbjag= From 3e1ba36cdd0625434c0a4af4d6b0c5becc593769 Mon Sep 17 00:00:00 2001 From: Greg Kalapos Date: Wed, 15 Jan 2025 18:39:19 +0100 Subject: [PATCH 3/8] rename common to elasticattributes --- common/attributes.go | 58 -- common/go.mod | 3 - elasticattributes/attributes.go | 58 ++ elasticattributes/go.mod | 3 + .../trace/internal/elastic/resource.go | 6 +- .../trace/internal/elastic/resource_test.go | 46 +- enrichments/trace/internal/elastic/scope.go | 6 +- .../trace/internal/elastic/scope_test.go | 10 +- enrichments/trace/internal/elastic/span.go | 64 +- .../trace/internal/elastic/span_test.go | 716 +++++++++--------- go.mod | 3 + 11 files changed, 488 insertions(+), 485 deletions(-) delete mode 100644 common/attributes.go delete mode 100644 common/go.mod create mode 100644 elasticattributes/attributes.go create mode 100644 elasticattributes/go.mod diff --git a/common/attributes.go b/common/attributes.go deleted file mode 100644 index 51abdc1..0000000 --- a/common/attributes.go +++ /dev/null @@ -1,58 +0,0 @@ -// Licensed to Elasticsearch B.V. under one or more contributor -// license agreements. See the NOTICE file distributed with -// this work for additional information regarding copyright -// ownership. Elasticsearch B.V. licenses this file to you under -// the Apache License, Version 2.0 (the "License"); you may -// not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, -// software distributed under the License is distributed on an -// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -// KIND, either express or implied. See the License for the -// specific language governing permissions and limitations -// under the License. - -package common - -const ( - // resource attributes - AttributeAgentName = "agent.name" - AttributeAgentVersion = "agent.version" - - // scope attributes - AttributeServiceFrameworkName = "service.framework.name" - AttributeServiceFrameworkVersion = "service.framework.version" - - // span attributes - AttributeTimestampUs = "timestamp.us" - AttributeProcessorEvent = "processor.event" - AttributeTransactionSampled = "transaction.sampled" - AttributeTransactionID = "transaction.id" - AttributeTransactionRoot = "transaction.root" - AttributeTransactionName = "transaction.name" - AttributeTransactionType = "transaction.type" - AttributeTransactionDurationUs = "transaction.duration.us" - AttributeTransactionResult = "transaction.result" - AttributeTransactionRepresentativeCount = "transaction.representative_count" - AttributeSpanName = "span.name" - AttributeSpanType = "span.type" - AttributeSpanSubtype = "span.subtype" - AttributeEventOutcome = "event.outcome" - AttributeSuccessCount = "event.success_count" - AttributeServiceTargetType = "service.target.type" - AttributeServiceTargetName = "service.target.name" - AttributeSpanDestinationServiceResource = "span.destination.service.resource" - AttributeSpanDurationUs = "span.duration.us" - AttributeSpanRepresentativeCount = "span.representative_count" - AttributeChildIDs = "child.id" - - // span event attributes - AttributeParentID = "parent.id" - AttributeErrorID = "error.id" - AttributeErrorExceptionHandled = "error.exception.handled" - AttributeErrorGroupingKey = "error.grouping_key" - AttributeErrorGroupingName = "error.grouping_name" -) diff --git a/common/go.mod b/common/go.mod deleted file mode 100644 index 5b049bb..0000000 --- a/common/go.mod +++ /dev/null @@ -1,3 +0,0 @@ -module github.com/elastic/opentelemetry-lib/common - -go 1.22.7 diff --git a/elasticattributes/attributes.go b/elasticattributes/attributes.go new file mode 100644 index 0000000..4d302e5 --- /dev/null +++ b/elasticattributes/attributes.go @@ -0,0 +1,58 @@ +// Licensed to Elasticsearch B.V. under one or more contributor +// license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright +// ownership. Elasticsearch B.V. licenses this file to you under +// the Apache License, Version 2.0 (the "License"); you may +// not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. + +package elasticattr + +const ( + // resource s + AgentName = "agent.name" + AgentVersion = "agent.version" + + // scope s + ServiceFrameworkName = "service.framework.name" + ServiceFrameworkVersion = "service.framework.version" + + // span s + TimestampUs = "timestamp.us" + ProcessorEvent = "processor.event" + TransactionSampled = "transaction.sampled" + TransactionID = "transaction.id" + TransactionRoot = "transaction.root" + TransactionName = "transaction.name" + TransactionType = "transaction.type" + TransactionDurationUs = "transaction.duration.us" + TransactionResult = "transaction.result" + TransactionRepresentativeCount = "transaction.representative_count" + SpanName = "span.name" + SpanType = "span.type" + SpanSubtype = "span.subtype" + EventOutcome = "event.outcome" + SuccessCount = "event.success_count" + ServiceTargetType = "service.target.type" + ServiceTargetName = "service.target.name" + SpanDestinationServiceResource = "span.destination.service.resource" + SpanDurationUs = "span.duration.us" + SpanRepresentativeCount = "span.representative_count" + ChildIDs = "child.id" + + // span event s + ParentID = "parent.id" + ErrorID = "error.id" + ErrorExceptionHandled = "error.exception.handled" + ErrorGroupingKey = "error.grouping_key" + ErrorGroupingName = "error.grouping_name" +) diff --git a/elasticattributes/go.mod b/elasticattributes/go.mod new file mode 100644 index 0000000..6c0d5e1 --- /dev/null +++ b/elasticattributes/go.mod @@ -0,0 +1,3 @@ +module github.com/elastic/opentelemetry-lib/elasticattributes + +go 1.22.7 diff --git a/enrichments/trace/internal/elastic/resource.go b/enrichments/trace/internal/elastic/resource.go index 8a19e8c..edb5766 100644 --- a/enrichments/trace/internal/elastic/resource.go +++ b/enrichments/trace/internal/elastic/resource.go @@ -20,7 +20,7 @@ package elastic import ( "fmt" - "github.com/elastic/opentelemetry-lib/common" + elasticattr "github.com/elastic/opentelemetry-lib/elasticattributes" "github.com/elastic/opentelemetry-lib/enrichments/trace/config" "go.opentelemetry.io/collector/pdata/pcommon" semconv "go.opentelemetry.io/collector/semconv/v1.25.0" @@ -100,7 +100,7 @@ func (s *resourceEnrichmentContext) setAgentName(resource pcommon.Resource) { ) } - resource.Attributes().PutStr(common.AttributeAgentName, agentName) + resource.Attributes().PutStr(elasticattr.AgentName, agentName) } func (s *resourceEnrichmentContext) setAgentVersion(resource pcommon.Resource) { @@ -115,7 +115,7 @@ func (s *resourceEnrichmentContext) setAgentVersion(resource pcommon.Resource) { case s.telemetrySDKVersion != "": agentVersion = s.telemetrySDKVersion } - resource.Attributes().PutStr(common.AttributeAgentVersion, agentVersion) + resource.Attributes().PutStr(elasticattr.AgentVersion, agentVersion) } func (s *resourceEnrichmentContext) overrideHostNameWithK8sNodeName(resource pcommon.Resource) { diff --git a/enrichments/trace/internal/elastic/resource_test.go b/enrichments/trace/internal/elastic/resource_test.go index 7dcdc8b..af4461c 100644 --- a/enrichments/trace/internal/elastic/resource_test.go +++ b/enrichments/trace/internal/elastic/resource_test.go @@ -20,7 +20,7 @@ package elastic import ( "testing" - "github.com/elastic/opentelemetry-lib/common" + elasticattr "github.com/elastic/opentelemetry-lib/elasticattributes" "github.com/elastic/opentelemetry-lib/enrichments/trace/config" "github.com/google/go-cmp/cmp" "github.com/stretchr/testify/assert" @@ -45,8 +45,8 @@ func TestResourceEnrich(t *testing.T) { input: pcommon.NewResource(), config: config.Enabled().Resource, enrichedAttrs: map[string]any{ - common.AttributeAgentName: "otlp", - common.AttributeAgentVersion: "unknown", + elasticattr.AgentName: "otlp", + elasticattr.AgentVersion: "unknown", }, }, { @@ -58,8 +58,8 @@ func TestResourceEnrich(t *testing.T) { }(), config: config.Enabled().Resource, enrichedAttrs: map[string]any{ - common.AttributeAgentName: "customflavor", - common.AttributeAgentVersion: "unknown", + elasticattr.AgentName: "customflavor", + elasticattr.AgentVersion: "unknown", }, }, { @@ -72,8 +72,8 @@ func TestResourceEnrich(t *testing.T) { }(), config: config.Enabled().Resource, enrichedAttrs: map[string]any{ - common.AttributeAgentName: "customflavor/unknown/elastic", - common.AttributeAgentVersion: "unknown", + elasticattr.AgentName: "customflavor/unknown/elastic", + elasticattr.AgentVersion: "unknown", }, }, { @@ -87,8 +87,8 @@ func TestResourceEnrich(t *testing.T) { }(), config: config.Enabled().Resource, enrichedAttrs: map[string]any{ - common.AttributeAgentName: "customflavor/cpp/elastic", - common.AttributeAgentVersion: "unknown", + elasticattr.AgentName: "customflavor/cpp/elastic", + elasticattr.AgentVersion: "unknown", }, }, { @@ -100,8 +100,8 @@ func TestResourceEnrich(t *testing.T) { }(), config: config.Enabled().Resource, enrichedAttrs: map[string]any{ - common.AttributeAgentName: "otlp/cpp", - common.AttributeAgentVersion: "unknown", + elasticattr.AgentName: "otlp/cpp", + elasticattr.AgentVersion: "unknown", }, }, { @@ -114,8 +114,8 @@ func TestResourceEnrich(t *testing.T) { }(), config: config.Enabled().Resource, enrichedAttrs: map[string]any{ - common.AttributeAgentName: "customflavor/cpp", - common.AttributeAgentVersion: "unknown", + elasticattr.AgentName: "customflavor/cpp", + elasticattr.AgentVersion: "unknown", }, }, { @@ -128,8 +128,8 @@ func TestResourceEnrich(t *testing.T) { }(), config: config.Enabled().Resource, enrichedAttrs: map[string]any{ - common.AttributeAgentName: "customflavor", - common.AttributeAgentVersion: "9.999.9", + elasticattr.AgentName: "customflavor", + elasticattr.AgentVersion: "9.999.9", }, }, { @@ -143,8 +143,8 @@ func TestResourceEnrich(t *testing.T) { }(), config: config.Enabled().Resource, enrichedAttrs: map[string]any{ - common.AttributeAgentName: "customflavor/unknown/elastic", - common.AttributeAgentVersion: "unknown", + elasticattr.AgentName: "customflavor/unknown/elastic", + elasticattr.AgentVersion: "unknown", }, }, { @@ -159,8 +159,8 @@ func TestResourceEnrich(t *testing.T) { }(), config: config.Enabled().Resource, enrichedAttrs: map[string]any{ - common.AttributeAgentName: "customflavor/unknown/elastic", - common.AttributeAgentVersion: "1.2.3", + elasticattr.AgentName: "customflavor/unknown/elastic", + elasticattr.AgentVersion: "1.2.3", }, }, { @@ -175,8 +175,8 @@ func TestResourceEnrich(t *testing.T) { enrichedAttrs: map[string]any{ semconv.AttributeHostName: "k8s-node", semconv.AttributeK8SNodeName: "k8s-node", - common.AttributeAgentName: "otlp", - common.AttributeAgentVersion: "unknown", + elasticattr.AgentName: "otlp", + elasticattr.AgentVersion: "unknown", }, }, { @@ -190,8 +190,8 @@ func TestResourceEnrich(t *testing.T) { enrichedAttrs: map[string]any{ semconv.AttributeHostName: "k8s-node", semconv.AttributeK8SNodeName: "k8s-node", - common.AttributeAgentName: "otlp", - common.AttributeAgentVersion: "unknown", + elasticattr.AgentName: "otlp", + elasticattr.AgentVersion: "unknown", }, }, } { diff --git a/enrichments/trace/internal/elastic/scope.go b/enrichments/trace/internal/elastic/scope.go index 647a32b..7265f73 100644 --- a/enrichments/trace/internal/elastic/scope.go +++ b/enrichments/trace/internal/elastic/scope.go @@ -18,7 +18,7 @@ package elastic import ( - "github.com/elastic/opentelemetry-lib/common" + elasticattr "github.com/elastic/opentelemetry-lib/elasticattributes" "github.com/elastic/opentelemetry-lib/enrichments/trace/config" "go.opentelemetry.io/collector/pdata/pcommon" ) @@ -28,8 +28,8 @@ func EnrichScope(scope pcommon.InstrumentationScope, cfg config.Config) { attrs := scope.Attributes() if cfg.Scope.ServiceFrameworkName.Enabled { if name := scope.Name(); name != "" { - attrs.PutStr(common.AttributeServiceFrameworkName, name) - attrs.PutStr(common.AttributeServiceFrameworkVersion, scope.Version()) + attrs.PutStr(elasticattr.ServiceFrameworkName, name) + attrs.PutStr(elasticattr.ServiceFrameworkVersion, scope.Version()) } } } diff --git a/enrichments/trace/internal/elastic/scope_test.go b/enrichments/trace/internal/elastic/scope_test.go index f6c46cd..cfcdbd9 100644 --- a/enrichments/trace/internal/elastic/scope_test.go +++ b/enrichments/trace/internal/elastic/scope_test.go @@ -20,7 +20,7 @@ package elastic import ( "testing" - "github.com/elastic/opentelemetry-lib/common" + elasticattr "github.com/elastic/opentelemetry-lib/elasticattributes" "github.com/elastic/opentelemetry-lib/enrichments/trace/config" "github.com/google/go-cmp/cmp" "github.com/stretchr/testify/assert" @@ -48,8 +48,8 @@ func TestScopeEnrich(t *testing.T) { }(), config: config.Enabled().Scope, enrichedAttrs: map[string]any{ - common.AttributeServiceFrameworkName: "test", - common.AttributeServiceFrameworkVersion: "", + elasticattr.ServiceFrameworkName: "test", + elasticattr.ServiceFrameworkVersion: "", }, }, { @@ -62,8 +62,8 @@ func TestScopeEnrich(t *testing.T) { }(), config: config.Enabled().Scope, enrichedAttrs: map[string]any{ - common.AttributeServiceFrameworkName: "test", - common.AttributeServiceFrameworkVersion: "v1.0.0", + elasticattr.ServiceFrameworkName: "test", + elasticattr.ServiceFrameworkVersion: "v1.0.0", }, }, } { diff --git a/enrichments/trace/internal/elastic/span.go b/enrichments/trace/internal/elastic/span.go index d8b5b6a..7c8b3f5 100644 --- a/enrichments/trace/internal/elastic/span.go +++ b/enrichments/trace/internal/elastic/span.go @@ -30,7 +30,7 @@ import ( "strconv" "strings" - "github.com/elastic/opentelemetry-lib/common" + elasticattr "github.com/elastic/opentelemetry-lib/elasticattributes" "github.com/elastic/opentelemetry-lib/enrichments/trace/config" "go.opentelemetry.io/collector/pdata/pcommon" "go.opentelemetry.io/collector/pdata/ptrace" @@ -206,32 +206,32 @@ func (s *spanEnrichmentContext) enrichTransaction( cfg config.ElasticTransactionConfig, ) { if cfg.TimestampUs.Enabled { - span.Attributes().PutInt(common.AttributeTimestampUs, getTimestampUs(span.StartTimestamp())) + span.Attributes().PutInt(elasticattr.TimestampUs, getTimestampUs(span.StartTimestamp())) } if cfg.Sampled.Enabled { - span.Attributes().PutBool(common.AttributeTransactionSampled, s.getSampled()) + span.Attributes().PutBool(elasticattr.TransactionSampled, s.getSampled()) } if cfg.ID.Enabled { - span.Attributes().PutStr(common.AttributeTransactionID, span.SpanID().String()) + span.Attributes().PutStr(elasticattr.TransactionID, span.SpanID().String()) } if cfg.Root.Enabled { - span.Attributes().PutBool(common.AttributeTransactionRoot, isTraceRoot(span)) + span.Attributes().PutBool(elasticattr.TransactionRoot, isTraceRoot(span)) } if cfg.Name.Enabled { - span.Attributes().PutStr(common.AttributeTransactionName, span.Name()) + span.Attributes().PutStr(elasticattr.TransactionName, span.Name()) } if cfg.ProcessorEvent.Enabled { - span.Attributes().PutStr(common.AttributeProcessorEvent, "transaction") + span.Attributes().PutStr(elasticattr.ProcessorEvent, "transaction") } if cfg.RepresentativeCount.Enabled { repCount := getRepresentativeCount(span.TraceState().AsRaw()) - span.Attributes().PutDouble(common.AttributeTransactionRepresentativeCount, repCount) + span.Attributes().PutDouble(elasticattr.TransactionRepresentativeCount, repCount) } if cfg.DurationUs.Enabled { - span.Attributes().PutInt(common.AttributeTransactionDurationUs, getDurationUs(span)) + span.Attributes().PutInt(elasticattr.TransactionDurationUs, getDurationUs(span)) } if cfg.Type.Enabled { - span.Attributes().PutStr(common.AttributeTransactionType, s.getTxnType()) + span.Attributes().PutStr(elasticattr.TransactionType, s.getTxnType()) } if cfg.Result.Enabled { s.setTxnResult(span) @@ -249,17 +249,17 @@ func (s *spanEnrichmentContext) enrichSpan( cfg config.ElasticSpanConfig, ) { if cfg.TimestampUs.Enabled { - span.Attributes().PutInt(common.AttributeTimestampUs, getTimestampUs(span.StartTimestamp())) + span.Attributes().PutInt(elasticattr.TimestampUs, getTimestampUs(span.StartTimestamp())) } if cfg.Name.Enabled { - span.Attributes().PutStr(common.AttributeSpanName, span.Name()) + span.Attributes().PutStr(elasticattr.SpanName, span.Name()) } if cfg.ProcessorEvent.Enabled { - span.Attributes().PutStr(common.AttributeProcessorEvent, "span") + span.Attributes().PutStr(elasticattr.ProcessorEvent, "span") } if cfg.RepresentativeCount.Enabled { repCount := getRepresentativeCount(span.TraceState().AsRaw()) - span.Attributes().PutDouble(common.AttributeSpanRepresentativeCount, repCount) + span.Attributes().PutDouble(elasticattr.SpanRepresentativeCount, repCount) } if cfg.TypeSubtype.Enabled { s.setSpanTypeSubtype(span) @@ -268,7 +268,7 @@ func (s *spanEnrichmentContext) enrichSpan( s.setEventOutcome(span) } if cfg.DurationUs.Enabled { - span.Attributes().PutInt(common.AttributeSpanDurationUs, getDurationUs(span)) + span.Attributes().PutInt(elasticattr.SpanDurationUs, getDurationUs(span)) } if cfg.ServiceTarget.Enabled { s.setServiceTarget(span) @@ -329,7 +329,7 @@ func (s *spanEnrichmentContext) setTxnResult(span ptrace.Span) { } } - span.Attributes().PutStr(common.AttributeTransactionResult, result) + span.Attributes().PutStr(elasticattr.TransactionResult, result) } func (s *spanEnrichmentContext) setEventOutcome(span ptrace.Span) { @@ -348,8 +348,8 @@ func (s *spanEnrichmentContext) setEventOutcome(span ptrace.Span) { outcome = "failure" successCount = 0 } - span.Attributes().PutStr(common.AttributeEventOutcome, outcome) - span.Attributes().PutInt(common.AttributeSuccessCount, int64(successCount)) + span.Attributes().PutStr(elasticattr.EventOutcome, outcome) + span.Attributes().PutInt(elasticattr.SuccessCount, int64(successCount)) } func (s *spanEnrichmentContext) setSpanTypeSubtype(span ptrace.Span) { @@ -381,9 +381,9 @@ func (s *spanEnrichmentContext) setSpanTypeSubtype(span ptrace.Span) { } } - span.Attributes().PutStr(common.AttributeSpanType, spanType) + span.Attributes().PutStr(elasticattr.SpanType, spanType) if spanSubtype != "" { - span.Attributes().PutStr(common.AttributeSpanSubtype, spanSubtype) + span.Attributes().PutStr(elasticattr.SpanSubtype, spanSubtype) } } @@ -430,8 +430,8 @@ func (s *spanEnrichmentContext) setServiceTarget(span ptrace.Span) { } if targetType != "" || targetName != "" { - span.Attributes().PutStr(common.AttributeServiceTargetType, targetType) - span.Attributes().PutStr(common.AttributeServiceTargetName, targetName) + span.Attributes().PutStr(elasticattr.ServiceTargetType, targetType) + span.Attributes().PutStr(elasticattr.ServiceTargetName, targetName) } } @@ -468,7 +468,7 @@ func (s *spanEnrichmentContext) setDestinationService(span ptrace.Span) { } if destnResource != "" { - span.Attributes().PutStr(common.AttributeSpanDestinationServiceResource, destnResource) + span.Attributes().PutStr(elasticattr.SpanDestinationServiceResource, destnResource) } } @@ -492,7 +492,7 @@ func (s *spanEnrichmentContext) setInferredSpans(span ptrace.Span) { }) if childIDs.Len() > 0 { - childIDs.MoveAndAppendTo(span.Attributes().PutEmptySlice(common.AttributeChildIDs)) + childIDs.MoveAndAppendTo(span.Attributes().PutEmptySlice(elasticattr.ChildIDs)) } } @@ -527,10 +527,10 @@ func (s *spanEventEnrichmentContext) enrich( // Enrich span event attributes. if cfg.TimestampUs.Enabled { - se.Attributes().PutInt(common.AttributeTimestampUs, getTimestampUs(se.Timestamp())) + se.Attributes().PutInt(elasticattr.TimestampUs, getTimestampUs(se.Timestamp())) } if cfg.ProcessorEvent.Enabled && s.exception { - se.Attributes().PutStr(common.AttributeProcessorEvent, "error") + se.Attributes().PutStr(elasticattr.ProcessorEvent, "error") } if s.exceptionType == "" && s.exceptionMessage == "" { // Span event does not represent an exception @@ -540,11 +540,11 @@ func (s *spanEventEnrichmentContext) enrich( // Span event represents exception if cfg.ErrorID.Enabled { if id, err := newUniqueID(); err == nil { - se.Attributes().PutStr(common.AttributeErrorID, id) + se.Attributes().PutStr(elasticattr.ErrorID, id) } } if cfg.ErrorExceptionHandled.Enabled { - se.Attributes().PutBool(common.AttributeErrorExceptionHandled, !s.exceptionEscaped) + se.Attributes().PutBool(elasticattr.ErrorExceptionHandled, !s.exceptionEscaped) } if cfg.ErrorGroupingKey.Enabled { // See https://github.com/elastic/apm-data/issues/299 @@ -555,21 +555,21 @@ func (s *spanEventEnrichmentContext) enrich( } else if s.exceptionMessage != "" { io.WriteString(hash, s.exceptionMessage) } - se.Attributes().PutStr(common.AttributeErrorGroupingKey, hex.EncodeToString(hash.Sum(nil))) + se.Attributes().PutStr(elasticattr.ErrorGroupingKey, hex.EncodeToString(hash.Sum(nil))) } if cfg.ErrorGroupingName.Enabled { if s.exceptionMessage != "" { - se.Attributes().PutStr(common.AttributeErrorGroupingName, s.exceptionMessage) + se.Attributes().PutStr(elasticattr.ErrorGroupingName, s.exceptionMessage) } } // Transaction type and sampled are added as span event enrichment only for errors if parentCtx.isTransaction && s.exception { if cfg.TransactionSampled.Enabled { - se.Attributes().PutBool(common.AttributeTransactionSampled, parentCtx.getSampled()) + se.Attributes().PutBool(elasticattr.TransactionSampled, parentCtx.getSampled()) } if cfg.TransactionType.Enabled { - se.Attributes().PutStr(common.AttributeTransactionType, parentCtx.getTxnType()) + se.Attributes().PutStr(elasticattr.TransactionType, parentCtx.getTxnType()) } } } diff --git a/enrichments/trace/internal/elastic/span_test.go b/enrichments/trace/internal/elastic/span_test.go index a80cae7..a6d7942 100644 --- a/enrichments/trace/internal/elastic/span_test.go +++ b/enrichments/trace/internal/elastic/span_test.go @@ -24,7 +24,7 @@ import ( "testing" "time" - "github.com/elastic/opentelemetry-lib/common" + elasticattr "github.com/elastic/opentelemetry-lib/elasticattributes" "github.com/elastic/opentelemetry-lib/enrichments/trace/config" "github.com/google/go-cmp/cmp" "github.com/open-telemetry/opentelemetry-collector-contrib/pkg/pdatatest/ptracetest" @@ -63,18 +63,18 @@ func TestElasticTransactionEnrich(t *testing.T) { input: ptrace.NewSpan(), config: config.Enabled().Transaction, enrichedAttrs: map[string]any{ - common.AttributeTimestampUs: int64(0), - common.AttributeTransactionSampled: true, - common.AttributeTransactionRoot: true, - common.AttributeTransactionID: "", - common.AttributeTransactionName: "", - common.AttributeProcessorEvent: "transaction", - common.AttributeTransactionRepresentativeCount: float64(1), - common.AttributeTransactionDurationUs: int64(0), - common.AttributeEventOutcome: "success", - common.AttributeSuccessCount: int64(1), - common.AttributeTransactionResult: "Success", - common.AttributeTransactionType: "unknown", + elasticattr.TimestampUs: int64(0), + elasticattr.TransactionSampled: true, + elasticattr.TransactionRoot: true, + elasticattr.TransactionID: "", + elasticattr.TransactionName: "", + elasticattr.ProcessorEvent: "transaction", + elasticattr.TransactionRepresentativeCount: float64(1), + elasticattr.TransactionDurationUs: int64(0), + elasticattr.EventOutcome: "success", + elasticattr.SuccessCount: int64(1), + elasticattr.TransactionResult: "Success", + elasticattr.TransactionType: "unknown", }, }, { @@ -91,18 +91,18 @@ func TestElasticTransactionEnrich(t *testing.T) { }(), config: config.Enabled().Transaction, enrichedAttrs: map[string]any{ - common.AttributeTimestampUs: int64(0), - common.AttributeTransactionSampled: true, - common.AttributeTransactionRoot: true, - common.AttributeTransactionID: "", - common.AttributeTransactionName: "", - common.AttributeProcessorEvent: "transaction", - common.AttributeTransactionRepresentativeCount: float64(256), - common.AttributeTransactionDurationUs: int64(0), - common.AttributeEventOutcome: "success", - common.AttributeSuccessCount: int64(256), - common.AttributeTransactionResult: "Success", - common.AttributeTransactionType: "unknown", + elasticattr.TimestampUs: int64(0), + elasticattr.TransactionSampled: true, + elasticattr.TransactionRoot: true, + elasticattr.TransactionID: "", + elasticattr.TransactionName: "", + elasticattr.ProcessorEvent: "transaction", + elasticattr.TransactionRepresentativeCount: float64(256), + elasticattr.TransactionDurationUs: int64(0), + elasticattr.EventOutcome: "success", + elasticattr.SuccessCount: int64(256), + elasticattr.TransactionResult: "Success", + elasticattr.TransactionType: "unknown", }, }, { @@ -115,18 +115,18 @@ func TestElasticTransactionEnrich(t *testing.T) { }(), config: config.Enabled().Transaction, enrichedAttrs: map[string]any{ - common.AttributeTimestampUs: startTs.AsTime().UnixMicro(), - common.AttributeTransactionSampled: true, - common.AttributeTransactionRoot: true, - common.AttributeTransactionID: "0100000000000000", - common.AttributeTransactionName: "testtxn", - common.AttributeProcessorEvent: "transaction", - common.AttributeTransactionRepresentativeCount: float64(1), - common.AttributeTransactionDurationUs: expectedDuration.Microseconds(), - common.AttributeEventOutcome: "success", - common.AttributeSuccessCount: int64(1), - common.AttributeTransactionResult: "HTTP 2xx", - common.AttributeTransactionType: "request", + elasticattr.TimestampUs: startTs.AsTime().UnixMicro(), + elasticattr.TransactionSampled: true, + elasticattr.TransactionRoot: true, + elasticattr.TransactionID: "0100000000000000", + elasticattr.TransactionName: "testtxn", + elasticattr.ProcessorEvent: "transaction", + elasticattr.TransactionRepresentativeCount: float64(1), + elasticattr.TransactionDurationUs: expectedDuration.Microseconds(), + elasticattr.EventOutcome: "success", + elasticattr.SuccessCount: int64(1), + elasticattr.TransactionResult: "HTTP 2xx", + elasticattr.TransactionType: "request", }, }, { @@ -145,18 +145,18 @@ func TestElasticTransactionEnrich(t *testing.T) { }(), config: config.Enabled().Transaction, enrichedAttrs: map[string]any{ - common.AttributeTimestampUs: startTs.AsTime().UnixMicro(), - common.AttributeTransactionSampled: true, - common.AttributeTransactionRoot: true, - common.AttributeTransactionID: "0100000000000000", - common.AttributeTransactionName: "testtxn", - common.AttributeProcessorEvent: "transaction", - common.AttributeTransactionRepresentativeCount: float64(1), - common.AttributeTransactionDurationUs: expectedDuration.Microseconds(), - common.AttributeEventOutcome: "success", - common.AttributeSuccessCount: int64(1), - common.AttributeTransactionResult: "HTTP 1xx", - common.AttributeTransactionType: "request", + elasticattr.TimestampUs: startTs.AsTime().UnixMicro(), + elasticattr.TransactionSampled: true, + elasticattr.TransactionRoot: true, + elasticattr.TransactionID: "0100000000000000", + elasticattr.TransactionName: "testtxn", + elasticattr.ProcessorEvent: "transaction", + elasticattr.TransactionRepresentativeCount: float64(1), + elasticattr.TransactionDurationUs: expectedDuration.Microseconds(), + elasticattr.EventOutcome: "success", + elasticattr.SuccessCount: int64(1), + elasticattr.TransactionResult: "HTTP 1xx", + elasticattr.TransactionType: "request", }, }, { @@ -174,18 +174,18 @@ func TestElasticTransactionEnrich(t *testing.T) { }(), config: config.Enabled().Transaction, enrichedAttrs: map[string]any{ - common.AttributeTimestampUs: startTs.AsTime().UnixMicro(), - common.AttributeTransactionSampled: true, - common.AttributeTransactionRoot: true, - common.AttributeTransactionID: "0100000000000000", - common.AttributeTransactionName: "testtxn", - common.AttributeProcessorEvent: "transaction", - common.AttributeTransactionRepresentativeCount: float64(1), - common.AttributeTransactionDurationUs: expectedDuration.Microseconds(), - common.AttributeEventOutcome: "success", - common.AttributeSuccessCount: int64(1), - common.AttributeTransactionResult: "HTTP 5xx", - common.AttributeTransactionType: "request", + elasticattr.TimestampUs: startTs.AsTime().UnixMicro(), + elasticattr.TransactionSampled: true, + elasticattr.TransactionRoot: true, + elasticattr.TransactionID: "0100000000000000", + elasticattr.TransactionName: "testtxn", + elasticattr.ProcessorEvent: "transaction", + elasticattr.TransactionRepresentativeCount: float64(1), + elasticattr.TransactionDurationUs: expectedDuration.Microseconds(), + elasticattr.EventOutcome: "success", + elasticattr.SuccessCount: int64(1), + elasticattr.TransactionResult: "HTTP 5xx", + elasticattr.TransactionType: "request", }, }, { @@ -204,18 +204,18 @@ func TestElasticTransactionEnrich(t *testing.T) { }(), config: config.Enabled().Transaction, enrichedAttrs: map[string]any{ - common.AttributeTimestampUs: startTs.AsTime().UnixMicro(), - common.AttributeTransactionSampled: true, - common.AttributeTransactionRoot: true, - common.AttributeTransactionID: "0100000000000000", - common.AttributeTransactionName: "testtxn", - common.AttributeProcessorEvent: "transaction", - common.AttributeTransactionRepresentativeCount: float64(1), - common.AttributeTransactionDurationUs: expectedDuration.Microseconds(), - common.AttributeEventOutcome: "success", - common.AttributeSuccessCount: int64(1), - common.AttributeTransactionResult: "OK", - common.AttributeTransactionType: "request", + elasticattr.TimestampUs: startTs.AsTime().UnixMicro(), + elasticattr.TransactionSampled: true, + elasticattr.TransactionRoot: true, + elasticattr.TransactionID: "0100000000000000", + elasticattr.TransactionName: "testtxn", + elasticattr.ProcessorEvent: "transaction", + elasticattr.TransactionRepresentativeCount: float64(1), + elasticattr.TransactionDurationUs: expectedDuration.Microseconds(), + elasticattr.EventOutcome: "success", + elasticattr.SuccessCount: int64(1), + elasticattr.TransactionResult: "OK", + elasticattr.TransactionType: "request", }, }, { @@ -234,18 +234,18 @@ func TestElasticTransactionEnrich(t *testing.T) { }(), config: config.Enabled().Transaction, enrichedAttrs: map[string]any{ - common.AttributeTimestampUs: startTs.AsTime().UnixMicro(), - common.AttributeTransactionSampled: true, - common.AttributeTransactionRoot: true, - common.AttributeTransactionID: "0100000000000000", - common.AttributeTransactionName: "testtxn", - common.AttributeProcessorEvent: "transaction", - common.AttributeTransactionRepresentativeCount: float64(1), - common.AttributeTransactionDurationUs: expectedDuration.Microseconds(), - common.AttributeEventOutcome: "success", - common.AttributeSuccessCount: int64(1), - common.AttributeTransactionResult: "Internal", - common.AttributeTransactionType: "request", + elasticattr.TimestampUs: startTs.AsTime().UnixMicro(), + elasticattr.TransactionSampled: true, + elasticattr.TransactionRoot: true, + elasticattr.TransactionID: "0100000000000000", + elasticattr.TransactionName: "testtxn", + elasticattr.ProcessorEvent: "transaction", + elasticattr.TransactionRepresentativeCount: float64(1), + elasticattr.TransactionDurationUs: expectedDuration.Microseconds(), + elasticattr.EventOutcome: "success", + elasticattr.SuccessCount: int64(1), + elasticattr.TransactionResult: "Internal", + elasticattr.TransactionType: "request", }, }, { @@ -259,18 +259,18 @@ func TestElasticTransactionEnrich(t *testing.T) { }(), config: config.Enabled().Transaction, enrichedAttrs: map[string]any{ - common.AttributeTimestampUs: startTs.AsTime().UnixMicro(), - common.AttributeTransactionSampled: true, - common.AttributeTransactionRoot: true, - common.AttributeTransactionID: "0100000000000000", - common.AttributeTransactionName: "testtxn", - common.AttributeProcessorEvent: "transaction", - common.AttributeTransactionRepresentativeCount: float64(1), - common.AttributeTransactionDurationUs: expectedDuration.Microseconds(), - common.AttributeEventOutcome: "success", - common.AttributeSuccessCount: int64(1), - common.AttributeTransactionResult: "Success", - common.AttributeTransactionType: "unknown", + elasticattr.TimestampUs: startTs.AsTime().UnixMicro(), + elasticattr.TransactionSampled: true, + elasticattr.TransactionRoot: true, + elasticattr.TransactionID: "0100000000000000", + elasticattr.TransactionName: "testtxn", + elasticattr.ProcessorEvent: "transaction", + elasticattr.TransactionRepresentativeCount: float64(1), + elasticattr.TransactionDurationUs: expectedDuration.Microseconds(), + elasticattr.EventOutcome: "success", + elasticattr.SuccessCount: int64(1), + elasticattr.TransactionResult: "Success", + elasticattr.TransactionType: "unknown", }, }, { @@ -284,18 +284,18 @@ func TestElasticTransactionEnrich(t *testing.T) { }(), config: config.Enabled().Transaction, enrichedAttrs: map[string]any{ - common.AttributeTimestampUs: startTs.AsTime().UnixMicro(), - common.AttributeTransactionSampled: true, - common.AttributeTransactionRoot: true, - common.AttributeTransactionID: "0100000000000000", - common.AttributeTransactionName: "testtxn", - common.AttributeProcessorEvent: "transaction", - common.AttributeTransactionRepresentativeCount: float64(1), - common.AttributeTransactionDurationUs: expectedDuration.Microseconds(), - common.AttributeEventOutcome: "failure", - common.AttributeSuccessCount: int64(0), - common.AttributeTransactionResult: "Error", - common.AttributeTransactionType: "unknown", + elasticattr.TimestampUs: startTs.AsTime().UnixMicro(), + elasticattr.TransactionSampled: true, + elasticattr.TransactionRoot: true, + elasticattr.TransactionID: "0100000000000000", + elasticattr.TransactionName: "testtxn", + elasticattr.ProcessorEvent: "transaction", + elasticattr.TransactionRepresentativeCount: float64(1), + elasticattr.TransactionDurationUs: expectedDuration.Microseconds(), + elasticattr.EventOutcome: "failure", + elasticattr.SuccessCount: int64(0), + elasticattr.TransactionResult: "Error", + elasticattr.TransactionType: "unknown", }, }, { @@ -309,18 +309,18 @@ func TestElasticTransactionEnrich(t *testing.T) { }(), config: config.Enabled().Transaction, enrichedAttrs: map[string]any{ - common.AttributeTimestampUs: startTs.AsTime().UnixMicro(), - common.AttributeTransactionSampled: true, - common.AttributeTransactionRoot: true, - common.AttributeTransactionID: "0100000000000000", - common.AttributeTransactionName: "testtxn", - common.AttributeProcessorEvent: "transaction", - common.AttributeTransactionRepresentativeCount: float64(1), - common.AttributeTransactionDurationUs: expectedDuration.Microseconds(), - common.AttributeEventOutcome: "success", - common.AttributeSuccessCount: int64(1), - common.AttributeTransactionResult: "Success", - common.AttributeTransactionType: "messaging", + elasticattr.TimestampUs: startTs.AsTime().UnixMicro(), + elasticattr.TransactionSampled: true, + elasticattr.TransactionRoot: true, + elasticattr.TransactionID: "0100000000000000", + elasticattr.TransactionName: "testtxn", + elasticattr.ProcessorEvent: "transaction", + elasticattr.TransactionRepresentativeCount: float64(1), + elasticattr.TransactionDurationUs: expectedDuration.Microseconds(), + elasticattr.EventOutcome: "success", + elasticattr.SuccessCount: int64(1), + elasticattr.TransactionResult: "Success", + elasticattr.TransactionType: "messaging", }, }, { @@ -343,19 +343,19 @@ func TestElasticTransactionEnrich(t *testing.T) { }(), config: config.Enabled().Transaction, enrichedAttrs: map[string]any{ - common.AttributeTimestampUs: startTs.AsTime().UnixMicro(), - common.AttributeTransactionSampled: true, - common.AttributeTransactionRoot: true, - common.AttributeTransactionID: "0100000000000000", - common.AttributeTransactionName: "testtxn", - common.AttributeProcessorEvent: "transaction", - common.AttributeTransactionRepresentativeCount: float64(1), - common.AttributeTransactionDurationUs: expectedDuration.Microseconds(), - common.AttributeEventOutcome: "success", - common.AttributeSuccessCount: int64(1), - common.AttributeTransactionResult: "Success", - common.AttributeTransactionType: "unknown", - common.AttributeChildIDs: []any{"0300000000000000", "0400000000000000"}, + elasticattr.TimestampUs: startTs.AsTime().UnixMicro(), + elasticattr.TransactionSampled: true, + elasticattr.TransactionRoot: true, + elasticattr.TransactionID: "0100000000000000", + elasticattr.TransactionName: "testtxn", + elasticattr.ProcessorEvent: "transaction", + elasticattr.TransactionRepresentativeCount: float64(1), + elasticattr.TransactionDurationUs: expectedDuration.Microseconds(), + elasticattr.EventOutcome: "success", + elasticattr.SuccessCount: int64(1), + elasticattr.TransactionResult: "Success", + elasticattr.TransactionType: "unknown", + elasticattr.ChildIDs: []any{"0300000000000000", "0400000000000000"}, }, expectedSpanLinks: func() *ptrace.SpanLinkSlice { spanLinks := ptrace.NewSpanLinkSlice() @@ -418,14 +418,14 @@ func TestElasticSpanEnrich(t *testing.T) { }(), config: config.Enabled().Span, enrichedAttrs: map[string]any{ - common.AttributeTimestampUs: int64(0), - common.AttributeSpanName: "", - common.AttributeProcessorEvent: "span", - common.AttributeSpanRepresentativeCount: float64(1), - common.AttributeSpanType: "unknown", - common.AttributeSpanDurationUs: int64(0), - common.AttributeEventOutcome: "success", - common.AttributeSuccessCount: int64(1), + elasticattr.TimestampUs: int64(0), + elasticattr.SpanName: "", + elasticattr.ProcessorEvent: "span", + elasticattr.SpanRepresentativeCount: float64(1), + elasticattr.SpanType: "unknown", + elasticattr.SpanDurationUs: int64(0), + elasticattr.EventOutcome: "success", + elasticattr.SuccessCount: int64(1), }, }, { @@ -443,15 +443,15 @@ func TestElasticSpanEnrich(t *testing.T) { }(), config: config.Enabled().Span, enrichedAttrs: map[string]any{ - common.AttributeTimestampUs: int64(0), - common.AttributeSpanName: "", - common.AttributeProcessorEvent: "span", - common.AttributeSpanRepresentativeCount: float64(1), - common.AttributeSpanType: "app", - common.AttributeSpanSubtype: "internal", - common.AttributeSpanDurationUs: int64(0), - common.AttributeEventOutcome: "success", - common.AttributeSuccessCount: int64(1), + elasticattr.TimestampUs: int64(0), + elasticattr.SpanName: "", + elasticattr.ProcessorEvent: "span", + elasticattr.SpanRepresentativeCount: float64(1), + elasticattr.SpanType: "app", + elasticattr.SpanSubtype: "internal", + elasticattr.SpanDurationUs: int64(0), + elasticattr.EventOutcome: "success", + elasticattr.SuccessCount: int64(1), }, }, { @@ -464,17 +464,17 @@ func TestElasticSpanEnrich(t *testing.T) { }(), config: config.Enabled().Span, enrichedAttrs: map[string]any{ - common.AttributeTimestampUs: startTs.AsTime().UnixMicro(), - common.AttributeSpanName: "testspan", - common.AttributeProcessorEvent: "span", - common.AttributeSpanRepresentativeCount: float64(1), - common.AttributeSpanType: "unknown", - common.AttributeSpanDurationUs: expectedDuration.Microseconds(), - common.AttributeEventOutcome: "success", - common.AttributeSuccessCount: int64(1), - common.AttributeServiceTargetName: "testsvc", - common.AttributeServiceTargetType: "", - common.AttributeSpanDestinationServiceResource: "testsvc", + elasticattr.TimestampUs: startTs.AsTime().UnixMicro(), + elasticattr.SpanName: "testspan", + elasticattr.ProcessorEvent: "span", + elasticattr.SpanRepresentativeCount: float64(1), + elasticattr.SpanType: "unknown", + elasticattr.SpanDurationUs: expectedDuration.Microseconds(), + elasticattr.EventOutcome: "success", + elasticattr.SuccessCount: int64(1), + elasticattr.ServiceTargetName: "testsvc", + elasticattr.ServiceTargetType: "", + elasticattr.SpanDestinationServiceResource: "testsvc", }, }, { @@ -491,18 +491,18 @@ func TestElasticSpanEnrich(t *testing.T) { }(), config: config.Enabled().Span, enrichedAttrs: map[string]any{ - common.AttributeTimestampUs: startTs.AsTime().UnixMicro(), - common.AttributeSpanName: "testspan", - common.AttributeProcessorEvent: "span", - common.AttributeSpanRepresentativeCount: float64(1), - common.AttributeSpanType: "external", - common.AttributeSpanSubtype: "http", - common.AttributeSpanDurationUs: expectedDuration.Microseconds(), - common.AttributeEventOutcome: "success", - common.AttributeSuccessCount: int64(1), - common.AttributeServiceTargetType: "http", - common.AttributeServiceTargetName: "testsvc", - common.AttributeSpanDestinationServiceResource: "testsvc", + elasticattr.TimestampUs: startTs.AsTime().UnixMicro(), + elasticattr.SpanName: "testspan", + elasticattr.ProcessorEvent: "span", + elasticattr.SpanRepresentativeCount: float64(1), + elasticattr.SpanType: "external", + elasticattr.SpanSubtype: "http", + elasticattr.SpanDurationUs: expectedDuration.Microseconds(), + elasticattr.EventOutcome: "success", + elasticattr.SuccessCount: int64(1), + elasticattr.ServiceTargetType: "http", + elasticattr.ServiceTargetName: "testsvc", + elasticattr.SpanDestinationServiceResource: "testsvc", }, }, { @@ -525,18 +525,18 @@ func TestElasticSpanEnrich(t *testing.T) { }(), config: config.Enabled().Span, enrichedAttrs: map[string]any{ - common.AttributeTimestampUs: startTs.AsTime().UnixMicro(), - common.AttributeSpanName: "testspan", - common.AttributeProcessorEvent: "span", - common.AttributeSpanRepresentativeCount: float64(1), - common.AttributeSpanType: "external", - common.AttributeSpanSubtype: "http", - common.AttributeSpanDurationUs: expectedDuration.Microseconds(), - common.AttributeEventOutcome: "success", - common.AttributeSuccessCount: int64(1), - common.AttributeServiceTargetType: "http", - common.AttributeServiceTargetName: "www.foo.bar:443", - common.AttributeSpanDestinationServiceResource: "testsvc", + elasticattr.TimestampUs: startTs.AsTime().UnixMicro(), + elasticattr.SpanName: "testspan", + elasticattr.ProcessorEvent: "span", + elasticattr.SpanRepresentativeCount: float64(1), + elasticattr.SpanType: "external", + elasticattr.SpanSubtype: "http", + elasticattr.SpanDurationUs: expectedDuration.Microseconds(), + elasticattr.EventOutcome: "success", + elasticattr.SuccessCount: int64(1), + elasticattr.ServiceTargetType: "http", + elasticattr.ServiceTargetName: "www.foo.bar:443", + elasticattr.SpanDestinationServiceResource: "testsvc", }, }, { @@ -559,18 +559,18 @@ func TestElasticSpanEnrich(t *testing.T) { }(), config: config.Enabled().Span, enrichedAttrs: map[string]any{ - common.AttributeTimestampUs: startTs.AsTime().UnixMicro(), - common.AttributeSpanName: "testspan", - common.AttributeProcessorEvent: "span", - common.AttributeSpanRepresentativeCount: float64(1), - common.AttributeSpanType: "external", - common.AttributeSpanSubtype: "http", - common.AttributeSpanDurationUs: expectedDuration.Microseconds(), - common.AttributeEventOutcome: "success", - common.AttributeSuccessCount: int64(1), - common.AttributeServiceTargetType: "http", - common.AttributeServiceTargetName: "www.foo.bar:443", - common.AttributeSpanDestinationServiceResource: "testsvc", + elasticattr.TimestampUs: startTs.AsTime().UnixMicro(), + elasticattr.SpanName: "testspan", + elasticattr.ProcessorEvent: "span", + elasticattr.SpanRepresentativeCount: float64(1), + elasticattr.SpanType: "external", + elasticattr.SpanSubtype: "http", + elasticattr.SpanDurationUs: expectedDuration.Microseconds(), + elasticattr.EventOutcome: "success", + elasticattr.SuccessCount: int64(1), + elasticattr.ServiceTargetType: "http", + elasticattr.ServiceTargetName: "www.foo.bar:443", + elasticattr.SpanDestinationServiceResource: "testsvc", }, }, { @@ -591,18 +591,18 @@ func TestElasticSpanEnrich(t *testing.T) { }(), config: config.Enabled().Span, enrichedAttrs: map[string]any{ - common.AttributeTimestampUs: startTs.AsTime().UnixMicro(), - common.AttributeSpanName: "testspan", - common.AttributeProcessorEvent: "span", - common.AttributeSpanRepresentativeCount: float64(1), - common.AttributeSpanType: "external", - common.AttributeSpanSubtype: "http", - common.AttributeSpanDurationUs: expectedDuration.Microseconds(), - common.AttributeEventOutcome: "success", - common.AttributeSuccessCount: int64(1), - common.AttributeServiceTargetType: "http", - common.AttributeServiceTargetName: "www.foo.bar:443", - common.AttributeSpanDestinationServiceResource: "testsvc", + elasticattr.TimestampUs: startTs.AsTime().UnixMicro(), + elasticattr.SpanName: "testspan", + elasticattr.ProcessorEvent: "span", + elasticattr.SpanRepresentativeCount: float64(1), + elasticattr.SpanType: "external", + elasticattr.SpanSubtype: "http", + elasticattr.SpanDurationUs: expectedDuration.Microseconds(), + elasticattr.EventOutcome: "success", + elasticattr.SuccessCount: int64(1), + elasticattr.ServiceTargetType: "http", + elasticattr.ServiceTargetName: "www.foo.bar:443", + elasticattr.SpanDestinationServiceResource: "testsvc", }, }, { @@ -619,18 +619,18 @@ func TestElasticSpanEnrich(t *testing.T) { }(), config: config.Enabled().Span, enrichedAttrs: map[string]any{ - common.AttributeTimestampUs: startTs.AsTime().UnixMicro(), - common.AttributeSpanName: "testspan", - common.AttributeProcessorEvent: "span", - common.AttributeSpanRepresentativeCount: float64(1), - common.AttributeSpanType: "external", - common.AttributeSpanSubtype: "grpc", - common.AttributeSpanDurationUs: expectedDuration.Microseconds(), - common.AttributeEventOutcome: "success", - common.AttributeSuccessCount: int64(1), - common.AttributeServiceTargetType: "grpc", - common.AttributeServiceTargetName: "testsvc", - common.AttributeSpanDestinationServiceResource: "testsvc", + elasticattr.TimestampUs: startTs.AsTime().UnixMicro(), + elasticattr.SpanName: "testspan", + elasticattr.ProcessorEvent: "span", + elasticattr.SpanRepresentativeCount: float64(1), + elasticattr.SpanType: "external", + elasticattr.SpanSubtype: "grpc", + elasticattr.SpanDurationUs: expectedDuration.Microseconds(), + elasticattr.EventOutcome: "success", + elasticattr.SuccessCount: int64(1), + elasticattr.ServiceTargetType: "grpc", + elasticattr.ServiceTargetName: "testsvc", + elasticattr.SpanDestinationServiceResource: "testsvc", }, }, { @@ -644,18 +644,18 @@ func TestElasticSpanEnrich(t *testing.T) { }(), config: config.Enabled().Span, enrichedAttrs: map[string]any{ - common.AttributeTimestampUs: startTs.AsTime().UnixMicro(), - common.AttributeSpanName: "testspan", - common.AttributeProcessorEvent: "span", - common.AttributeSpanRepresentativeCount: float64(1), - common.AttributeSpanType: "external", - common.AttributeSpanSubtype: "xmlrpc", - common.AttributeSpanDurationUs: expectedDuration.Microseconds(), - common.AttributeEventOutcome: "success", - common.AttributeSuccessCount: int64(1), - common.AttributeServiceTargetType: "xmlrpc", - common.AttributeServiceTargetName: "testsvc", - common.AttributeSpanDestinationServiceResource: "testsvc", + elasticattr.TimestampUs: startTs.AsTime().UnixMicro(), + elasticattr.SpanName: "testspan", + elasticattr.ProcessorEvent: "span", + elasticattr.SpanRepresentativeCount: float64(1), + elasticattr.SpanType: "external", + elasticattr.SpanSubtype: "xmlrpc", + elasticattr.SpanDurationUs: expectedDuration.Microseconds(), + elasticattr.EventOutcome: "success", + elasticattr.SuccessCount: int64(1), + elasticattr.ServiceTargetType: "xmlrpc", + elasticattr.ServiceTargetName: "testsvc", + elasticattr.SpanDestinationServiceResource: "testsvc", }, }, { @@ -671,17 +671,17 @@ func TestElasticSpanEnrich(t *testing.T) { }(), config: config.Enabled().Span, enrichedAttrs: map[string]any{ - common.AttributeTimestampUs: startTs.AsTime().UnixMicro(), - common.AttributeSpanName: "testspan", - common.AttributeProcessorEvent: "span", - common.AttributeSpanRepresentativeCount: float64(1), - common.AttributeSpanType: "external", - common.AttributeSpanDurationUs: expectedDuration.Microseconds(), - common.AttributeEventOutcome: "success", - common.AttributeSuccessCount: int64(1), - common.AttributeServiceTargetType: "external", - common.AttributeServiceTargetName: "service.Test", - common.AttributeSpanDestinationServiceResource: "testsvc", + elasticattr.TimestampUs: startTs.AsTime().UnixMicro(), + elasticattr.SpanName: "testspan", + elasticattr.ProcessorEvent: "span", + elasticattr.SpanRepresentativeCount: float64(1), + elasticattr.SpanType: "external", + elasticattr.SpanDurationUs: expectedDuration.Microseconds(), + elasticattr.EventOutcome: "success", + elasticattr.SuccessCount: int64(1), + elasticattr.ServiceTargetType: "external", + elasticattr.ServiceTargetName: "service.Test", + elasticattr.SpanDestinationServiceResource: "testsvc", }, }, { @@ -697,17 +697,17 @@ func TestElasticSpanEnrich(t *testing.T) { }(), config: config.Enabled().Span, enrichedAttrs: map[string]any{ - common.AttributeTimestampUs: startTs.AsTime().UnixMicro(), - common.AttributeSpanName: "testspan", - common.AttributeProcessorEvent: "span", - common.AttributeSpanRepresentativeCount: float64(1), - common.AttributeSpanType: "external", - common.AttributeSpanDurationUs: expectedDuration.Microseconds(), - common.AttributeEventOutcome: "success", - common.AttributeSuccessCount: int64(1), - common.AttributeServiceTargetType: "external", - common.AttributeServiceTargetName: "service.Test", - common.AttributeSpanDestinationServiceResource: "10.2.20.18:8081", + elasticattr.TimestampUs: startTs.AsTime().UnixMicro(), + elasticattr.SpanName: "testspan", + elasticattr.ProcessorEvent: "span", + elasticattr.SpanRepresentativeCount: float64(1), + elasticattr.SpanType: "external", + elasticattr.SpanDurationUs: expectedDuration.Microseconds(), + elasticattr.EventOutcome: "success", + elasticattr.SuccessCount: int64(1), + elasticattr.ServiceTargetType: "external", + elasticattr.ServiceTargetName: "service.Test", + elasticattr.SpanDestinationServiceResource: "10.2.20.18:8081", }, }, { @@ -723,17 +723,17 @@ func TestElasticSpanEnrich(t *testing.T) { }(), config: config.Enabled().Span, enrichedAttrs: map[string]any{ - common.AttributeTimestampUs: startTs.AsTime().UnixMicro(), - common.AttributeSpanName: "testspan", - common.AttributeProcessorEvent: "span", - common.AttributeSpanRepresentativeCount: float64(1), - common.AttributeSpanType: "external", - common.AttributeSpanDurationUs: expectedDuration.Microseconds(), - common.AttributeEventOutcome: "success", - common.AttributeSuccessCount: int64(1), - common.AttributeServiceTargetType: "external", - common.AttributeServiceTargetName: "service.Test", - common.AttributeSpanDestinationServiceResource: "10.2.20.18:8081", + elasticattr.TimestampUs: startTs.AsTime().UnixMicro(), + elasticattr.SpanName: "testspan", + elasticattr.ProcessorEvent: "span", + elasticattr.SpanRepresentativeCount: float64(1), + elasticattr.SpanType: "external", + elasticattr.SpanDurationUs: expectedDuration.Microseconds(), + elasticattr.EventOutcome: "success", + elasticattr.SuccessCount: int64(1), + elasticattr.ServiceTargetType: "external", + elasticattr.ServiceTargetName: "service.Test", + elasticattr.SpanDestinationServiceResource: "10.2.20.18:8081", }, }, { @@ -747,18 +747,18 @@ func TestElasticSpanEnrich(t *testing.T) { }(), config: config.Enabled().Span, enrichedAttrs: map[string]any{ - common.AttributeTimestampUs: startTs.AsTime().UnixMicro(), - common.AttributeSpanName: "testspan", - common.AttributeProcessorEvent: "span", - common.AttributeSpanRepresentativeCount: float64(1), - common.AttributeSpanType: "messaging", - common.AttributeSpanSubtype: "kafka", - common.AttributeSpanDurationUs: expectedDuration.Microseconds(), - common.AttributeEventOutcome: "success", - common.AttributeSuccessCount: int64(1), - common.AttributeServiceTargetType: "kafka", - common.AttributeServiceTargetName: "testsvc", - common.AttributeSpanDestinationServiceResource: "testsvc", + elasticattr.TimestampUs: startTs.AsTime().UnixMicro(), + elasticattr.SpanName: "testspan", + elasticattr.ProcessorEvent: "span", + elasticattr.SpanRepresentativeCount: float64(1), + elasticattr.SpanType: "messaging", + elasticattr.SpanSubtype: "kafka", + elasticattr.SpanDurationUs: expectedDuration.Microseconds(), + elasticattr.EventOutcome: "success", + elasticattr.SuccessCount: int64(1), + elasticattr.ServiceTargetType: "kafka", + elasticattr.ServiceTargetName: "testsvc", + elasticattr.SpanDestinationServiceResource: "testsvc", }, }, { @@ -772,17 +772,17 @@ func TestElasticSpanEnrich(t *testing.T) { }(), config: config.Enabled().Span, enrichedAttrs: map[string]any{ - common.AttributeTimestampUs: startTs.AsTime().UnixMicro(), - common.AttributeSpanName: "testspan", - common.AttributeProcessorEvent: "span", - common.AttributeSpanRepresentativeCount: float64(1), - common.AttributeSpanType: "messaging", - common.AttributeSpanDurationUs: expectedDuration.Microseconds(), - common.AttributeEventOutcome: "success", - common.AttributeSuccessCount: int64(1), - common.AttributeServiceTargetType: "messaging", - common.AttributeServiceTargetName: "t1", - common.AttributeSpanDestinationServiceResource: "testsvc/t1", + elasticattr.TimestampUs: startTs.AsTime().UnixMicro(), + elasticattr.SpanName: "testspan", + elasticattr.ProcessorEvent: "span", + elasticattr.SpanRepresentativeCount: float64(1), + elasticattr.SpanType: "messaging", + elasticattr.SpanDurationUs: expectedDuration.Microseconds(), + elasticattr.EventOutcome: "success", + elasticattr.SuccessCount: int64(1), + elasticattr.ServiceTargetType: "messaging", + elasticattr.ServiceTargetName: "t1", + elasticattr.SpanDestinationServiceResource: "testsvc/t1", }, }, { @@ -797,17 +797,17 @@ func TestElasticSpanEnrich(t *testing.T) { }(), config: config.Enabled().Span, enrichedAttrs: map[string]any{ - common.AttributeTimestampUs: startTs.AsTime().UnixMicro(), - common.AttributeSpanName: "testspan", - common.AttributeProcessorEvent: "span", - common.AttributeSpanRepresentativeCount: float64(1), - common.AttributeSpanType: "messaging", - common.AttributeSpanDurationUs: expectedDuration.Microseconds(), - common.AttributeEventOutcome: "success", - common.AttributeSuccessCount: int64(1), - common.AttributeServiceTargetType: "messaging", - common.AttributeServiceTargetName: "testsvc", - common.AttributeSpanDestinationServiceResource: "testsvc/t1", + elasticattr.TimestampUs: startTs.AsTime().UnixMicro(), + elasticattr.SpanName: "testspan", + elasticattr.ProcessorEvent: "span", + elasticattr.SpanRepresentativeCount: float64(1), + elasticattr.SpanType: "messaging", + elasticattr.SpanDurationUs: expectedDuration.Microseconds(), + elasticattr.EventOutcome: "success", + elasticattr.SuccessCount: int64(1), + elasticattr.ServiceTargetType: "messaging", + elasticattr.ServiceTargetName: "testsvc", + elasticattr.SpanDestinationServiceResource: "testsvc/t1", }, }, { @@ -828,18 +828,18 @@ func TestElasticSpanEnrich(t *testing.T) { }(), config: config.Enabled().Span, enrichedAttrs: map[string]any{ - common.AttributeTimestampUs: startTs.AsTime().UnixMicro(), - common.AttributeSpanName: "testspan", - common.AttributeProcessorEvent: "span", - common.AttributeSpanRepresentativeCount: float64(1), - common.AttributeSpanType: "db", - common.AttributeSpanSubtype: "elasticsearch", - common.AttributeSpanDurationUs: expectedDuration.Microseconds(), - common.AttributeEventOutcome: "success", - common.AttributeSuccessCount: int64(1), - common.AttributeServiceTargetType: "elasticsearch", - common.AttributeServiceTargetName: "testsvc", - common.AttributeSpanDestinationServiceResource: "testsvc", + elasticattr.TimestampUs: startTs.AsTime().UnixMicro(), + elasticattr.SpanName: "testspan", + elasticattr.ProcessorEvent: "span", + elasticattr.SpanRepresentativeCount: float64(1), + elasticattr.SpanType: "db", + elasticattr.SpanSubtype: "elasticsearch", + elasticattr.SpanDurationUs: expectedDuration.Microseconds(), + elasticattr.EventOutcome: "success", + elasticattr.SuccessCount: int64(1), + elasticattr.ServiceTargetType: "elasticsearch", + elasticattr.ServiceTargetName: "testsvc", + elasticattr.SpanDestinationServiceResource: "testsvc", }, }, { @@ -865,18 +865,18 @@ func TestElasticSpanEnrich(t *testing.T) { }(), config: config.Enabled().Span, enrichedAttrs: map[string]any{ - common.AttributeTimestampUs: startTs.AsTime().UnixMicro(), - common.AttributeSpanName: "testspan", - common.AttributeProcessorEvent: "span", - common.AttributeSpanRepresentativeCount: float64(1), - common.AttributeSpanType: "db", - common.AttributeSpanSubtype: "cassandra", - common.AttributeSpanDurationUs: expectedDuration.Microseconds(), - common.AttributeEventOutcome: "success", - common.AttributeSuccessCount: int64(1), - common.AttributeServiceTargetType: "cassandra", - common.AttributeServiceTargetName: "testsvc", - common.AttributeSpanDestinationServiceResource: "testsvc", + elasticattr.TimestampUs: startTs.AsTime().UnixMicro(), + elasticattr.SpanName: "testspan", + elasticattr.ProcessorEvent: "span", + elasticattr.SpanRepresentativeCount: float64(1), + elasticattr.SpanType: "db", + elasticattr.SpanSubtype: "cassandra", + elasticattr.SpanDurationUs: expectedDuration.Microseconds(), + elasticattr.EventOutcome: "success", + elasticattr.SuccessCount: int64(1), + elasticattr.ServiceTargetType: "cassandra", + elasticattr.ServiceTargetName: "testsvc", + elasticattr.SpanDestinationServiceResource: "testsvc", }, }, { @@ -899,15 +899,15 @@ func TestElasticSpanEnrich(t *testing.T) { }(), config: config.Enabled().Span, enrichedAttrs: map[string]any{ - common.AttributeTimestampUs: startTs.AsTime().UnixMicro(), - common.AttributeSpanName: "testspan", - common.AttributeProcessorEvent: "span", - common.AttributeSpanRepresentativeCount: float64(1), - common.AttributeSpanType: "unknown", - common.AttributeSpanDurationUs: expectedDuration.Microseconds(), - common.AttributeEventOutcome: "success", - common.AttributeSuccessCount: int64(1), - common.AttributeChildIDs: []any{"0300000000000000", "0400000000000000"}, + elasticattr.TimestampUs: startTs.AsTime().UnixMicro(), + elasticattr.SpanName: "testspan", + elasticattr.ProcessorEvent: "span", + elasticattr.SpanRepresentativeCount: float64(1), + elasticattr.SpanType: "unknown", + elasticattr.SpanDurationUs: expectedDuration.Microseconds(), + elasticattr.EventOutcome: "success", + elasticattr.SuccessCount: int64(1), + elasticattr.ChildIDs: []any{"0300000000000000", "0400000000000000"}, }, expectedSpanLinks: func() *ptrace.SpanLinkSlice { spanLinks := ptrace.NewSpanLinkSlice() @@ -927,15 +927,15 @@ func TestElasticSpanEnrich(t *testing.T) { }(), config: config.Enabled().Span, enrichedAttrs: map[string]any{ - common.AttributeTimestampUs: startTs.AsTime().UnixMicro(), - common.AttributeSpanName: "testspan", - common.AttributeProcessorEvent: "span", - common.AttributeSpanRepresentativeCount: float64(1), - common.AttributeSpanType: "genai", - common.AttributeSpanSubtype: "openai", - common.AttributeSpanDurationUs: expectedDuration.Microseconds(), - common.AttributeEventOutcome: "success", - common.AttributeSuccessCount: int64(1), + elasticattr.TimestampUs: startTs.AsTime().UnixMicro(), + elasticattr.SpanName: "testspan", + elasticattr.ProcessorEvent: "span", + elasticattr.SpanRepresentativeCount: float64(1), + elasticattr.SpanType: "genai", + elasticattr.SpanSubtype: "openai", + elasticattr.SpanDurationUs: expectedDuration.Microseconds(), + elasticattr.EventOutcome: "success", + elasticattr.SuccessCount: int64(1), }, }, } { @@ -984,7 +984,7 @@ func TestSpanEventEnrich(t *testing.T) { config: config.Enabled().SpanEvent, errorID: false, // error ID is only present for exceptions enrichedAttrs: map[string]any{ - common.AttributeTimestampUs: ts.AsTime().UnixMicro(), + elasticattr.TimestampUs: ts.AsTime().UnixMicro(), }, }, { @@ -1006,17 +1006,17 @@ func TestSpanEventEnrich(t *testing.T) { config: config.Enabled().SpanEvent, errorID: true, enrichedAttrs: map[string]any{ - common.AttributeTimestampUs: ts.AsTime().UnixMicro(), - common.AttributeProcessorEvent: "error", - common.AttributeErrorExceptionHandled: true, - common.AttributeErrorGroupingKey: func() string { + elasticattr.TimestampUs: ts.AsTime().UnixMicro(), + elasticattr.ProcessorEvent: "error", + elasticattr.ErrorExceptionHandled: true, + elasticattr.ErrorGroupingKey: func() string { hash := md5.New() hash.Write([]byte("java.net.ConnectionError")) return hex.EncodeToString(hash.Sum(nil)) }(), - common.AttributeErrorGroupingName: "something is wrong", - common.AttributeTransactionSampled: true, - common.AttributeTransactionType: "unknown", + elasticattr.ErrorGroupingName: "something is wrong", + elasticattr.TransactionSampled: true, + elasticattr.TransactionType: "unknown", }, }, { @@ -1039,15 +1039,15 @@ func TestSpanEventEnrich(t *testing.T) { config: config.Enabled().SpanEvent, errorID: true, enrichedAttrs: map[string]any{ - common.AttributeTimestampUs: ts.AsTime().UnixMicro(), - common.AttributeProcessorEvent: "error", - common.AttributeErrorExceptionHandled: true, - common.AttributeErrorGroupingKey: func() string { + elasticattr.TimestampUs: ts.AsTime().UnixMicro(), + elasticattr.ProcessorEvent: "error", + elasticattr.ErrorExceptionHandled: true, + elasticattr.ErrorGroupingKey: func() string { hash := md5.New() hash.Write([]byte("java.net.ConnectionError")) return hex.EncodeToString(hash.Sum(nil)) }(), - common.AttributeErrorGroupingName: "something is wrong", + elasticattr.ErrorGroupingName: "something is wrong", }, }, } { @@ -1065,13 +1065,13 @@ func TestSpanEventEnrich(t *testing.T) { }) actual := tc.parent.Events().At(0).Attributes() - errorID, ok := actual.Get(common.AttributeErrorID) + errorID, ok := actual.Get(elasticattr.ErrorID) assert.Equal(t, tc.errorID, ok, "error_id must be present for exception and must not be present for non-exception") if tc.errorID { assert.NotEmpty(t, errorID, "error_id must not be empty") } // Ignore error in actual diff since it is randomly generated - actual.Remove(common.AttributeErrorID) + actual.Remove(elasticattr.ErrorID) assert.Empty(t, cmp.Diff(expectedAttrs, actual.AsRaw())) }) } diff --git a/go.mod b/go.mod index 41f3a45..edc3bb1 100644 --- a/go.mod +++ b/go.mod @@ -5,6 +5,7 @@ go 1.22.7 require ( github.com/elastic/go-elasticsearch/v8 v8.17.0 github.com/elastic/opentelemetry-lib/common v0.1.0 + github.com/elastic/opentelemetry-lib/elasticattributes v0.0.0 github.com/google/go-cmp v0.6.0 github.com/open-telemetry/opentelemetry-collector-contrib/pkg/golden v0.117.0 github.com/open-telemetry/opentelemetry-collector-contrib/pkg/pdatatest v0.117.0 @@ -39,3 +40,5 @@ require ( google.golang.org/protobuf v1.36.2 // indirect gopkg.in/yaml.v3 v3.0.1 // indirect ) + +replace github.com/elastic/opentelemetry-lib/elasticattributes => ./elasticattributes From 821746ed7473f916913a985620cc17f11aa2659e Mon Sep 17 00:00:00 2001 From: Greg Kalapos Date: Mon, 20 Jan 2025 19:29:11 +0100 Subject: [PATCH 4/8] Rename folder to elasticattr --- {elasticattributes => elasticattr}/attributes.go | 0 {elasticattributes => elasticattr}/go.mod | 0 go.mod | 2 +- 3 files changed, 1 insertion(+), 1 deletion(-) rename {elasticattributes => elasticattr}/attributes.go (100%) rename {elasticattributes => elasticattr}/go.mod (100%) diff --git a/elasticattributes/attributes.go b/elasticattr/attributes.go similarity index 100% rename from elasticattributes/attributes.go rename to elasticattr/attributes.go diff --git a/elasticattributes/go.mod b/elasticattr/go.mod similarity index 100% rename from elasticattributes/go.mod rename to elasticattr/go.mod diff --git a/go.mod b/go.mod index edc3bb1..098a99c 100644 --- a/go.mod +++ b/go.mod @@ -41,4 +41,4 @@ require ( gopkg.in/yaml.v3 v3.0.1 // indirect ) -replace github.com/elastic/opentelemetry-lib/elasticattributes => ./elasticattributes +replace github.com/elastic/opentelemetry-lib/elasticattributes => ./elasticattr From 5f4573271d74ef0dc62db4b2c566c4413ae057ff Mon Sep 17 00:00:00 2001 From: Greg Kalapos Date: Tue, 21 Jan 2025 18:19:13 +0100 Subject: [PATCH 5/8] rename module --- elasticattr/go.mod | 2 +- enrichments/trace/internal/elastic/resource.go | 2 +- enrichments/trace/internal/elastic/resource_test.go | 2 +- enrichments/trace/internal/elastic/scope.go | 2 +- enrichments/trace/internal/elastic/scope_test.go | 2 +- enrichments/trace/internal/elastic/span.go | 2 +- enrichments/trace/internal/elastic/span_test.go | 2 +- go.mod | 4 ++-- 8 files changed, 9 insertions(+), 9 deletions(-) diff --git a/elasticattr/go.mod b/elasticattr/go.mod index 6c0d5e1..b54dd1e 100644 --- a/elasticattr/go.mod +++ b/elasticattr/go.mod @@ -1,3 +1,3 @@ -module github.com/elastic/opentelemetry-lib/elasticattributes +module github.com/elastic/opentelemetry-lib/elasticattr go 1.22.7 diff --git a/enrichments/trace/internal/elastic/resource.go b/enrichments/trace/internal/elastic/resource.go index edb5766..48e4b10 100644 --- a/enrichments/trace/internal/elastic/resource.go +++ b/enrichments/trace/internal/elastic/resource.go @@ -20,7 +20,7 @@ package elastic import ( "fmt" - elasticattr "github.com/elastic/opentelemetry-lib/elasticattributes" + "github.com/elastic/opentelemetry-lib/elasticattr" "github.com/elastic/opentelemetry-lib/enrichments/trace/config" "go.opentelemetry.io/collector/pdata/pcommon" semconv "go.opentelemetry.io/collector/semconv/v1.25.0" diff --git a/enrichments/trace/internal/elastic/resource_test.go b/enrichments/trace/internal/elastic/resource_test.go index af4461c..d3c5a52 100644 --- a/enrichments/trace/internal/elastic/resource_test.go +++ b/enrichments/trace/internal/elastic/resource_test.go @@ -20,7 +20,7 @@ package elastic import ( "testing" - elasticattr "github.com/elastic/opentelemetry-lib/elasticattributes" + "github.com/elastic/opentelemetry-lib/elasticattr" "github.com/elastic/opentelemetry-lib/enrichments/trace/config" "github.com/google/go-cmp/cmp" "github.com/stretchr/testify/assert" diff --git a/enrichments/trace/internal/elastic/scope.go b/enrichments/trace/internal/elastic/scope.go index 7265f73..e31abe3 100644 --- a/enrichments/trace/internal/elastic/scope.go +++ b/enrichments/trace/internal/elastic/scope.go @@ -18,7 +18,7 @@ package elastic import ( - elasticattr "github.com/elastic/opentelemetry-lib/elasticattributes" + "github.com/elastic/opentelemetry-lib/elasticattr" "github.com/elastic/opentelemetry-lib/enrichments/trace/config" "go.opentelemetry.io/collector/pdata/pcommon" ) diff --git a/enrichments/trace/internal/elastic/scope_test.go b/enrichments/trace/internal/elastic/scope_test.go index cfcdbd9..1d3a4a2 100644 --- a/enrichments/trace/internal/elastic/scope_test.go +++ b/enrichments/trace/internal/elastic/scope_test.go @@ -20,7 +20,7 @@ package elastic import ( "testing" - elasticattr "github.com/elastic/opentelemetry-lib/elasticattributes" + "github.com/elastic/opentelemetry-lib/elasticattr" "github.com/elastic/opentelemetry-lib/enrichments/trace/config" "github.com/google/go-cmp/cmp" "github.com/stretchr/testify/assert" diff --git a/enrichments/trace/internal/elastic/span.go b/enrichments/trace/internal/elastic/span.go index 7c8b3f5..4ac174d 100644 --- a/enrichments/trace/internal/elastic/span.go +++ b/enrichments/trace/internal/elastic/span.go @@ -30,7 +30,7 @@ import ( "strconv" "strings" - elasticattr "github.com/elastic/opentelemetry-lib/elasticattributes" + "github.com/elastic/opentelemetry-lib/elasticattr" "github.com/elastic/opentelemetry-lib/enrichments/trace/config" "go.opentelemetry.io/collector/pdata/pcommon" "go.opentelemetry.io/collector/pdata/ptrace" diff --git a/enrichments/trace/internal/elastic/span_test.go b/enrichments/trace/internal/elastic/span_test.go index a6d7942..c818db0 100644 --- a/enrichments/trace/internal/elastic/span_test.go +++ b/enrichments/trace/internal/elastic/span_test.go @@ -24,7 +24,7 @@ import ( "testing" "time" - elasticattr "github.com/elastic/opentelemetry-lib/elasticattributes" + "github.com/elastic/opentelemetry-lib/elasticattr" "github.com/elastic/opentelemetry-lib/enrichments/trace/config" "github.com/google/go-cmp/cmp" "github.com/open-telemetry/opentelemetry-collector-contrib/pkg/pdatatest/ptracetest" diff --git a/go.mod b/go.mod index 098a99c..25e952e 100644 --- a/go.mod +++ b/go.mod @@ -5,7 +5,7 @@ go 1.22.7 require ( github.com/elastic/go-elasticsearch/v8 v8.17.0 github.com/elastic/opentelemetry-lib/common v0.1.0 - github.com/elastic/opentelemetry-lib/elasticattributes v0.0.0 + github.com/elastic/opentelemetry-lib/elasticattr v0.0.0 github.com/google/go-cmp v0.6.0 github.com/open-telemetry/opentelemetry-collector-contrib/pkg/golden v0.117.0 github.com/open-telemetry/opentelemetry-collector-contrib/pkg/pdatatest v0.117.0 @@ -41,4 +41,4 @@ require ( gopkg.in/yaml.v3 v3.0.1 // indirect ) -replace github.com/elastic/opentelemetry-lib/elasticattributes => ./elasticattr +replace github.com/elastic/opentelemetry-lib/elasticattr => ./elasticattr From 619ac5aaa341763192b8e1f0691b229aaaf52ea6 Mon Sep 17 00:00:00 2001 From: Greg Kalapos Date: Tue, 21 Jan 2025 18:46:18 +0100 Subject: [PATCH 6/8] Remove `replace` from go.mod --- go.mod | 5 +---- go.sum | 4 ++-- 2 files changed, 3 insertions(+), 6 deletions(-) diff --git a/go.mod b/go.mod index 25e952e..52dfa24 100644 --- a/go.mod +++ b/go.mod @@ -4,8 +4,7 @@ go 1.22.7 require ( github.com/elastic/go-elasticsearch/v8 v8.17.0 - github.com/elastic/opentelemetry-lib/common v0.1.0 - github.com/elastic/opentelemetry-lib/elasticattr v0.0.0 + github.com/elastic/opentelemetry-lib/elasticattr v0.1.0 github.com/google/go-cmp v0.6.0 github.com/open-telemetry/opentelemetry-collector-contrib/pkg/golden v0.117.0 github.com/open-telemetry/opentelemetry-collector-contrib/pkg/pdatatest v0.117.0 @@ -40,5 +39,3 @@ require ( google.golang.org/protobuf v1.36.2 // indirect gopkg.in/yaml.v3 v3.0.1 // indirect ) - -replace github.com/elastic/opentelemetry-lib/elasticattr => ./elasticattr diff --git a/go.sum b/go.sum index 6eb9ff9..4714206 100644 --- a/go.sum +++ b/go.sum @@ -7,9 +7,9 @@ github.com/elastic/elastic-transport-go/v8 v8.6.0 h1:Y2S/FBjx1LlCv5m6pWAF2kDJAHo github.com/elastic/elastic-transport-go/v8 v8.6.0/go.mod h1:YLHer5cj0csTzNFXoNQ8qhtGY1GTvSqPnKWKaqQE3Hk= github.com/elastic/go-elasticsearch/v8 v8.17.0 h1:e9cWksE/Fr7urDRmGPGp47Nsp4/mvNOrU8As1l2HQQ0= github.com/elastic/go-elasticsearch/v8 v8.17.0/go.mod h1:lGMlgKIbYoRvay3xWBeKahAiJOgmFDsjZC39nmO3H64= +github.com/elastic/opentelemetry-lib/elasticattr v0.1.0 h1:L24IjtTF1WuhW+7/QOm9ppfLP5sYDnAfV7CU4TLyacQ= +github.com/elastic/opentelemetry-lib/elasticattr v0.1.0/go.mod h1:cRJkIC+mQ8VRJrgnxa5tAfjY+yRF4kn4ISCoSSma04U= github.com/go-logr/logr v1.2.2/go.mod h1:jdQByPbusPIv2/zmleS9BjJVeZ6kBagPoEUsqbVz/1A= -github.com/elastic/opentelemetry-lib/common v0.1.0 h1:oZxb1CGzmc8md6Up0orgdc/2M1LpnGgjpvj50br/jE4= -github.com/elastic/opentelemetry-lib/common v0.1.0/go.mod h1:8uIzkjcq5I3ZEtblW+TOIJLJgj1t3VH+O/Uw1rqKPq4= github.com/go-logr/logr v1.4.2 h1:6pFjapn8bFcIbiKo3XT4j/BhANplGihG6tvd+8rYgrY= github.com/go-logr/logr v1.4.2/go.mod h1:9T104GzyrTigFIr8wt5mBrctHMim0Nb2HLGrmQ40KvY= github.com/go-logr/stdr v1.2.2 h1:hSWxHoqTgW2S2qGc0LTAI563KZ5YKYRhT3MFKZMbjag= From 9373c893545c3bd3cca8d5c4623bf536cd40009f Mon Sep 17 00:00:00 2001 From: Greg Kalapos Date: Wed, 22 Jan 2025 11:41:06 +0100 Subject: [PATCH 7/8] Remove module --- elasticattr/go.mod | 3 --- go.mod | 1 - go.sum | 2 -- 3 files changed, 6 deletions(-) delete mode 100644 elasticattr/go.mod diff --git a/elasticattr/go.mod b/elasticattr/go.mod deleted file mode 100644 index b54dd1e..0000000 --- a/elasticattr/go.mod +++ /dev/null @@ -1,3 +0,0 @@ -module github.com/elastic/opentelemetry-lib/elasticattr - -go 1.22.7 diff --git a/go.mod b/go.mod index 52dfa24..cd7e117 100644 --- a/go.mod +++ b/go.mod @@ -4,7 +4,6 @@ go 1.22.7 require ( github.com/elastic/go-elasticsearch/v8 v8.17.0 - github.com/elastic/opentelemetry-lib/elasticattr v0.1.0 github.com/google/go-cmp v0.6.0 github.com/open-telemetry/opentelemetry-collector-contrib/pkg/golden v0.117.0 github.com/open-telemetry/opentelemetry-collector-contrib/pkg/pdatatest v0.117.0 diff --git a/go.sum b/go.sum index 4714206..42281c5 100644 --- a/go.sum +++ b/go.sum @@ -7,8 +7,6 @@ github.com/elastic/elastic-transport-go/v8 v8.6.0 h1:Y2S/FBjx1LlCv5m6pWAF2kDJAHo github.com/elastic/elastic-transport-go/v8 v8.6.0/go.mod h1:YLHer5cj0csTzNFXoNQ8qhtGY1GTvSqPnKWKaqQE3Hk= github.com/elastic/go-elasticsearch/v8 v8.17.0 h1:e9cWksE/Fr7urDRmGPGp47Nsp4/mvNOrU8As1l2HQQ0= github.com/elastic/go-elasticsearch/v8 v8.17.0/go.mod h1:lGMlgKIbYoRvay3xWBeKahAiJOgmFDsjZC39nmO3H64= -github.com/elastic/opentelemetry-lib/elasticattr v0.1.0 h1:L24IjtTF1WuhW+7/QOm9ppfLP5sYDnAfV7CU4TLyacQ= -github.com/elastic/opentelemetry-lib/elasticattr v0.1.0/go.mod h1:cRJkIC+mQ8VRJrgnxa5tAfjY+yRF4kn4ISCoSSma04U= github.com/go-logr/logr v1.2.2/go.mod h1:jdQByPbusPIv2/zmleS9BjJVeZ6kBagPoEUsqbVz/1A= github.com/go-logr/logr v1.4.2 h1:6pFjapn8bFcIbiKo3XT4j/BhANplGihG6tvd+8rYgrY= github.com/go-logr/logr v1.4.2/go.mod h1:9T104GzyrTigFIr8wt5mBrctHMim0Nb2HLGrmQ40KvY= From ca74f38ad5dad247523fa3e4126ac668255cc718 Mon Sep 17 00:00:00 2001 From: Greg Kalapos Date: Wed, 22 Jan 2025 11:42:52 +0100 Subject: [PATCH 8/8] Update resource.go --- enrichments/trace/internal/elastic/resource.go | 1 - 1 file changed, 1 deletion(-) diff --git a/enrichments/trace/internal/elastic/resource.go b/enrichments/trace/internal/elastic/resource.go index 48e4b10..0b4bd4e 100644 --- a/enrichments/trace/internal/elastic/resource.go +++ b/enrichments/trace/internal/elastic/resource.go @@ -99,7 +99,6 @@ func (s *resourceEnrichmentContext) setAgentName(resource pcommon.Resource) { s.telemetrySDKLanguage, ) } - resource.Attributes().PutStr(elasticattr.AgentName, agentName) }