From 831e4d6f4b988e25b130231e18171bf25f1e9c48 Mon Sep 17 00:00:00 2001 From: Zhonghao Zhao Date: Wed, 18 Dec 2024 00:26:57 +0000 Subject: [PATCH 1/7] Support new sematic conventions. --- .../internal/translator/aws.go | 6 +- .../internal/translator/aws_test.go | 17 +++ .../internal/translator/cause.go | 3 + .../internal/translator/cause_test.go | 140 ++++++++++++++++++ .../internal/translator/http.go | 5 +- .../internal/translator/http_test.go | 27 +++- 6 files changed, 192 insertions(+), 6 deletions(-) diff --git a/exporter/awsxrayexporter/internal/translator/aws.go b/exporter/awsxrayexporter/internal/translator/aws.go index e29c7e4cbfdc..e312e27cf1ff 100644 --- a/exporter/awsxrayexporter/internal/translator/aws.go +++ b/exporter/awsxrayexporter/internal/translator/aws.go @@ -14,6 +14,10 @@ import ( awsxray "github.com/open-telemetry/opentelemetry-collector-contrib/internal/aws/xray" ) +const ( + AttributeTelemetryDistroVersion = "telemetry.distro.version" +) + func makeAws(attributes map[string]pcommon.Value, resource pcommon.Resource, logGroupNames []string) (map[string]pcommon.Value, *awsxray.AWSData) { var ( cloud string @@ -90,7 +94,7 @@ func makeAws(attributes map[string]pcommon.Value, resource pcommon.Resource, log sdkLanguage = value.Str() case conventions.AttributeTelemetrySDKVersion: sdkVersion = value.Str() - case conventions.AttributeTelemetryAutoVersion: + case conventions.AttributeTelemetryAutoVersion, AttributeTelemetryDistroVersion: autoVersion = value.Str() case conventions.AttributeContainerID: containerID = value.Str() diff --git a/exporter/awsxrayexporter/internal/translator/aws_test.go b/exporter/awsxrayexporter/internal/translator/aws_test.go index e5e7d2f585cb..4c8c78ae3c25 100644 --- a/exporter/awsxrayexporter/internal/translator/aws_test.go +++ b/exporter/awsxrayexporter/internal/translator/aws_test.go @@ -360,6 +360,23 @@ func TestJavaAutoInstrumentation(t *testing.T) { assert.True(t, *awsData.XRay.AutoInstrumentation) } +func TestJavaAutoInstrumentationStable(t *testing.T) { + attributes := make(map[string]pcommon.Value) + resource := pcommon.NewResource() + resource.Attributes().PutStr(conventions.AttributeTelemetrySDKName, "opentelemetry") + resource.Attributes().PutStr(conventions.AttributeTelemetrySDKLanguage, "java") + resource.Attributes().PutStr(conventions.AttributeTelemetrySDKVersion, "1.2.3") + resource.Attributes().PutStr(AttributeTelemetryDistroVersion, "3.4.5") + + filtered, awsData := makeAws(attributes, resource, nil) + + assert.NotNil(t, filtered) + assert.NotNil(t, awsData) + assert.Equal(t, "opentelemetry for java", *awsData.XRay.SDK) + assert.Equal(t, "1.2.3", *awsData.XRay.SDKVersion) + assert.True(t, *awsData.XRay.AutoInstrumentation) +} + func TestGoSDK(t *testing.T) { attributes := make(map[string]pcommon.Value) resource := pcommon.NewResource() diff --git a/exporter/awsxrayexporter/internal/translator/cause.go b/exporter/awsxrayexporter/internal/translator/cause.go index 3f26c84d7b75..1408983b20cd 100644 --- a/exporter/awsxrayexporter/internal/translator/cause.go +++ b/exporter/awsxrayexporter/internal/translator/cause.go @@ -150,6 +150,9 @@ func makeCause(span ptrace.Span, attributes map[string]pcommon.Value, resource p } val, ok := span.Attributes().Get(conventions.AttributeHTTPStatusCode) + if !ok { + val, ok = span.Attributes().Get(AwsIndividualHTTPErrorCodeAttr) + } switch { // The segment status for http spans will be based on their http.statuscode as we found some http diff --git a/exporter/awsxrayexporter/internal/translator/cause_test.go b/exporter/awsxrayexporter/internal/translator/cause_test.go index eabe8147369a..95dcb22681ec 100644 --- a/exporter/awsxrayexporter/internal/translator/cause_test.go +++ b/exporter/awsxrayexporter/internal/translator/cause_test.go @@ -196,6 +196,31 @@ func TestCauseWithStatusMessage(t *testing.T) { assert.True(t, strings.Contains(jsonStr, errorMsg)) } +func TestCauseWithStatusMessageStable(t *testing.T) { + errorMsg := "this is a test" + attributes := make(map[string]any) + attributes[conventions.AttributeHTTPMethod] = "POST" + attributes[conventions.AttributeHTTPURL] = "https://api.example.com/widgets" + attributes[AwsIndividualHTTPErrorCodeAttr] = 500 + span := constructExceptionServerSpan(attributes, ptrace.StatusCodeError) + span.Status().SetMessage(errorMsg) + filtered, _ := makeHTTP(span) + + res := pcommon.NewResource() + isError, isFault, isThrottle, filtered, cause := makeCause(span, filtered, res) + + assert.True(t, isFault) + assert.False(t, isError) + assert.False(t, isThrottle) + assert.NotNil(t, filtered) + assert.NotNil(t, cause) + w := testWriters.borrow() + require.NoError(t, w.Encode(cause)) + jsonStr := w.String() + testWriters.release(w) + assert.True(t, strings.Contains(jsonStr, errorMsg)) +} + func TestCauseWithHttpStatusMessage(t *testing.T) { errorMsg := "this is a test" attributes := make(map[string]any) @@ -221,6 +246,31 @@ func TestCauseWithHttpStatusMessage(t *testing.T) { assert.True(t, strings.Contains(jsonStr, errorMsg)) } +func TestCauseWithHttpStatusMessageStable(t *testing.T) { + errorMsg := "this is a test" + attributes := make(map[string]any) + attributes[conventions.AttributeHTTPMethod] = "POST" + attributes[conventions.AttributeHTTPURL] = "https://api.example.com/widgets" + attributes[AwsIndividualHTTPErrorCodeAttr] = 500 + attributes["http.status_text"] = errorMsg + span := constructExceptionServerSpan(attributes, ptrace.StatusCodeError) + filtered, _ := makeHTTP(span) + + res := pcommon.NewResource() + isError, isFault, isThrottle, filtered, cause := makeCause(span, filtered, res) + + assert.True(t, isFault) + assert.False(t, isError) + assert.False(t, isThrottle) + assert.NotNil(t, filtered) + assert.NotNil(t, cause) + w := testWriters.borrow() + require.NoError(t, w.Encode(cause)) + jsonStr := w.String() + testWriters.release(w) + assert.True(t, strings.Contains(jsonStr, errorMsg)) +} + func TestCauseWithZeroStatusMessageAndFaultHttpCode(t *testing.T) { errorMsg := "this is a test" attributes := make(map[string]any) @@ -245,6 +295,30 @@ func TestCauseWithZeroStatusMessageAndFaultHttpCode(t *testing.T) { assert.Nil(t, cause) } +func TestCauseWithZeroStatusMessageAndFaultHttpCodeStable(t *testing.T) { + errorMsg := "this is a test" + attributes := make(map[string]any) + attributes[conventions.AttributeHTTPMethod] = "POST" + attributes[conventions.AttributeHTTPURL] = "https://api.example.com/widgets" + attributes[AwsIndividualHTTPErrorCodeAttr] = 500 + attributes["http.status_text"] = errorMsg + + span := constructExceptionServerSpan(attributes, ptrace.StatusCodeUnset) + filtered, _ := makeHTTP(span) + // Status is used to determine whether an error or not. + // This span illustrates incorrect instrumentation, + // marking a success status with an error http status code, and status wins. + // We do not expect to see such spans in practice. + res := pcommon.NewResource() + isError, isFault, isThrottle, filtered, cause := makeCause(span, filtered, res) + + assert.False(t, isError) + assert.True(t, isFault) + assert.False(t, isThrottle) + assert.NotNil(t, filtered) + assert.Nil(t, cause) +} + func TestNonHttpUnsetCodeSpan(t *testing.T) { errorMsg := "this is a test" attributes := make(map[string]any) @@ -338,6 +412,30 @@ func TestCauseWithZeroStatusMessageAndFaultErrorCode(t *testing.T) { assert.Nil(t, cause) } +func TestCauseWithZeroStatusMessageAndFaultErrorCodeStable(t *testing.T) { + errorMsg := "this is a test" + attributes := make(map[string]any) + attributes[conventions.AttributeHTTPMethod] = "POST" + attributes[conventions.AttributeHTTPURL] = "https://api.example.com/widgets" + attributes[AwsIndividualHTTPErrorCodeAttr] = 400 + attributes["http.status_text"] = errorMsg + + span := constructExceptionServerSpan(attributes, ptrace.StatusCodeUnset) + filtered, _ := makeHTTP(span) + // Status is used to determine whether an error or not. + // This span illustrates incorrect instrumentation, + // marking a success status with an error http status code, and status wins. + // We do not expect to see such spans in practice. + res := pcommon.NewResource() + isError, isFault, isThrottle, filtered, cause := makeCause(span, filtered, res) + + assert.True(t, isError) + assert.False(t, isFault) + assert.False(t, isThrottle) + assert.NotNil(t, filtered) + assert.Nil(t, cause) +} + func TestCauseWithClientErrorMessage(t *testing.T) { errorMsg := "this is a test" attributes := make(map[string]any) @@ -359,6 +457,27 @@ func TestCauseWithClientErrorMessage(t *testing.T) { assert.NotNil(t, cause) } +func TestCauseWithClientErrorMessageStable(t *testing.T) { + errorMsg := "this is a test" + attributes := make(map[string]any) + attributes[conventions.AttributeHTTPMethod] = "POST" + attributes[conventions.AttributeHTTPURL] = "https://api.example.com/widgets" + attributes[AwsIndividualHTTPErrorCodeAttr] = 499 + attributes["http.status_text"] = errorMsg + + span := constructExceptionServerSpan(attributes, ptrace.StatusCodeError) + filtered, _ := makeHTTP(span) + + res := pcommon.NewResource() + isError, isFault, isThrottle, filtered, cause := makeCause(span, filtered, res) + + assert.True(t, isError) + assert.False(t, isFault) + assert.False(t, isThrottle) + assert.NotNil(t, filtered) + assert.NotNil(t, cause) +} + func TestCauseWithThrottled(t *testing.T) { errorMsg := "this is a test" attributes := make(map[string]any) @@ -380,6 +499,27 @@ func TestCauseWithThrottled(t *testing.T) { assert.NotNil(t, cause) } +func TestCauseWithThrottledStable(t *testing.T) { + errorMsg := "this is a test" + attributes := make(map[string]any) + attributes[conventions.AttributeHTTPMethod] = "POST" + attributes[conventions.AttributeHTTPURL] = "https://api.example.com/widgets" + attributes[AwsIndividualHTTPErrorCodeAttr] = 429 + attributes["http.status_text"] = errorMsg + + span := constructExceptionServerSpan(attributes, ptrace.StatusCodeError) + filtered, _ := makeHTTP(span) + + res := pcommon.NewResource() + isError, isFault, isThrottle, filtered, cause := makeCause(span, filtered, res) + + assert.True(t, isError) + assert.False(t, isFault) + assert.True(t, isThrottle) + assert.NotNil(t, filtered) + assert.NotNil(t, cause) +} + func constructExceptionServerSpan(attributes map[string]any, statuscode ptrace.StatusCode) ptrace.Span { endTime := time.Now().Round(time.Second) startTime := endTime.Add(-90 * time.Second) diff --git a/exporter/awsxrayexporter/internal/translator/http.go b/exporter/awsxrayexporter/internal/translator/http.go index 7aa31f83b777..475d5fc89aa7 100644 --- a/exporter/awsxrayexporter/internal/translator/http.go +++ b/exporter/awsxrayexporter/internal/translator/http.go @@ -25,6 +25,7 @@ const ( AttributeURLScheme = "url.scheme" AttributeURLFull = "url.full" AttributeURLPath = "url.path" + AttributeURLQuery = "url.query" AttributeUserAgentOriginal = "user_agent.original" ) @@ -71,8 +72,8 @@ func makeHTTP(span ptrace.Span) (map[string]pcommon.Value, *awsxray.HTTPData) { urlParts[key] = value.Str() hasHTTP = true hasHTTPRequestURLAttributes = true - case conventions.AttributeHTTPTarget: - urlParts[key] = value.Str() + case conventions.AttributeHTTPTarget, AttributeURLQuery: + urlParts[conventions.AttributeHTTPTarget] = value.Str() hasHTTP = true case conventions.AttributeHTTPServerName: urlParts[key] = value.Str() diff --git a/exporter/awsxrayexporter/internal/translator/http_test.go b/exporter/awsxrayexporter/internal/translator/http_test.go index a5fd43109ac8..f4b9f79c182b 100644 --- a/exporter/awsxrayexporter/internal/translator/http_test.go +++ b/exporter/awsxrayexporter/internal/translator/http_test.go @@ -73,6 +73,27 @@ func TestClientSpanWithSchemeHostTargetAttributes(t *testing.T) { assert.True(t, strings.Contains(jsonStr, "https://api.example.com/users/junit")) } +func TestClientSpanWithSchemeHostTargetAttributesStable(t *testing.T) { + attributes := make(map[string]any) + attributes[conventions.AttributeHTTPMethod] = "GET" + attributes[conventions.AttributeHTTPScheme] = "https" + attributes[conventions.AttributeHTTPHost] = "api.example.com" + attributes[AttributeURLQuery] = "/users/junit" + attributes[conventions.AttributeHTTPStatusCode] = 200 + attributes["user.id"] = "junit" + span := constructHTTPClientSpan(attributes) + + filtered, httpData := makeHTTP(span) + + assert.NotNil(t, httpData) + assert.NotNil(t, filtered) + w := testWriters.borrow() + require.NoError(t, w.Encode(httpData)) + jsonStr := w.String() + testWriters.release(w) + assert.True(t, strings.Contains(jsonStr, "https://api.example.com/users/junit")) +} + func TestClientSpanWithPeerAttributes(t *testing.T) { attributes := make(map[string]any) attributes[conventions.AttributeHTTPMethod] = "GET" @@ -106,7 +127,7 @@ func TestClientSpanWithPeerAttributesStable(t *testing.T) { attributes[conventions.AttributeNetPeerName] = "kb234.example.com" attributes[conventions.AttributeNetPeerPort] = 8080 attributes[conventions.AttributeNetPeerIP] = "10.8.17.36" - attributes[conventions.AttributeHTTPTarget] = "/users/junit" + attributes[AttributeURLQuery] = "/users/junit" attributes[conventions.AttributeHTTPStatusCode] = 200 span := constructHTTPClientSpan(attributes) @@ -257,7 +278,7 @@ func TestServerSpanWithSchemeHostTargetAttributesStable(t *testing.T) { attributes[AttributeHTTPRequestMethod] = "GET" attributes[AttributeURLScheme] = "https" attributes[AttributeServerAddress] = "api.example.com" - attributes[AttributeURLPath] = "/users/junit" + attributes[AttributeURLQuery] = "/users/junit" attributes[AttributeClientAddress] = "192.168.15.32" attributes[AttributeHTTPResponseStatusCode] = 200 span := constructHTTPServerSpan(attributes) @@ -301,7 +322,7 @@ func TestServerSpanWithSchemeServernamePortTargetAttributesStable(t *testing.T) attributes[AttributeURLScheme] = "https" attributes[AttributeServerAddress] = "api.example.com" attributes[AttributeServerPort] = 443 - attributes[AttributeURLPath] = "/users/junit" + attributes[AttributeURLQuery] = "/users/junit" attributes[AttributeClientAddress] = "192.168.15.32" attributes[AttributeHTTPResponseStatusCode] = 200 span := constructHTTPServerSpan(attributes) From c176b0727c4bb5b784b296eff2c39501601d6734 Mon Sep 17 00:00:00 2001 From: Zhonghao Zhao Date: Wed, 18 Dec 2024 22:44:11 +0000 Subject: [PATCH 2/7] Merge in latest semconv pkg. --- exporter/awsxrayexporter/awsxray.go | 2 +- exporter/awsxrayexporter/go.mod | 4 +- exporter/awsxrayexporter/go.sum | 4 + .../internal/translator/aws.go | 7 +- .../internal/translator/aws_test.go | 3 +- .../internal/translator/cause.go | 6 +- .../internal/translator/cause_test.go | 15 +- .../internal/translator/http.go | 43 ++---- .../internal/translator/http_test.go | 131 +++++++++--------- 9 files changed, 103 insertions(+), 112 deletions(-) diff --git a/exporter/awsxrayexporter/awsxray.go b/exporter/awsxrayexporter/awsxray.go index 2f6432da1a23..0d04e35c3b5b 100644 --- a/exporter/awsxrayexporter/awsxray.go +++ b/exporter/awsxrayexporter/awsxray.go @@ -92,7 +92,7 @@ func newTracesExporter( } return err }, - exporterhelper.WithStart(func(ctx context.Context, host component.Host) error { + exporterhelper.WithStart(func(_ context.Context, host component.Host) error { awsConfig, session, err := awsutil.GetAWSConfigSession(logger, cn, &cfg.AWSSessionSettings) if err != nil { return err diff --git a/exporter/awsxrayexporter/go.mod b/exporter/awsxrayexporter/go.mod index 8125c4e0f4c9..b71030c06aa3 100644 --- a/exporter/awsxrayexporter/go.mod +++ b/exporter/awsxrayexporter/go.mod @@ -8,14 +8,14 @@ require ( github.com/open-telemetry/opentelemetry-collector-contrib/internal/aws/awsutil v0.103.0 github.com/open-telemetry/opentelemetry-collector-contrib/internal/aws/xray v0.103.0 github.com/open-telemetry/opentelemetry-collector-contrib/internal/coreinternal v0.103.0 - github.com/stretchr/testify v1.9.0 + github.com/stretchr/testify v1.10.0 go.opentelemetry.io/collector/component v0.103.0 go.opentelemetry.io/collector/confmap v0.103.0 go.opentelemetry.io/collector/consumer v0.103.0 go.opentelemetry.io/collector/exporter v0.103.0 go.opentelemetry.io/collector/featuregate v1.10.0 go.opentelemetry.io/collector/pdata v1.10.0 - go.opentelemetry.io/collector/semconv v0.103.0 + go.opentelemetry.io/collector/semconv v0.116.0 go.opentelemetry.io/otel/metric v1.27.0 go.opentelemetry.io/otel/trace v1.27.0 go.uber.org/goleak v1.3.0 diff --git a/exporter/awsxrayexporter/go.sum b/exporter/awsxrayexporter/go.sum index 63352824831a..1cc70bbb5cfa 100644 --- a/exporter/awsxrayexporter/go.sum +++ b/exporter/awsxrayexporter/go.sum @@ -92,6 +92,8 @@ github.com/stretchr/objx v0.5.2/go.mod h1:FRsXN1f5AsAjCGJKqEizvkpNtU+EGNCLh3NxZ/ github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI= github.com/stretchr/testify v1.9.0 h1:HtqpIVDClZ4nwg75+f6Lvsy/wHu+3BoSGCbBAcpTsTg= github.com/stretchr/testify v1.9.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY= +github.com/stretchr/testify v1.10.0 h1:Xv5erBjTwe/5IxqUQTdXv5kgmIvbHo3QQyRwhJsOfJA= +github.com/stretchr/testify v1.10.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY= github.com/yuin/goldmark v1.1.27/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= github.com/yuin/goldmark v1.2.1/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= go.opentelemetry.io/collector v0.103.0 h1:mssWo1y31p1F/SRsSBnVUX6YocgawCqM1blpE+hkWog= @@ -120,6 +122,8 @@ go.opentelemetry.io/collector/receiver v0.103.0 h1:V3JBKkX+7e/NYpDDZVyeu2VQB1/lL go.opentelemetry.io/collector/receiver v0.103.0/go.mod h1:Yybv4ynKFdMOYViWWPMmjkugR89FSQN0P37wP6mX6qM= go.opentelemetry.io/collector/semconv v0.103.0 h1:5tlVoZlo9USHAU2Bz4YrEste0Vm5AMufXkYJhAVve1Q= go.opentelemetry.io/collector/semconv v0.103.0/go.mod h1:yMVUCNoQPZVq/IPfrHrnntZTWsLf5YGZ7qwKulIl5hw= +go.opentelemetry.io/collector/semconv v0.116.0 h1:63xCZomsKJAWmKGWD3lnORiE3WKW6AO4LjnzcHzGx3Y= +go.opentelemetry.io/collector/semconv v0.116.0/go.mod h1:N6XE8Q0JKgBN2fAhkUQtqK9LT7rEGR6+Wu/Rtbal1iI= go.opentelemetry.io/otel v1.27.0 h1:9BZoF3yMK/O1AafMiQTVu0YDj5Ea4hPhxCs7sGva+cg= go.opentelemetry.io/otel v1.27.0/go.mod h1:DMpAK8fzYRzs+bi3rS5REupisuqTheUlSZJ1WnZaPAQ= go.opentelemetry.io/otel/exporters/prometheus v0.49.0 h1:Er5I1g/YhfYv9Affk9nJLfH/+qCCVVg1f2R9AbJfqDQ= diff --git a/exporter/awsxrayexporter/internal/translator/aws.go b/exporter/awsxrayexporter/internal/translator/aws.go index e312e27cf1ff..6641ae12b65d 100644 --- a/exporter/awsxrayexporter/internal/translator/aws.go +++ b/exporter/awsxrayexporter/internal/translator/aws.go @@ -9,15 +9,12 @@ import ( "github.com/aws/aws-sdk-go/aws" "go.opentelemetry.io/collector/pdata/pcommon" + conventionsV127 "go.opentelemetry.io/collector/semconv/v1.27.0" conventions "go.opentelemetry.io/collector/semconv/v1.6.1" awsxray "github.com/open-telemetry/opentelemetry-collector-contrib/internal/aws/xray" ) -const ( - AttributeTelemetryDistroVersion = "telemetry.distro.version" -) - func makeAws(attributes map[string]pcommon.Value, resource pcommon.Resource, logGroupNames []string) (map[string]pcommon.Value, *awsxray.AWSData) { var ( cloud string @@ -94,7 +91,7 @@ func makeAws(attributes map[string]pcommon.Value, resource pcommon.Resource, log sdkLanguage = value.Str() case conventions.AttributeTelemetrySDKVersion: sdkVersion = value.Str() - case conventions.AttributeTelemetryAutoVersion, AttributeTelemetryDistroVersion: + case conventions.AttributeTelemetryAutoVersion, conventionsV127.AttributeTelemetryDistroVersion: autoVersion = value.Str() case conventions.AttributeContainerID: containerID = value.Str() diff --git a/exporter/awsxrayexporter/internal/translator/aws_test.go b/exporter/awsxrayexporter/internal/translator/aws_test.go index 4c8c78ae3c25..f9c1109a7f40 100644 --- a/exporter/awsxrayexporter/internal/translator/aws_test.go +++ b/exporter/awsxrayexporter/internal/translator/aws_test.go @@ -9,6 +9,7 @@ import ( "github.com/aws/aws-sdk-go/aws" "github.com/stretchr/testify/assert" "go.opentelemetry.io/collector/pdata/pcommon" + conventionsV127 "go.opentelemetry.io/collector/semconv/v1.27.0" conventions "go.opentelemetry.io/collector/semconv/v1.6.1" awsxray "github.com/open-telemetry/opentelemetry-collector-contrib/internal/aws/xray" @@ -366,7 +367,7 @@ func TestJavaAutoInstrumentationStable(t *testing.T) { resource.Attributes().PutStr(conventions.AttributeTelemetrySDKName, "opentelemetry") resource.Attributes().PutStr(conventions.AttributeTelemetrySDKLanguage, "java") resource.Attributes().PutStr(conventions.AttributeTelemetrySDKVersion, "1.2.3") - resource.Attributes().PutStr(AttributeTelemetryDistroVersion, "3.4.5") + resource.Attributes().PutStr(conventionsV127.AttributeTelemetryDistroVersion, "3.4.5") filtered, awsData := makeAws(attributes, resource, nil) diff --git a/exporter/awsxrayexporter/internal/translator/cause.go b/exporter/awsxrayexporter/internal/translator/cause.go index 1408983b20cd..ae9bcf73d253 100644 --- a/exporter/awsxrayexporter/internal/translator/cause.go +++ b/exporter/awsxrayexporter/internal/translator/cause.go @@ -14,6 +14,7 @@ import ( "github.com/aws/aws-sdk-go/aws" "go.opentelemetry.io/collector/pdata/pcommon" "go.opentelemetry.io/collector/pdata/ptrace" + conventionsV127 "go.opentelemetry.io/collector/semconv/v1.27.0" conventions "go.opentelemetry.io/collector/semconv/v1.6.1" awsxray "github.com/open-telemetry/opentelemetry-collector-contrib/internal/aws/xray" @@ -24,7 +25,6 @@ import ( const ExceptionEventName = "exception" const AwsIndividualHTTPEventName = "HTTP request failure" const AwsIndividualHTTPErrorEventType = "aws.http.error.event" -const AwsIndividualHTTPErrorCodeAttr = "http.response.status_code" const AwsIndividualHTTPErrorMsgAttr = "aws.http.error_message" func makeCause(span ptrace.Span, attributes map[string]pcommon.Value, resource pcommon.Resource) (isError, isFault, isThrottle bool, @@ -88,7 +88,7 @@ func makeCause(span ptrace.Span, attributes map[string]pcommon.Value, resource p parsed := parseException(exceptionType, message, stacktrace, isRemote, language) exceptions = append(exceptions, parsed...) } else if isAwsSdkSpan && event.Name() == AwsIndividualHTTPEventName { - errorCode, ok1 := event.Attributes().Get(AwsIndividualHTTPErrorCodeAttr) + errorCode, ok1 := event.Attributes().Get(conventionsV127.AttributeHTTPResponseStatusCode) errorMessage, ok2 := event.Attributes().Get(AwsIndividualHTTPErrorMsgAttr) if ok1 && ok2 { eventEpochTime := event.Timestamp().AsTime().UnixMicro() @@ -151,7 +151,7 @@ func makeCause(span ptrace.Span, attributes map[string]pcommon.Value, resource p val, ok := span.Attributes().Get(conventions.AttributeHTTPStatusCode) if !ok { - val, ok = span.Attributes().Get(AwsIndividualHTTPErrorCodeAttr) + val, ok = span.Attributes().Get(conventionsV127.AttributeHTTPResponseStatusCode) } switch { diff --git a/exporter/awsxrayexporter/internal/translator/cause_test.go b/exporter/awsxrayexporter/internal/translator/cause_test.go index 95dcb22681ec..2194fdd68b29 100644 --- a/exporter/awsxrayexporter/internal/translator/cause_test.go +++ b/exporter/awsxrayexporter/internal/translator/cause_test.go @@ -12,6 +12,7 @@ import ( "github.com/stretchr/testify/require" "go.opentelemetry.io/collector/pdata/pcommon" "go.opentelemetry.io/collector/pdata/ptrace" + conventionsV127 "go.opentelemetry.io/collector/semconv/v1.27.0" conventions "go.opentelemetry.io/collector/semconv/v1.6.1" ) @@ -68,7 +69,7 @@ func TestMakeCauseAwsSdkSpan(t *testing.T) { event1 := span.Events().AppendEmpty() event1.SetName(AwsIndividualHTTPEventName) - event1.Attributes().PutStr(AwsIndividualHTTPErrorCodeAttr, "503") + event1.Attributes().PutStr(conventionsV127.AttributeHTTPResponseStatusCode, "503") event1.Attributes().PutStr(AwsIndividualHTTPErrorMsgAttr, "service is temporarily unavailable") timestamp := pcommon.NewTimestampFromTime(time.UnixMicro(1696954761000001)) event1.SetTimestamp(timestamp) @@ -201,7 +202,7 @@ func TestCauseWithStatusMessageStable(t *testing.T) { attributes := make(map[string]any) attributes[conventions.AttributeHTTPMethod] = "POST" attributes[conventions.AttributeHTTPURL] = "https://api.example.com/widgets" - attributes[AwsIndividualHTTPErrorCodeAttr] = 500 + attributes[conventionsV127.AttributeHTTPResponseStatusCode] = 500 span := constructExceptionServerSpan(attributes, ptrace.StatusCodeError) span.Status().SetMessage(errorMsg) filtered, _ := makeHTTP(span) @@ -251,7 +252,7 @@ func TestCauseWithHttpStatusMessageStable(t *testing.T) { attributes := make(map[string]any) attributes[conventions.AttributeHTTPMethod] = "POST" attributes[conventions.AttributeHTTPURL] = "https://api.example.com/widgets" - attributes[AwsIndividualHTTPErrorCodeAttr] = 500 + attributes[conventionsV127.AttributeHTTPResponseStatusCode] = 500 attributes["http.status_text"] = errorMsg span := constructExceptionServerSpan(attributes, ptrace.StatusCodeError) filtered, _ := makeHTTP(span) @@ -300,7 +301,7 @@ func TestCauseWithZeroStatusMessageAndFaultHttpCodeStable(t *testing.T) { attributes := make(map[string]any) attributes[conventions.AttributeHTTPMethod] = "POST" attributes[conventions.AttributeHTTPURL] = "https://api.example.com/widgets" - attributes[AwsIndividualHTTPErrorCodeAttr] = 500 + attributes[conventionsV127.AttributeHTTPResponseStatusCode] = 500 attributes["http.status_text"] = errorMsg span := constructExceptionServerSpan(attributes, ptrace.StatusCodeUnset) @@ -417,7 +418,7 @@ func TestCauseWithZeroStatusMessageAndFaultErrorCodeStable(t *testing.T) { attributes := make(map[string]any) attributes[conventions.AttributeHTTPMethod] = "POST" attributes[conventions.AttributeHTTPURL] = "https://api.example.com/widgets" - attributes[AwsIndividualHTTPErrorCodeAttr] = 400 + attributes[conventionsV127.AttributeHTTPResponseStatusCode] = 400 attributes["http.status_text"] = errorMsg span := constructExceptionServerSpan(attributes, ptrace.StatusCodeUnset) @@ -462,7 +463,7 @@ func TestCauseWithClientErrorMessageStable(t *testing.T) { attributes := make(map[string]any) attributes[conventions.AttributeHTTPMethod] = "POST" attributes[conventions.AttributeHTTPURL] = "https://api.example.com/widgets" - attributes[AwsIndividualHTTPErrorCodeAttr] = 499 + attributes[conventionsV127.AttributeHTTPResponseStatusCode] = 499 attributes["http.status_text"] = errorMsg span := constructExceptionServerSpan(attributes, ptrace.StatusCodeError) @@ -504,7 +505,7 @@ func TestCauseWithThrottledStable(t *testing.T) { attributes := make(map[string]any) attributes[conventions.AttributeHTTPMethod] = "POST" attributes[conventions.AttributeHTTPURL] = "https://api.example.com/widgets" - attributes[AwsIndividualHTTPErrorCodeAttr] = 429 + attributes[conventionsV127.AttributeHTTPResponseStatusCode] = 429 attributes["http.status_text"] = errorMsg span := constructExceptionServerSpan(attributes, ptrace.StatusCodeError) diff --git a/exporter/awsxrayexporter/internal/translator/http.go b/exporter/awsxrayexporter/internal/translator/http.go index 475d5fc89aa7..55b633bf2e81 100644 --- a/exporter/awsxrayexporter/internal/translator/http.go +++ b/exporter/awsxrayexporter/internal/translator/http.go @@ -10,25 +10,12 @@ import ( "github.com/aws/aws-sdk-go/aws" "go.opentelemetry.io/collector/pdata/pcommon" "go.opentelemetry.io/collector/pdata/ptrace" + conventionsV127 "go.opentelemetry.io/collector/semconv/v1.27.0" conventions "go.opentelemetry.io/collector/semconv/v1.6.1" awsxray "github.com/open-telemetry/opentelemetry-collector-contrib/internal/aws/xray" ) -const ( - AttributeHTTPRequestMethod = "http.request.method" - AttributeHTTPResponseStatusCode = "http.response.status_code" - AttributeServerAddress = "server.address" - AttributeServerPort = "server.port" - AttributeNetworkPeerAddress = "network.peer.address" - AttributeClientAddress = "client.address" - AttributeURLScheme = "url.scheme" - AttributeURLFull = "url.full" - AttributeURLPath = "url.path" - AttributeURLQuery = "url.query" - AttributeUserAgentOriginal = "user_agent.original" -) - func makeHTTP(span ptrace.Span) (map[string]pcommon.Value, *awsxray.HTTPData) { var ( info = awsxray.HTTPData{ @@ -49,30 +36,30 @@ func makeHTTP(span ptrace.Span) (map[string]pcommon.Value, *awsxray.HTTPData) { span.Attributes().Range(func(key string, value pcommon.Value) bool { switch key { - case conventions.AttributeHTTPMethod, AttributeHTTPRequestMethod: + case conventions.AttributeHTTPMethod, conventionsV127.AttributeHTTPRequestMethod: info.Request.Method = awsxray.String(value.Str()) hasHTTP = true case conventions.AttributeHTTPClientIP: info.Request.ClientIP = awsxray.String(value.Str()) hasHTTP = true - case conventions.AttributeHTTPUserAgent, AttributeUserAgentOriginal: + case conventions.AttributeHTTPUserAgent, conventionsV127.AttributeUserAgentOriginal: info.Request.UserAgent = awsxray.String(value.Str()) hasHTTP = true - case conventions.AttributeHTTPStatusCode, AttributeHTTPResponseStatusCode: + case conventions.AttributeHTTPStatusCode, conventionsV127.AttributeHTTPResponseStatusCode: info.Response.Status = aws.Int64(value.Int()) hasHTTP = true - case conventions.AttributeHTTPURL, AttributeURLFull: + case conventions.AttributeHTTPURL, conventionsV127.AttributeURLFull: urlParts[conventions.AttributeHTTPURL] = value.Str() hasHTTP = true hasHTTPRequestURLAttributes = true - case conventions.AttributeHTTPScheme, AttributeURLScheme: + case conventions.AttributeHTTPScheme, conventionsV127.AttributeURLScheme: urlParts[conventions.AttributeHTTPScheme] = value.Str() hasHTTP = true case conventions.AttributeHTTPHost: urlParts[key] = value.Str() hasHTTP = true hasHTTPRequestURLAttributes = true - case conventions.AttributeHTTPTarget, AttributeURLQuery: + case conventions.AttributeHTTPTarget, conventionsV127.AttributeURLQuery: urlParts[conventions.AttributeHTTPTarget] = value.Str() hasHTTP = true case conventions.AttributeHTTPServerName: @@ -107,7 +94,7 @@ func makeHTTP(span ptrace.Span) (map[string]pcommon.Value, *awsxray.HTTPData) { urlParts[key] = value.Str() hasHTTPRequestURLAttributes = true hasNetPeerAddr = true - case AttributeNetworkPeerAddress: + case conventionsV127.AttributeNetworkPeerAddress: // Prefer HTTP forwarded information (AttributeHTTPClientIP) when present. if net.ParseIP(value.Str()) != nil { if info.Request.ClientIP == nil { @@ -116,17 +103,17 @@ func makeHTTP(span ptrace.Span) (map[string]pcommon.Value, *awsxray.HTTPData) { hasHTTPRequestURLAttributes = true hasNetPeerAddr = true } - case AttributeClientAddress: + case conventionsV127.AttributeClientAddress: if net.ParseIP(value.Str()) != nil { info.Request.ClientIP = awsxray.String(value.Str()) } - case AttributeURLPath: + case conventionsV127.AttributeURLPath: urlParts[key] = value.Str() hasHTTP = true - case AttributeServerAddress: + case conventionsV127.AttributeServerAddress: urlParts[key] = value.Str() hasHTTPRequestURLAttributes = true - case AttributeServerPort: + case conventionsV127.AttributeServerPort: urlParts[key] = value.Str() if len(urlParts[key]) == 0 { urlParts[key] = strconv.FormatInt(value.Int(), 10) @@ -247,13 +234,13 @@ func constructServerURL(urlParts map[string]string) string { if !ok { host, ok = urlParts[conventions.AttributeHostName] if !ok { - host = urlParts[AttributeServerAddress] + host = urlParts[conventionsV127.AttributeServerAddress] } } } port, ok = urlParts[conventions.AttributeNetHostPort] if !ok { - port, ok = urlParts[AttributeServerPort] + port, ok = urlParts[conventionsV127.AttributeServerPort] if !ok { port = "" } @@ -267,7 +254,7 @@ func constructServerURL(urlParts map[string]string) string { if ok { url += target } else { - path, ok := urlParts[AttributeURLPath] + path, ok := urlParts[conventionsV127.AttributeURLPath] if ok { url += path } else { diff --git a/exporter/awsxrayexporter/internal/translator/http_test.go b/exporter/awsxrayexporter/internal/translator/http_test.go index f4b9f79c182b..ad1033b2848c 100644 --- a/exporter/awsxrayexporter/internal/translator/http_test.go +++ b/exporter/awsxrayexporter/internal/translator/http_test.go @@ -13,6 +13,7 @@ import ( "github.com/stretchr/testify/require" "go.opentelemetry.io/collector/pdata/pcommon" "go.opentelemetry.io/collector/pdata/ptrace" + conventionsV127 "go.opentelemetry.io/collector/semconv/v1.27.0" conventions "go.opentelemetry.io/collector/semconv/v1.6.1" ) @@ -36,9 +37,9 @@ func TestClientSpanWithURLAttribute(t *testing.T) { func TestClientSpanWithURLAttributeStable(t *testing.T) { attributes := make(map[string]any) - attributes[AttributeHTTPRequestMethod] = "GET" - attributes[AttributeURLFull] = "https://api.example.com/users/junit" - attributes[AttributeHTTPResponseStatusCode] = 200 + attributes[conventionsV127.AttributeHTTPRequestMethod] = "GET" + attributes[conventionsV127.AttributeURLFull] = "https://api.example.com/users/junit" + attributes[conventionsV127.AttributeHTTPResponseStatusCode] = 200 span := constructHTTPClientSpan(attributes) filtered, httpData := makeHTTP(span) @@ -75,11 +76,11 @@ func TestClientSpanWithSchemeHostTargetAttributes(t *testing.T) { func TestClientSpanWithSchemeHostTargetAttributesStable(t *testing.T) { attributes := make(map[string]any) - attributes[conventions.AttributeHTTPMethod] = "GET" - attributes[conventions.AttributeHTTPScheme] = "https" - attributes[conventions.AttributeHTTPHost] = "api.example.com" - attributes[AttributeURLQuery] = "/users/junit" - attributes[conventions.AttributeHTTPStatusCode] = 200 + attributes[conventionsV127.AttributeHTTPRequestMethod] = "GET" + attributes[conventionsV127.AttributeURLScheme] = "https" + attributes[conventionsV127.AttributeServerAddress] = "api.example.com" + attributes[conventionsV127.AttributeURLQuery] = "/users/junit" + attributes[conventionsV127.AttributeHTTPResponseStatusCode] = 200 attributes["user.id"] = "junit" span := constructHTTPClientSpan(attributes) @@ -122,13 +123,13 @@ func TestClientSpanWithPeerAttributes(t *testing.T) { func TestClientSpanWithPeerAttributesStable(t *testing.T) { attributes := make(map[string]any) - attributes[AttributeHTTPRequestMethod] = "GET" - attributes[AttributeURLScheme] = "http" - attributes[conventions.AttributeNetPeerName] = "kb234.example.com" - attributes[conventions.AttributeNetPeerPort] = 8080 - attributes[conventions.AttributeNetPeerIP] = "10.8.17.36" - attributes[AttributeURLQuery] = "/users/junit" - attributes[conventions.AttributeHTTPStatusCode] = 200 + attributes[conventionsV127.AttributeHTTPRequestMethod] = "GET" + attributes[conventionsV127.AttributeURLScheme] = "http" + attributes[conventionsV127.AttributeServerAddress] = "kb234.example.com" + attributes[conventionsV127.AttributeServerPort] = 8080 + attributes[conventionsV127.AttributeNetworkPeerAddress] = "10.8.17.36" + attributes[conventionsV127.AttributeURLQuery] = "/users/junit" + attributes[conventionsV127.AttributeHTTPResponseStatusCode] = 200 span := constructHTTPClientSpan(attributes) filtered, httpData := makeHTTP(span) @@ -161,9 +162,9 @@ func TestClientSpanWithHttpPeerAttributes(t *testing.T) { func TestClientSpanWithHttpPeerAttributesStable(t *testing.T) { attributes := make(map[string]any) - attributes[AttributeURLFull] = "https://api.example.com/users/junit" - attributes[AttributeClientAddress] = "1.2.3.4" - attributes[AttributeNetworkPeerAddress] = "10.8.17.36" + attributes[conventionsV127.AttributeURLFull] = "https://api.example.com/users/junit" + attributes[conventionsV127.AttributeClientAddress] = "1.2.3.4" + attributes[conventionsV127.AttributeNetworkPeerAddress] = "10.8.17.36" span := constructHTTPClientSpan(attributes) filtered, httpData := makeHTTP(span) @@ -234,11 +235,11 @@ func TestServerSpanWithURLAttribute(t *testing.T) { func TestServerSpanWithURLAttributeStable(t *testing.T) { attributes := make(map[string]any) - attributes[AttributeHTTPRequestMethod] = "GET" - attributes[AttributeURLFull] = "https://api.example.com/users/junit" - attributes[AttributeClientAddress] = "192.168.15.32" - attributes[AttributeUserAgentOriginal] = "PostmanRuntime/7.21.0" - attributes[AttributeHTTPResponseStatusCode] = 200 + attributes[conventionsV127.AttributeHTTPRequestMethod] = "GET" + attributes[conventionsV127.AttributeURLFull] = "https://api.example.com/users/junit" + attributes[conventionsV127.AttributeClientAddress] = "192.168.15.32" + attributes[conventionsV127.AttributeUserAgentOriginal] = "PostmanRuntime/7.21.0" + attributes[conventionsV127.AttributeHTTPResponseStatusCode] = 200 span := constructHTTPServerSpan(attributes) filtered, httpData := makeHTTP(span) @@ -275,12 +276,12 @@ func TestServerSpanWithSchemeHostTargetAttributes(t *testing.T) { func TestServerSpanWithSchemeHostTargetAttributesStable(t *testing.T) { attributes := make(map[string]any) - attributes[AttributeHTTPRequestMethod] = "GET" - attributes[AttributeURLScheme] = "https" - attributes[AttributeServerAddress] = "api.example.com" - attributes[AttributeURLQuery] = "/users/junit" - attributes[AttributeClientAddress] = "192.168.15.32" - attributes[AttributeHTTPResponseStatusCode] = 200 + attributes[conventionsV127.AttributeHTTPRequestMethod] = "GET" + attributes[conventionsV127.AttributeURLScheme] = "https" + attributes[conventionsV127.AttributeServerAddress] = "api.example.com" + attributes[conventionsV127.AttributeURLQuery] = "/users/junit" + attributes[conventionsV127.AttributeClientAddress] = "192.168.15.32" + attributes[conventionsV127.AttributeHTTPResponseStatusCode] = 200 span := constructHTTPServerSpan(attributes) filtered, httpData := makeHTTP(span) @@ -318,13 +319,13 @@ func TestServerSpanWithSchemeServernamePortTargetAttributes(t *testing.T) { func TestServerSpanWithSchemeServernamePortTargetAttributesStable(t *testing.T) { attributes := make(map[string]any) - attributes[AttributeHTTPRequestMethod] = "GET" - attributes[AttributeURLScheme] = "https" - attributes[AttributeServerAddress] = "api.example.com" - attributes[AttributeServerPort] = 443 - attributes[AttributeURLQuery] = "/users/junit" - attributes[AttributeClientAddress] = "192.168.15.32" - attributes[AttributeHTTPResponseStatusCode] = 200 + attributes[conventionsV127.AttributeHTTPRequestMethod] = "GET" + attributes[conventionsV127.AttributeURLScheme] = "https" + attributes[conventionsV127.AttributeServerAddress] = "api.example.com" + attributes[conventionsV127.AttributeServerPort] = 443 + attributes[conventionsV127.AttributeURLQuery] = "/users/junit" + attributes[conventionsV127.AttributeClientAddress] = "192.168.15.32" + attributes[conventionsV127.AttributeHTTPResponseStatusCode] = 200 span := constructHTTPServerSpan(attributes) filtered, httpData := makeHTTP(span) @@ -364,13 +365,13 @@ func TestServerSpanWithSchemeNamePortTargetAttributes(t *testing.T) { func TestServerSpanWithSchemeNamePortTargetAttributesStable(t *testing.T) { attributes := make(map[string]any) - attributes[AttributeHTTPRequestMethod] = "GET" - attributes[AttributeURLScheme] = "http" - attributes[AttributeServerAddress] = "kb234.example.com" - attributes[AttributeServerPort] = 8080 - attributes[AttributeURLPath] = "/users/junit" - attributes[AttributeClientAddress] = "192.168.15.32" - attributes[AttributeHTTPResponseStatusCode] = 200 + attributes[conventionsV127.AttributeHTTPRequestMethod] = "GET" + attributes[conventionsV127.AttributeURLScheme] = "http" + attributes[conventionsV127.AttributeServerAddress] = "kb234.example.com" + attributes[conventionsV127.AttributeServerPort] = 8080 + attributes[conventionsV127.AttributeURLPath] = "/users/junit" + attributes[conventionsV127.AttributeClientAddress] = "192.168.15.32" + attributes[conventionsV127.AttributeHTTPResponseStatusCode] = 200 span := constructHTTPServerSpan(attributes) timeEvents := constructTimedEventsWithReceivedMessageEvent(span.EndTimestamp()) timeEvents.CopyTo(span.Events()) @@ -414,13 +415,13 @@ func TestSpanWithNotEnoughHTTPRequestURLAttributes(t *testing.T) { func TestSpanWithNotEnoughHTTPRequestURLAttributesStable(t *testing.T) { attributes := make(map[string]any) - attributes[AttributeHTTPRequestMethod] = "GET" - attributes[AttributeURLScheme] = "http" - attributes[AttributeClientAddress] = "192.168.15.32" - attributes[AttributeUserAgentOriginal] = "PostmanRuntime/7.21.0" - attributes[AttributeURLPath] = "/users/junit" - attributes[AttributeServerPort] = 443 - attributes[AttributeHTTPResponseStatusCode] = 200 + attributes[conventionsV127.AttributeHTTPRequestMethod] = "GET" + attributes[conventionsV127.AttributeURLScheme] = "http" + attributes[conventionsV127.AttributeClientAddress] = "192.168.15.32" + attributes[conventionsV127.AttributeUserAgentOriginal] = "PostmanRuntime/7.21.0" + attributes[conventionsV127.AttributeURLPath] = "/users/junit" + attributes[conventionsV127.AttributeServerPort] = 443 + attributes[conventionsV127.AttributeHTTPResponseStatusCode] = 200 span := constructHTTPServerSpan(attributes) timeEvents := constructTimedEventsWithReceivedMessageEvent(span.EndTimestamp()) timeEvents.CopyTo(span.Events()) @@ -440,20 +441,20 @@ func TestSpanWithNotEnoughHTTPRequestURLAttributesStable(t *testing.T) { func TestSpanWithNotEnoughHTTPRequestURLAttributesDuplicated(t *testing.T) { attributes := make(map[string]any) attributes[conventions.AttributeHTTPMethod] = "GET" - attributes[AttributeHTTPRequestMethod] = "GET" + attributes[conventionsV127.AttributeHTTPRequestMethod] = "GET" attributes[conventions.AttributeHTTPScheme] = "http" - attributes[AttributeURLScheme] = "http" + attributes[conventionsV127.AttributeURLScheme] = "http" attributes[conventions.AttributeHTTPClientIP] = "192.168.15.32" - attributes[AttributeClientAddress] = "192.168.15.32" + attributes[conventionsV127.AttributeClientAddress] = "192.168.15.32" attributes[conventions.AttributeHTTPUserAgent] = "PostmanRuntime/7.21.0" - attributes[AttributeUserAgentOriginal] = "PostmanRuntime/7.21.0" + attributes[conventionsV127.AttributeUserAgentOriginal] = "PostmanRuntime/7.21.0" attributes[conventions.AttributeHTTPTarget] = "/users/junit" - attributes[AttributeURLPath] = "/users/junit" + attributes[conventionsV127.AttributeURLPath] = "/users/junit" attributes[conventions.AttributeNetHostPort] = 443 - attributes[AttributeServerPort] = 443 + attributes[conventionsV127.AttributeServerPort] = 443 attributes[conventions.AttributeNetPeerPort] = 8080 attributes[conventions.AttributeHTTPStatusCode] = 200 - attributes[AttributeHTTPResponseStatusCode] = 200 + attributes[conventionsV127.AttributeHTTPResponseStatusCode] = 200 span := constructHTTPServerSpan(attributes) timeEvents := constructTimedEventsWithReceivedMessageEvent(span.EndTimestamp()) timeEvents.CopyTo(span.Events()) @@ -472,8 +473,8 @@ func TestSpanWithNotEnoughHTTPRequestURLAttributesDuplicated(t *testing.T) { func TestSpanWithClientAddrWithoutNetworkPeerAddr(t *testing.T) { attributes := make(map[string]any) - attributes[AttributeURLFull] = "https://api.example.com/users/junit" - attributes[AttributeClientAddress] = "192.168.15.32" + attributes[conventionsV127.AttributeURLFull] = "https://api.example.com/users/junit" + attributes[conventionsV127.AttributeClientAddress] = "192.168.15.32" span := constructHTTPServerSpan(attributes) _, httpData := makeHTTP(span) @@ -482,9 +483,9 @@ func TestSpanWithClientAddrWithoutNetworkPeerAddr(t *testing.T) { } func TestSpanWithClientAddrAndNetworkPeerAddr(t *testing.T) { attributes := make(map[string]any) - attributes[AttributeURLFull] = "https://api.example.com/users/junit" - attributes[AttributeClientAddress] = "192.168.15.32" - attributes[AttributeNetworkPeerAddress] = "192.168.15.32" + attributes[conventionsV127.AttributeURLFull] = "https://api.example.com/users/junit" + attributes[conventionsV127.AttributeClientAddress] = "192.168.15.32" + attributes[conventionsV127.AttributeNetworkPeerAddress] = "192.168.15.32" span := constructHTTPServerSpan(attributes) _, httpData := makeHTTP(span) @@ -495,9 +496,9 @@ func TestSpanWithClientAddrAndNetworkPeerAddr(t *testing.T) { func TestSpanWithClientAddrNotIP(t *testing.T) { attributes := make(map[string]any) - attributes[AttributeURLFull] = "https://api.example.com/users/junit" - attributes[AttributeClientAddress] = "api.example.com" - attributes[AttributeNetworkPeerAddress] = "api.example.com" + attributes[conventionsV127.AttributeURLFull] = "https://api.example.com/users/junit" + attributes[conventionsV127.AttributeClientAddress] = "api.example.com" + attributes[conventionsV127.AttributeNetworkPeerAddress] = "api.example.com" span := constructHTTPServerSpan(attributes) _, httpData := makeHTTP(span) From 49f2b4fc479b4e64a729fe14b791bf3ac52d45da Mon Sep 17 00:00:00 2001 From: Zhonghao Zhao Date: Wed, 18 Dec 2024 22:51:41 +0000 Subject: [PATCH 3/7] Update unit tests. --- .../internal/translator/aws_test.go | 6 +++--- .../internal/translator/cause_test.go | 20 +++++++++---------- 2 files changed, 13 insertions(+), 13 deletions(-) diff --git a/exporter/awsxrayexporter/internal/translator/aws_test.go b/exporter/awsxrayexporter/internal/translator/aws_test.go index f9c1109a7f40..903c4c16c6ea 100644 --- a/exporter/awsxrayexporter/internal/translator/aws_test.go +++ b/exporter/awsxrayexporter/internal/translator/aws_test.go @@ -364,9 +364,9 @@ func TestJavaAutoInstrumentation(t *testing.T) { func TestJavaAutoInstrumentationStable(t *testing.T) { attributes := make(map[string]pcommon.Value) resource := pcommon.NewResource() - resource.Attributes().PutStr(conventions.AttributeTelemetrySDKName, "opentelemetry") - resource.Attributes().PutStr(conventions.AttributeTelemetrySDKLanguage, "java") - resource.Attributes().PutStr(conventions.AttributeTelemetrySDKVersion, "1.2.3") + resource.Attributes().PutStr(conventionsV127.AttributeTelemetrySDKName, "opentelemetry") + resource.Attributes().PutStr(conventionsV127.AttributeTelemetrySDKLanguage, "java") + resource.Attributes().PutStr(conventionsV127.AttributeTelemetrySDKVersion, "1.2.3") resource.Attributes().PutStr(conventionsV127.AttributeTelemetryDistroVersion, "3.4.5") filtered, awsData := makeAws(attributes, resource, nil) diff --git a/exporter/awsxrayexporter/internal/translator/cause_test.go b/exporter/awsxrayexporter/internal/translator/cause_test.go index 2194fdd68b29..62336f65d251 100644 --- a/exporter/awsxrayexporter/internal/translator/cause_test.go +++ b/exporter/awsxrayexporter/internal/translator/cause_test.go @@ -200,8 +200,8 @@ func TestCauseWithStatusMessage(t *testing.T) { func TestCauseWithStatusMessageStable(t *testing.T) { errorMsg := "this is a test" attributes := make(map[string]any) - attributes[conventions.AttributeHTTPMethod] = "POST" - attributes[conventions.AttributeHTTPURL] = "https://api.example.com/widgets" + attributes[conventionsV127.AttributeHTTPRequestMethod] = "POST" + attributes[conventionsV127.AttributeURLFull] = "https://api.example.com/widgets" attributes[conventionsV127.AttributeHTTPResponseStatusCode] = 500 span := constructExceptionServerSpan(attributes, ptrace.StatusCodeError) span.Status().SetMessage(errorMsg) @@ -299,8 +299,8 @@ func TestCauseWithZeroStatusMessageAndFaultHttpCode(t *testing.T) { func TestCauseWithZeroStatusMessageAndFaultHttpCodeStable(t *testing.T) { errorMsg := "this is a test" attributes := make(map[string]any) - attributes[conventions.AttributeHTTPMethod] = "POST" - attributes[conventions.AttributeHTTPURL] = "https://api.example.com/widgets" + attributes[conventionsV127.AttributeHTTPRequestMethod] = "POST" + attributes[conventionsV127.AttributeURLFull] = "https://api.example.com/widgets" attributes[conventionsV127.AttributeHTTPResponseStatusCode] = 500 attributes["http.status_text"] = errorMsg @@ -416,8 +416,8 @@ func TestCauseWithZeroStatusMessageAndFaultErrorCode(t *testing.T) { func TestCauseWithZeroStatusMessageAndFaultErrorCodeStable(t *testing.T) { errorMsg := "this is a test" attributes := make(map[string]any) - attributes[conventions.AttributeHTTPMethod] = "POST" - attributes[conventions.AttributeHTTPURL] = "https://api.example.com/widgets" + attributes[conventionsV127.AttributeHTTPRequestMethod] = "POST" + attributes[conventionsV127.AttributeURLFull] = "https://api.example.com/widgets" attributes[conventionsV127.AttributeHTTPResponseStatusCode] = 400 attributes["http.status_text"] = errorMsg @@ -461,8 +461,8 @@ func TestCauseWithClientErrorMessage(t *testing.T) { func TestCauseWithClientErrorMessageStable(t *testing.T) { errorMsg := "this is a test" attributes := make(map[string]any) - attributes[conventions.AttributeHTTPMethod] = "POST" - attributes[conventions.AttributeHTTPURL] = "https://api.example.com/widgets" + attributes[conventionsV127.AttributeHTTPRequestMethod] = "POST" + attributes[conventionsV127.AttributeURLFull] = "https://api.example.com/widgets" attributes[conventionsV127.AttributeHTTPResponseStatusCode] = 499 attributes["http.status_text"] = errorMsg @@ -503,8 +503,8 @@ func TestCauseWithThrottled(t *testing.T) { func TestCauseWithThrottledStable(t *testing.T) { errorMsg := "this is a test" attributes := make(map[string]any) - attributes[conventions.AttributeHTTPMethod] = "POST" - attributes[conventions.AttributeHTTPURL] = "https://api.example.com/widgets" + attributes[conventionsV127.AttributeHTTPRequestMethod] = "POST" + attributes[conventionsV127.AttributeURLFull] = "https://api.example.com/widgets" attributes[conventionsV127.AttributeHTTPResponseStatusCode] = 429 attributes["http.status_text"] = errorMsg From 4dcc70bcd7935bc6c329e331d875e907711eddd7 Mon Sep 17 00:00:00 2001 From: Zhonghao Zhao Date: Wed, 18 Dec 2024 23:35:37 +0000 Subject: [PATCH 4/7] Rename conventionsV127 to conventionsv127. --- .../internal/translator/aws.go | 4 +- .../internal/translator/aws_test.go | 10 +- .../internal/translator/cause.go | 6 +- .../internal/translator/cause_test.go | 36 ++--- .../internal/translator/http.go | 30 ++-- .../internal/translator/http_test.go | 132 +++++++++--------- 6 files changed, 109 insertions(+), 109 deletions(-) diff --git a/exporter/awsxrayexporter/internal/translator/aws.go b/exporter/awsxrayexporter/internal/translator/aws.go index 6641ae12b65d..52cd9b035c89 100644 --- a/exporter/awsxrayexporter/internal/translator/aws.go +++ b/exporter/awsxrayexporter/internal/translator/aws.go @@ -9,7 +9,7 @@ import ( "github.com/aws/aws-sdk-go/aws" "go.opentelemetry.io/collector/pdata/pcommon" - conventionsV127 "go.opentelemetry.io/collector/semconv/v1.27.0" + conventionsv127 "go.opentelemetry.io/collector/semconv/v1.27.0" conventions "go.opentelemetry.io/collector/semconv/v1.6.1" awsxray "github.com/open-telemetry/opentelemetry-collector-contrib/internal/aws/xray" @@ -91,7 +91,7 @@ func makeAws(attributes map[string]pcommon.Value, resource pcommon.Resource, log sdkLanguage = value.Str() case conventions.AttributeTelemetrySDKVersion: sdkVersion = value.Str() - case conventions.AttributeTelemetryAutoVersion, conventionsV127.AttributeTelemetryDistroVersion: + case conventions.AttributeTelemetryAutoVersion, conventionsv127.AttributeTelemetryDistroVersion: autoVersion = value.Str() case conventions.AttributeContainerID: containerID = value.Str() diff --git a/exporter/awsxrayexporter/internal/translator/aws_test.go b/exporter/awsxrayexporter/internal/translator/aws_test.go index 903c4c16c6ea..fb9222da7450 100644 --- a/exporter/awsxrayexporter/internal/translator/aws_test.go +++ b/exporter/awsxrayexporter/internal/translator/aws_test.go @@ -9,7 +9,7 @@ import ( "github.com/aws/aws-sdk-go/aws" "github.com/stretchr/testify/assert" "go.opentelemetry.io/collector/pdata/pcommon" - conventionsV127 "go.opentelemetry.io/collector/semconv/v1.27.0" + conventionsv127 "go.opentelemetry.io/collector/semconv/v1.27.0" conventions "go.opentelemetry.io/collector/semconv/v1.6.1" awsxray "github.com/open-telemetry/opentelemetry-collector-contrib/internal/aws/xray" @@ -364,10 +364,10 @@ func TestJavaAutoInstrumentation(t *testing.T) { func TestJavaAutoInstrumentationStable(t *testing.T) { attributes := make(map[string]pcommon.Value) resource := pcommon.NewResource() - resource.Attributes().PutStr(conventionsV127.AttributeTelemetrySDKName, "opentelemetry") - resource.Attributes().PutStr(conventionsV127.AttributeTelemetrySDKLanguage, "java") - resource.Attributes().PutStr(conventionsV127.AttributeTelemetrySDKVersion, "1.2.3") - resource.Attributes().PutStr(conventionsV127.AttributeTelemetryDistroVersion, "3.4.5") + resource.Attributes().PutStr(conventionsv127.AttributeTelemetrySDKName, "opentelemetry") + resource.Attributes().PutStr(conventionsv127.AttributeTelemetrySDKLanguage, "java") + resource.Attributes().PutStr(conventionsv127.AttributeTelemetrySDKVersion, "1.2.3") + resource.Attributes().PutStr(conventionsv127.AttributeTelemetryDistroVersion, "3.4.5") filtered, awsData := makeAws(attributes, resource, nil) diff --git a/exporter/awsxrayexporter/internal/translator/cause.go b/exporter/awsxrayexporter/internal/translator/cause.go index ae9bcf73d253..4f223b899cf6 100644 --- a/exporter/awsxrayexporter/internal/translator/cause.go +++ b/exporter/awsxrayexporter/internal/translator/cause.go @@ -14,7 +14,7 @@ import ( "github.com/aws/aws-sdk-go/aws" "go.opentelemetry.io/collector/pdata/pcommon" "go.opentelemetry.io/collector/pdata/ptrace" - conventionsV127 "go.opentelemetry.io/collector/semconv/v1.27.0" + conventionsv127 "go.opentelemetry.io/collector/semconv/v1.27.0" conventions "go.opentelemetry.io/collector/semconv/v1.6.1" awsxray "github.com/open-telemetry/opentelemetry-collector-contrib/internal/aws/xray" @@ -88,7 +88,7 @@ func makeCause(span ptrace.Span, attributes map[string]pcommon.Value, resource p parsed := parseException(exceptionType, message, stacktrace, isRemote, language) exceptions = append(exceptions, parsed...) } else if isAwsSdkSpan && event.Name() == AwsIndividualHTTPEventName { - errorCode, ok1 := event.Attributes().Get(conventionsV127.AttributeHTTPResponseStatusCode) + errorCode, ok1 := event.Attributes().Get(conventionsv127.AttributeHTTPResponseStatusCode) errorMessage, ok2 := event.Attributes().Get(AwsIndividualHTTPErrorMsgAttr) if ok1 && ok2 { eventEpochTime := event.Timestamp().AsTime().UnixMicro() @@ -151,7 +151,7 @@ func makeCause(span ptrace.Span, attributes map[string]pcommon.Value, resource p val, ok := span.Attributes().Get(conventions.AttributeHTTPStatusCode) if !ok { - val, ok = span.Attributes().Get(conventionsV127.AttributeHTTPResponseStatusCode) + val, ok = span.Attributes().Get(conventionsv127.AttributeHTTPResponseStatusCode) } switch { diff --git a/exporter/awsxrayexporter/internal/translator/cause_test.go b/exporter/awsxrayexporter/internal/translator/cause_test.go index 62336f65d251..f9e11cacc68f 100644 --- a/exporter/awsxrayexporter/internal/translator/cause_test.go +++ b/exporter/awsxrayexporter/internal/translator/cause_test.go @@ -12,7 +12,7 @@ import ( "github.com/stretchr/testify/require" "go.opentelemetry.io/collector/pdata/pcommon" "go.opentelemetry.io/collector/pdata/ptrace" - conventionsV127 "go.opentelemetry.io/collector/semconv/v1.27.0" + conventionsv127 "go.opentelemetry.io/collector/semconv/v1.27.0" conventions "go.opentelemetry.io/collector/semconv/v1.6.1" ) @@ -69,7 +69,7 @@ func TestMakeCauseAwsSdkSpan(t *testing.T) { event1 := span.Events().AppendEmpty() event1.SetName(AwsIndividualHTTPEventName) - event1.Attributes().PutStr(conventionsV127.AttributeHTTPResponseStatusCode, "503") + event1.Attributes().PutStr(conventionsv127.AttributeHTTPResponseStatusCode, "503") event1.Attributes().PutStr(AwsIndividualHTTPErrorMsgAttr, "service is temporarily unavailable") timestamp := pcommon.NewTimestampFromTime(time.UnixMicro(1696954761000001)) event1.SetTimestamp(timestamp) @@ -200,9 +200,9 @@ func TestCauseWithStatusMessage(t *testing.T) { func TestCauseWithStatusMessageStable(t *testing.T) { errorMsg := "this is a test" attributes := make(map[string]any) - attributes[conventionsV127.AttributeHTTPRequestMethod] = "POST" - attributes[conventionsV127.AttributeURLFull] = "https://api.example.com/widgets" - attributes[conventionsV127.AttributeHTTPResponseStatusCode] = 500 + attributes[conventionsv127.AttributeHTTPRequestMethod] = "POST" + attributes[conventionsv127.AttributeURLFull] = "https://api.example.com/widgets" + attributes[conventionsv127.AttributeHTTPResponseStatusCode] = 500 span := constructExceptionServerSpan(attributes, ptrace.StatusCodeError) span.Status().SetMessage(errorMsg) filtered, _ := makeHTTP(span) @@ -252,7 +252,7 @@ func TestCauseWithHttpStatusMessageStable(t *testing.T) { attributes := make(map[string]any) attributes[conventions.AttributeHTTPMethod] = "POST" attributes[conventions.AttributeHTTPURL] = "https://api.example.com/widgets" - attributes[conventionsV127.AttributeHTTPResponseStatusCode] = 500 + attributes[conventionsv127.AttributeHTTPResponseStatusCode] = 500 attributes["http.status_text"] = errorMsg span := constructExceptionServerSpan(attributes, ptrace.StatusCodeError) filtered, _ := makeHTTP(span) @@ -299,9 +299,9 @@ func TestCauseWithZeroStatusMessageAndFaultHttpCode(t *testing.T) { func TestCauseWithZeroStatusMessageAndFaultHttpCodeStable(t *testing.T) { errorMsg := "this is a test" attributes := make(map[string]any) - attributes[conventionsV127.AttributeHTTPRequestMethod] = "POST" - attributes[conventionsV127.AttributeURLFull] = "https://api.example.com/widgets" - attributes[conventionsV127.AttributeHTTPResponseStatusCode] = 500 + attributes[conventionsv127.AttributeHTTPRequestMethod] = "POST" + attributes[conventionsv127.AttributeURLFull] = "https://api.example.com/widgets" + attributes[conventionsv127.AttributeHTTPResponseStatusCode] = 500 attributes["http.status_text"] = errorMsg span := constructExceptionServerSpan(attributes, ptrace.StatusCodeUnset) @@ -416,9 +416,9 @@ func TestCauseWithZeroStatusMessageAndFaultErrorCode(t *testing.T) { func TestCauseWithZeroStatusMessageAndFaultErrorCodeStable(t *testing.T) { errorMsg := "this is a test" attributes := make(map[string]any) - attributes[conventionsV127.AttributeHTTPRequestMethod] = "POST" - attributes[conventionsV127.AttributeURLFull] = "https://api.example.com/widgets" - attributes[conventionsV127.AttributeHTTPResponseStatusCode] = 400 + attributes[conventionsv127.AttributeHTTPRequestMethod] = "POST" + attributes[conventionsv127.AttributeURLFull] = "https://api.example.com/widgets" + attributes[conventionsv127.AttributeHTTPResponseStatusCode] = 400 attributes["http.status_text"] = errorMsg span := constructExceptionServerSpan(attributes, ptrace.StatusCodeUnset) @@ -461,9 +461,9 @@ func TestCauseWithClientErrorMessage(t *testing.T) { func TestCauseWithClientErrorMessageStable(t *testing.T) { errorMsg := "this is a test" attributes := make(map[string]any) - attributes[conventionsV127.AttributeHTTPRequestMethod] = "POST" - attributes[conventionsV127.AttributeURLFull] = "https://api.example.com/widgets" - attributes[conventionsV127.AttributeHTTPResponseStatusCode] = 499 + attributes[conventionsv127.AttributeHTTPRequestMethod] = "POST" + attributes[conventionsv127.AttributeURLFull] = "https://api.example.com/widgets" + attributes[conventionsv127.AttributeHTTPResponseStatusCode] = 499 attributes["http.status_text"] = errorMsg span := constructExceptionServerSpan(attributes, ptrace.StatusCodeError) @@ -503,9 +503,9 @@ func TestCauseWithThrottled(t *testing.T) { func TestCauseWithThrottledStable(t *testing.T) { errorMsg := "this is a test" attributes := make(map[string]any) - attributes[conventionsV127.AttributeHTTPRequestMethod] = "POST" - attributes[conventionsV127.AttributeURLFull] = "https://api.example.com/widgets" - attributes[conventionsV127.AttributeHTTPResponseStatusCode] = 429 + attributes[conventionsv127.AttributeHTTPRequestMethod] = "POST" + attributes[conventionsv127.AttributeURLFull] = "https://api.example.com/widgets" + attributes[conventionsv127.AttributeHTTPResponseStatusCode] = 429 attributes["http.status_text"] = errorMsg span := constructExceptionServerSpan(attributes, ptrace.StatusCodeError) diff --git a/exporter/awsxrayexporter/internal/translator/http.go b/exporter/awsxrayexporter/internal/translator/http.go index 55b633bf2e81..445a30f8815b 100644 --- a/exporter/awsxrayexporter/internal/translator/http.go +++ b/exporter/awsxrayexporter/internal/translator/http.go @@ -10,7 +10,7 @@ import ( "github.com/aws/aws-sdk-go/aws" "go.opentelemetry.io/collector/pdata/pcommon" "go.opentelemetry.io/collector/pdata/ptrace" - conventionsV127 "go.opentelemetry.io/collector/semconv/v1.27.0" + conventionsv127 "go.opentelemetry.io/collector/semconv/v1.27.0" conventions "go.opentelemetry.io/collector/semconv/v1.6.1" awsxray "github.com/open-telemetry/opentelemetry-collector-contrib/internal/aws/xray" @@ -36,30 +36,30 @@ func makeHTTP(span ptrace.Span) (map[string]pcommon.Value, *awsxray.HTTPData) { span.Attributes().Range(func(key string, value pcommon.Value) bool { switch key { - case conventions.AttributeHTTPMethod, conventionsV127.AttributeHTTPRequestMethod: + case conventions.AttributeHTTPMethod, conventionsv127.AttributeHTTPRequestMethod: info.Request.Method = awsxray.String(value.Str()) hasHTTP = true case conventions.AttributeHTTPClientIP: info.Request.ClientIP = awsxray.String(value.Str()) hasHTTP = true - case conventions.AttributeHTTPUserAgent, conventionsV127.AttributeUserAgentOriginal: + case conventions.AttributeHTTPUserAgent, conventionsv127.AttributeUserAgentOriginal: info.Request.UserAgent = awsxray.String(value.Str()) hasHTTP = true - case conventions.AttributeHTTPStatusCode, conventionsV127.AttributeHTTPResponseStatusCode: + case conventions.AttributeHTTPStatusCode, conventionsv127.AttributeHTTPResponseStatusCode: info.Response.Status = aws.Int64(value.Int()) hasHTTP = true - case conventions.AttributeHTTPURL, conventionsV127.AttributeURLFull: + case conventions.AttributeHTTPURL, conventionsv127.AttributeURLFull: urlParts[conventions.AttributeHTTPURL] = value.Str() hasHTTP = true hasHTTPRequestURLAttributes = true - case conventions.AttributeHTTPScheme, conventionsV127.AttributeURLScheme: + case conventions.AttributeHTTPScheme, conventionsv127.AttributeURLScheme: urlParts[conventions.AttributeHTTPScheme] = value.Str() hasHTTP = true case conventions.AttributeHTTPHost: urlParts[key] = value.Str() hasHTTP = true hasHTTPRequestURLAttributes = true - case conventions.AttributeHTTPTarget, conventionsV127.AttributeURLQuery: + case conventions.AttributeHTTPTarget, conventionsv127.AttributeURLQuery: urlParts[conventions.AttributeHTTPTarget] = value.Str() hasHTTP = true case conventions.AttributeHTTPServerName: @@ -94,7 +94,7 @@ func makeHTTP(span ptrace.Span) (map[string]pcommon.Value, *awsxray.HTTPData) { urlParts[key] = value.Str() hasHTTPRequestURLAttributes = true hasNetPeerAddr = true - case conventionsV127.AttributeNetworkPeerAddress: + case conventionsv127.AttributeNetworkPeerAddress: // Prefer HTTP forwarded information (AttributeHTTPClientIP) when present. if net.ParseIP(value.Str()) != nil { if info.Request.ClientIP == nil { @@ -103,17 +103,17 @@ func makeHTTP(span ptrace.Span) (map[string]pcommon.Value, *awsxray.HTTPData) { hasHTTPRequestURLAttributes = true hasNetPeerAddr = true } - case conventionsV127.AttributeClientAddress: + case conventionsv127.AttributeClientAddress: if net.ParseIP(value.Str()) != nil { info.Request.ClientIP = awsxray.String(value.Str()) } - case conventionsV127.AttributeURLPath: + case conventionsv127.AttributeURLPath: urlParts[key] = value.Str() hasHTTP = true - case conventionsV127.AttributeServerAddress: + case conventionsv127.AttributeServerAddress: urlParts[key] = value.Str() hasHTTPRequestURLAttributes = true - case conventionsV127.AttributeServerPort: + case conventionsv127.AttributeServerPort: urlParts[key] = value.Str() if len(urlParts[key]) == 0 { urlParts[key] = strconv.FormatInt(value.Int(), 10) @@ -234,13 +234,13 @@ func constructServerURL(urlParts map[string]string) string { if !ok { host, ok = urlParts[conventions.AttributeHostName] if !ok { - host = urlParts[conventionsV127.AttributeServerAddress] + host = urlParts[conventionsv127.AttributeServerAddress] } } } port, ok = urlParts[conventions.AttributeNetHostPort] if !ok { - port, ok = urlParts[conventionsV127.AttributeServerPort] + port, ok = urlParts[conventionsv127.AttributeServerPort] if !ok { port = "" } @@ -254,7 +254,7 @@ func constructServerURL(urlParts map[string]string) string { if ok { url += target } else { - path, ok := urlParts[conventionsV127.AttributeURLPath] + path, ok := urlParts[conventionsv127.AttributeURLPath] if ok { url += path } else { diff --git a/exporter/awsxrayexporter/internal/translator/http_test.go b/exporter/awsxrayexporter/internal/translator/http_test.go index ad1033b2848c..607f49684108 100644 --- a/exporter/awsxrayexporter/internal/translator/http_test.go +++ b/exporter/awsxrayexporter/internal/translator/http_test.go @@ -13,7 +13,7 @@ import ( "github.com/stretchr/testify/require" "go.opentelemetry.io/collector/pdata/pcommon" "go.opentelemetry.io/collector/pdata/ptrace" - conventionsV127 "go.opentelemetry.io/collector/semconv/v1.27.0" + conventionsv127 "go.opentelemetry.io/collector/semconv/v1.27.0" conventions "go.opentelemetry.io/collector/semconv/v1.6.1" ) @@ -37,9 +37,9 @@ func TestClientSpanWithURLAttribute(t *testing.T) { func TestClientSpanWithURLAttributeStable(t *testing.T) { attributes := make(map[string]any) - attributes[conventionsV127.AttributeHTTPRequestMethod] = "GET" - attributes[conventionsV127.AttributeURLFull] = "https://api.example.com/users/junit" - attributes[conventionsV127.AttributeHTTPResponseStatusCode] = 200 + attributes[conventionsv127.AttributeHTTPRequestMethod] = "GET" + attributes[conventionsv127.AttributeURLFull] = "https://api.example.com/users/junit" + attributes[conventionsv127.AttributeHTTPResponseStatusCode] = 200 span := constructHTTPClientSpan(attributes) filtered, httpData := makeHTTP(span) @@ -76,11 +76,11 @@ func TestClientSpanWithSchemeHostTargetAttributes(t *testing.T) { func TestClientSpanWithSchemeHostTargetAttributesStable(t *testing.T) { attributes := make(map[string]any) - attributes[conventionsV127.AttributeHTTPRequestMethod] = "GET" - attributes[conventionsV127.AttributeURLScheme] = "https" - attributes[conventionsV127.AttributeServerAddress] = "api.example.com" - attributes[conventionsV127.AttributeURLQuery] = "/users/junit" - attributes[conventionsV127.AttributeHTTPResponseStatusCode] = 200 + attributes[conventionsv127.AttributeHTTPRequestMethod] = "GET" + attributes[conventionsv127.AttributeURLScheme] = "https" + attributes[conventionsv127.AttributeServerAddress] = "api.example.com" + attributes[conventionsv127.AttributeURLQuery] = "/users/junit" + attributes[conventionsv127.AttributeHTTPResponseStatusCode] = 200 attributes["user.id"] = "junit" span := constructHTTPClientSpan(attributes) @@ -123,13 +123,13 @@ func TestClientSpanWithPeerAttributes(t *testing.T) { func TestClientSpanWithPeerAttributesStable(t *testing.T) { attributes := make(map[string]any) - attributes[conventionsV127.AttributeHTTPRequestMethod] = "GET" - attributes[conventionsV127.AttributeURLScheme] = "http" - attributes[conventionsV127.AttributeServerAddress] = "kb234.example.com" - attributes[conventionsV127.AttributeServerPort] = 8080 - attributes[conventionsV127.AttributeNetworkPeerAddress] = "10.8.17.36" - attributes[conventionsV127.AttributeURLQuery] = "/users/junit" - attributes[conventionsV127.AttributeHTTPResponseStatusCode] = 200 + attributes[conventionsv127.AttributeHTTPRequestMethod] = "GET" + attributes[conventionsv127.AttributeURLScheme] = "http" + attributes[conventionsv127.AttributeServerAddress] = "kb234.example.com" + attributes[conventionsv127.AttributeServerPort] = 8080 + attributes[conventionsv127.AttributeNetworkPeerAddress] = "10.8.17.36" + attributes[conventionsv127.AttributeURLQuery] = "/users/junit" + attributes[conventionsv127.AttributeHTTPResponseStatusCode] = 200 span := constructHTTPClientSpan(attributes) filtered, httpData := makeHTTP(span) @@ -162,9 +162,9 @@ func TestClientSpanWithHttpPeerAttributes(t *testing.T) { func TestClientSpanWithHttpPeerAttributesStable(t *testing.T) { attributes := make(map[string]any) - attributes[conventionsV127.AttributeURLFull] = "https://api.example.com/users/junit" - attributes[conventionsV127.AttributeClientAddress] = "1.2.3.4" - attributes[conventionsV127.AttributeNetworkPeerAddress] = "10.8.17.36" + attributes[conventionsv127.AttributeURLFull] = "https://api.example.com/users/junit" + attributes[conventionsv127.AttributeClientAddress] = "1.2.3.4" + attributes[conventionsv127.AttributeNetworkPeerAddress] = "10.8.17.36" span := constructHTTPClientSpan(attributes) filtered, httpData := makeHTTP(span) @@ -235,11 +235,11 @@ func TestServerSpanWithURLAttribute(t *testing.T) { func TestServerSpanWithURLAttributeStable(t *testing.T) { attributes := make(map[string]any) - attributes[conventionsV127.AttributeHTTPRequestMethod] = "GET" - attributes[conventionsV127.AttributeURLFull] = "https://api.example.com/users/junit" - attributes[conventionsV127.AttributeClientAddress] = "192.168.15.32" - attributes[conventionsV127.AttributeUserAgentOriginal] = "PostmanRuntime/7.21.0" - attributes[conventionsV127.AttributeHTTPResponseStatusCode] = 200 + attributes[conventionsv127.AttributeHTTPRequestMethod] = "GET" + attributes[conventionsv127.AttributeURLFull] = "https://api.example.com/users/junit" + attributes[conventionsv127.AttributeClientAddress] = "192.168.15.32" + attributes[conventionsv127.AttributeUserAgentOriginal] = "PostmanRuntime/7.21.0" + attributes[conventionsv127.AttributeHTTPResponseStatusCode] = 200 span := constructHTTPServerSpan(attributes) filtered, httpData := makeHTTP(span) @@ -276,12 +276,12 @@ func TestServerSpanWithSchemeHostTargetAttributes(t *testing.T) { func TestServerSpanWithSchemeHostTargetAttributesStable(t *testing.T) { attributes := make(map[string]any) - attributes[conventionsV127.AttributeHTTPRequestMethod] = "GET" - attributes[conventionsV127.AttributeURLScheme] = "https" - attributes[conventionsV127.AttributeServerAddress] = "api.example.com" - attributes[conventionsV127.AttributeURLQuery] = "/users/junit" - attributes[conventionsV127.AttributeClientAddress] = "192.168.15.32" - attributes[conventionsV127.AttributeHTTPResponseStatusCode] = 200 + attributes[conventionsv127.AttributeHTTPRequestMethod] = "GET" + attributes[conventionsv127.AttributeURLScheme] = "https" + attributes[conventionsv127.AttributeServerAddress] = "api.example.com" + attributes[conventionsv127.AttributeURLQuery] = "/users/junit" + attributes[conventionsv127.AttributeClientAddress] = "192.168.15.32" + attributes[conventionsv127.AttributeHTTPResponseStatusCode] = 200 span := constructHTTPServerSpan(attributes) filtered, httpData := makeHTTP(span) @@ -319,13 +319,13 @@ func TestServerSpanWithSchemeServernamePortTargetAttributes(t *testing.T) { func TestServerSpanWithSchemeServernamePortTargetAttributesStable(t *testing.T) { attributes := make(map[string]any) - attributes[conventionsV127.AttributeHTTPRequestMethod] = "GET" - attributes[conventionsV127.AttributeURLScheme] = "https" - attributes[conventionsV127.AttributeServerAddress] = "api.example.com" - attributes[conventionsV127.AttributeServerPort] = 443 - attributes[conventionsV127.AttributeURLQuery] = "/users/junit" - attributes[conventionsV127.AttributeClientAddress] = "192.168.15.32" - attributes[conventionsV127.AttributeHTTPResponseStatusCode] = 200 + attributes[conventionsv127.AttributeHTTPRequestMethod] = "GET" + attributes[conventionsv127.AttributeURLScheme] = "https" + attributes[conventionsv127.AttributeServerAddress] = "api.example.com" + attributes[conventionsv127.AttributeServerPort] = 443 + attributes[conventionsv127.AttributeURLQuery] = "/users/junit" + attributes[conventionsv127.AttributeClientAddress] = "192.168.15.32" + attributes[conventionsv127.AttributeHTTPResponseStatusCode] = 200 span := constructHTTPServerSpan(attributes) filtered, httpData := makeHTTP(span) @@ -365,13 +365,13 @@ func TestServerSpanWithSchemeNamePortTargetAttributes(t *testing.T) { func TestServerSpanWithSchemeNamePortTargetAttributesStable(t *testing.T) { attributes := make(map[string]any) - attributes[conventionsV127.AttributeHTTPRequestMethod] = "GET" - attributes[conventionsV127.AttributeURLScheme] = "http" - attributes[conventionsV127.AttributeServerAddress] = "kb234.example.com" - attributes[conventionsV127.AttributeServerPort] = 8080 - attributes[conventionsV127.AttributeURLPath] = "/users/junit" - attributes[conventionsV127.AttributeClientAddress] = "192.168.15.32" - attributes[conventionsV127.AttributeHTTPResponseStatusCode] = 200 + attributes[conventionsv127.AttributeHTTPRequestMethod] = "GET" + attributes[conventionsv127.AttributeURLScheme] = "http" + attributes[conventionsv127.AttributeServerAddress] = "kb234.example.com" + attributes[conventionsv127.AttributeServerPort] = 8080 + attributes[conventionsv127.AttributeURLPath] = "/users/junit" + attributes[conventionsv127.AttributeClientAddress] = "192.168.15.32" + attributes[conventionsv127.AttributeHTTPResponseStatusCode] = 200 span := constructHTTPServerSpan(attributes) timeEvents := constructTimedEventsWithReceivedMessageEvent(span.EndTimestamp()) timeEvents.CopyTo(span.Events()) @@ -415,13 +415,13 @@ func TestSpanWithNotEnoughHTTPRequestURLAttributes(t *testing.T) { func TestSpanWithNotEnoughHTTPRequestURLAttributesStable(t *testing.T) { attributes := make(map[string]any) - attributes[conventionsV127.AttributeHTTPRequestMethod] = "GET" - attributes[conventionsV127.AttributeURLScheme] = "http" - attributes[conventionsV127.AttributeClientAddress] = "192.168.15.32" - attributes[conventionsV127.AttributeUserAgentOriginal] = "PostmanRuntime/7.21.0" - attributes[conventionsV127.AttributeURLPath] = "/users/junit" - attributes[conventionsV127.AttributeServerPort] = 443 - attributes[conventionsV127.AttributeHTTPResponseStatusCode] = 200 + attributes[conventionsv127.AttributeHTTPRequestMethod] = "GET" + attributes[conventionsv127.AttributeURLScheme] = "http" + attributes[conventionsv127.AttributeClientAddress] = "192.168.15.32" + attributes[conventionsv127.AttributeUserAgentOriginal] = "PostmanRuntime/7.21.0" + attributes[conventionsv127.AttributeURLPath] = "/users/junit" + attributes[conventionsv127.AttributeServerPort] = 443 + attributes[conventionsv127.AttributeHTTPResponseStatusCode] = 200 span := constructHTTPServerSpan(attributes) timeEvents := constructTimedEventsWithReceivedMessageEvent(span.EndTimestamp()) timeEvents.CopyTo(span.Events()) @@ -441,20 +441,20 @@ func TestSpanWithNotEnoughHTTPRequestURLAttributesStable(t *testing.T) { func TestSpanWithNotEnoughHTTPRequestURLAttributesDuplicated(t *testing.T) { attributes := make(map[string]any) attributes[conventions.AttributeHTTPMethod] = "GET" - attributes[conventionsV127.AttributeHTTPRequestMethod] = "GET" + attributes[conventionsv127.AttributeHTTPRequestMethod] = "GET" attributes[conventions.AttributeHTTPScheme] = "http" - attributes[conventionsV127.AttributeURLScheme] = "http" + attributes[conventionsv127.AttributeURLScheme] = "http" attributes[conventions.AttributeHTTPClientIP] = "192.168.15.32" - attributes[conventionsV127.AttributeClientAddress] = "192.168.15.32" + attributes[conventionsv127.AttributeClientAddress] = "192.168.15.32" attributes[conventions.AttributeHTTPUserAgent] = "PostmanRuntime/7.21.0" - attributes[conventionsV127.AttributeUserAgentOriginal] = "PostmanRuntime/7.21.0" + attributes[conventionsv127.AttributeUserAgentOriginal] = "PostmanRuntime/7.21.0" attributes[conventions.AttributeHTTPTarget] = "/users/junit" - attributes[conventionsV127.AttributeURLPath] = "/users/junit" + attributes[conventionsv127.AttributeURLPath] = "/users/junit" attributes[conventions.AttributeNetHostPort] = 443 - attributes[conventionsV127.AttributeServerPort] = 443 + attributes[conventionsv127.AttributeServerPort] = 443 attributes[conventions.AttributeNetPeerPort] = 8080 attributes[conventions.AttributeHTTPStatusCode] = 200 - attributes[conventionsV127.AttributeHTTPResponseStatusCode] = 200 + attributes[conventionsv127.AttributeHTTPResponseStatusCode] = 200 span := constructHTTPServerSpan(attributes) timeEvents := constructTimedEventsWithReceivedMessageEvent(span.EndTimestamp()) timeEvents.CopyTo(span.Events()) @@ -473,8 +473,8 @@ func TestSpanWithNotEnoughHTTPRequestURLAttributesDuplicated(t *testing.T) { func TestSpanWithClientAddrWithoutNetworkPeerAddr(t *testing.T) { attributes := make(map[string]any) - attributes[conventionsV127.AttributeURLFull] = "https://api.example.com/users/junit" - attributes[conventionsV127.AttributeClientAddress] = "192.168.15.32" + attributes[conventionsv127.AttributeURLFull] = "https://api.example.com/users/junit" + attributes[conventionsv127.AttributeClientAddress] = "192.168.15.32" span := constructHTTPServerSpan(attributes) _, httpData := makeHTTP(span) @@ -483,9 +483,9 @@ func TestSpanWithClientAddrWithoutNetworkPeerAddr(t *testing.T) { } func TestSpanWithClientAddrAndNetworkPeerAddr(t *testing.T) { attributes := make(map[string]any) - attributes[conventionsV127.AttributeURLFull] = "https://api.example.com/users/junit" - attributes[conventionsV127.AttributeClientAddress] = "192.168.15.32" - attributes[conventionsV127.AttributeNetworkPeerAddress] = "192.168.15.32" + attributes[conventionsv127.AttributeURLFull] = "https://api.example.com/users/junit" + attributes[conventionsv127.AttributeClientAddress] = "192.168.15.32" + attributes[conventionsv127.AttributeNetworkPeerAddress] = "192.168.15.32" span := constructHTTPServerSpan(attributes) _, httpData := makeHTTP(span) @@ -496,9 +496,9 @@ func TestSpanWithClientAddrAndNetworkPeerAddr(t *testing.T) { func TestSpanWithClientAddrNotIP(t *testing.T) { attributes := make(map[string]any) - attributes[conventionsV127.AttributeURLFull] = "https://api.example.com/users/junit" - attributes[conventionsV127.AttributeClientAddress] = "api.example.com" - attributes[conventionsV127.AttributeNetworkPeerAddress] = "api.example.com" + attributes[conventionsv127.AttributeURLFull] = "https://api.example.com/users/junit" + attributes[conventionsv127.AttributeClientAddress] = "api.example.com" + attributes[conventionsv127.AttributeNetworkPeerAddress] = "api.example.com" span := constructHTTPServerSpan(attributes) _, httpData := makeHTTP(span) From f89d56055aef3eec5ba614b905beac8f6e8fe826 Mon Sep 17 00:00:00 2001 From: Zhonghao Zhao Date: Mon, 23 Dec 2024 21:23:48 +0000 Subject: [PATCH 5/7] update dependency. --- exporter/awsxrayexporter/internal/translator/http_test.go | 8 ++++---- go.mod | 4 ++-- go.sum | 7 ++++--- 3 files changed, 10 insertions(+), 9 deletions(-) diff --git a/exporter/awsxrayexporter/internal/translator/http_test.go b/exporter/awsxrayexporter/internal/translator/http_test.go index 607f49684108..171d3f0b455b 100644 --- a/exporter/awsxrayexporter/internal/translator/http_test.go +++ b/exporter/awsxrayexporter/internal/translator/http_test.go @@ -78,7 +78,7 @@ func TestClientSpanWithSchemeHostTargetAttributesStable(t *testing.T) { attributes := make(map[string]any) attributes[conventionsv127.AttributeHTTPRequestMethod] = "GET" attributes[conventionsv127.AttributeURLScheme] = "https" - attributes[conventionsv127.AttributeServerAddress] = "api.example.com" + attributes[conventions.AttributeHTTPHost] = "api.example.com" attributes[conventionsv127.AttributeURLQuery] = "/users/junit" attributes[conventionsv127.AttributeHTTPResponseStatusCode] = 200 attributes["user.id"] = "junit" @@ -125,9 +125,9 @@ func TestClientSpanWithPeerAttributesStable(t *testing.T) { attributes := make(map[string]any) attributes[conventionsv127.AttributeHTTPRequestMethod] = "GET" attributes[conventionsv127.AttributeURLScheme] = "http" - attributes[conventionsv127.AttributeServerAddress] = "kb234.example.com" - attributes[conventionsv127.AttributeServerPort] = 8080 - attributes[conventionsv127.AttributeNetworkPeerAddress] = "10.8.17.36" + attributes[conventions.AttributeNetPeerName] = "kb234.example.com" + attributes[conventions.AttributeNetPeerPort] = 8080 + attributes[conventions.AttributeNetPeerIP] = "10.8.17.36" attributes[conventionsv127.AttributeURLQuery] = "/users/junit" attributes[conventionsv127.AttributeHTTPResponseStatusCode] = 200 span := constructHTTPClientSpan(attributes) diff --git a/go.mod b/go.mod index 6ef036a1d2e9..81eb8d6284d7 100644 --- a/go.mod +++ b/go.mod @@ -668,7 +668,7 @@ require ( github.com/spf13/viper v1.19.0 // indirect github.com/stormcat24/protodep v0.1.8 // indirect github.com/stretchr/objx v0.5.2 // indirect - github.com/stretchr/testify v1.9.0 // indirect + github.com/stretchr/testify v1.10.0 // indirect github.com/subosito/gotenv v1.6.0 // indirect github.com/syndtr/gocapability v0.0.0-20200815063812-42c35b437635 // indirect github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/common v1.0.940 // indirect @@ -727,7 +727,7 @@ require ( go.opentelemetry.io/collector/featuregate v1.10.0 // indirect go.opentelemetry.io/collector/filter v0.103.0 // indirect go.opentelemetry.io/collector/pdata v1.10.0 // indirect - go.opentelemetry.io/collector/semconv v0.103.0 // indirect + go.opentelemetry.io/collector/semconv v0.116.0 // indirect go.opentelemetry.io/collector/service v0.103.0 // indirect go.opentelemetry.io/contrib/config v0.7.0 // indirect go.opentelemetry.io/contrib/instrumentation/google.golang.org/grpc/otelgrpc v0.52.0 // indirect diff --git a/go.sum b/go.sum index f69cba1993a7..cdb6e55401e1 100644 --- a/go.sum +++ b/go.sum @@ -2181,8 +2181,9 @@ github.com/stretchr/testify v1.8.1/go.mod h1:w2LPCIKwWwSfY2zedu0+kehJoqGctiVI29o github.com/stretchr/testify v1.8.2/go.mod h1:w2LPCIKwWwSfY2zedu0+kehJoqGctiVI29o6fzry7u4= github.com/stretchr/testify v1.8.3/go.mod h1:sz/lmYIOXD/1dqDmKjjqLyZ2RngseejIcXlSw2iwfAo= github.com/stretchr/testify v1.8.4/go.mod h1:sz/lmYIOXD/1dqDmKjjqLyZ2RngseejIcXlSw2iwfAo= -github.com/stretchr/testify v1.9.0 h1:HtqpIVDClZ4nwg75+f6Lvsy/wHu+3BoSGCbBAcpTsTg= github.com/stretchr/testify v1.9.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY= +github.com/stretchr/testify v1.10.0 h1:Xv5erBjTwe/5IxqUQTdXv5kgmIvbHo3QQyRwhJsOfJA= +github.com/stretchr/testify v1.10.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY= github.com/subosito/gotenv v1.2.0/go.mod h1:N0PQaV/YGNqwC0u51sEeR/aUtSLEXKX9iv69rRypqCw= github.com/subosito/gotenv v1.6.0 h1:9NlTDc1FTs4qu0DDq7AEtTPNw6SVm7uBMsUCUjABIf8= github.com/subosito/gotenv v1.6.0/go.mod h1:Dk4QP5c2W3ibzajGcXpNraDfq2IrhjMIvMSWPKKo0FU= @@ -2390,8 +2391,8 @@ go.opentelemetry.io/collector/receiver v0.103.0 h1:V3JBKkX+7e/NYpDDZVyeu2VQB1/lL go.opentelemetry.io/collector/receiver v0.103.0/go.mod h1:Yybv4ynKFdMOYViWWPMmjkugR89FSQN0P37wP6mX6qM= go.opentelemetry.io/collector/receiver/otlpreceiver v0.103.0 h1:TycVVl4AWioV6kWeFcCIk2QuKfXOzn88yw989opsMdE= go.opentelemetry.io/collector/receiver/otlpreceiver v0.103.0/go.mod h1:jAbzL5lwOGG93YbcPZ6aFZIZq+tjYQ+BS3vKKT2nRgw= -go.opentelemetry.io/collector/semconv v0.103.0 h1:5tlVoZlo9USHAU2Bz4YrEste0Vm5AMufXkYJhAVve1Q= -go.opentelemetry.io/collector/semconv v0.103.0/go.mod h1:yMVUCNoQPZVq/IPfrHrnntZTWsLf5YGZ7qwKulIl5hw= +go.opentelemetry.io/collector/semconv v0.116.0 h1:63xCZomsKJAWmKGWD3lnORiE3WKW6AO4LjnzcHzGx3Y= +go.opentelemetry.io/collector/semconv v0.116.0/go.mod h1:N6XE8Q0JKgBN2fAhkUQtqK9LT7rEGR6+Wu/Rtbal1iI= go.opentelemetry.io/collector/service v0.103.0 h1:e4Eri4jo+YOuEK0+/JE9SUdT/NZaJ2jz/ROJlmLn96s= go.opentelemetry.io/collector/service v0.103.0/go.mod h1:p1mlniiC1MuPN5FANYJYgf5V5CGFP0hNqWfI8t7Aw8M= go.opentelemetry.io/contrib/config v0.7.0 h1:b1rK5tGTuhhPirJiMxOcyQfZs76j2VapY6ODn3b2Dbs= From 880d11aa89a0d960a95d57568fdbfb13acc82a26 Mon Sep 17 00:00:00 2001 From: Zhonghao Zhao Date: Mon, 6 Jan 2025 21:12:07 +0000 Subject: [PATCH 6/7] Updated dependencies. --- exporter/awsxrayexporter/go.sum | 4 ---- 1 file changed, 4 deletions(-) diff --git a/exporter/awsxrayexporter/go.sum b/exporter/awsxrayexporter/go.sum index 1cc70bbb5cfa..9c37e7411cb8 100644 --- a/exporter/awsxrayexporter/go.sum +++ b/exporter/awsxrayexporter/go.sum @@ -90,8 +90,6 @@ github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+ github.com/stretchr/objx v0.5.2 h1:xuMeJ0Sdp5ZMRXx/aWO6RZxdr3beISkG5/G/aIRr3pY= github.com/stretchr/objx v0.5.2/go.mod h1:FRsXN1f5AsAjCGJKqEizvkpNtU+EGNCLh3NxZ/8L+MA= github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI= -github.com/stretchr/testify v1.9.0 h1:HtqpIVDClZ4nwg75+f6Lvsy/wHu+3BoSGCbBAcpTsTg= -github.com/stretchr/testify v1.9.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY= github.com/stretchr/testify v1.10.0 h1:Xv5erBjTwe/5IxqUQTdXv5kgmIvbHo3QQyRwhJsOfJA= github.com/stretchr/testify v1.10.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY= github.com/yuin/goldmark v1.1.27/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= @@ -120,8 +118,6 @@ go.opentelemetry.io/collector/pdata/testdata v0.103.0 h1:iI6NOE0L2je/bxlWzAWHQ/y go.opentelemetry.io/collector/pdata/testdata v0.103.0/go.mod h1:tLzRhb/h37/9wFRQVr+CxjKi5qmhSRpCAiOlhwRkeEk= go.opentelemetry.io/collector/receiver v0.103.0 h1:V3JBKkX+7e/NYpDDZVyeu2VQB1/lLFuoJFPfupdCcZs= go.opentelemetry.io/collector/receiver v0.103.0/go.mod h1:Yybv4ynKFdMOYViWWPMmjkugR89FSQN0P37wP6mX6qM= -go.opentelemetry.io/collector/semconv v0.103.0 h1:5tlVoZlo9USHAU2Bz4YrEste0Vm5AMufXkYJhAVve1Q= -go.opentelemetry.io/collector/semconv v0.103.0/go.mod h1:yMVUCNoQPZVq/IPfrHrnntZTWsLf5YGZ7qwKulIl5hw= go.opentelemetry.io/collector/semconv v0.116.0 h1:63xCZomsKJAWmKGWD3lnORiE3WKW6AO4LjnzcHzGx3Y= go.opentelemetry.io/collector/semconv v0.116.0/go.mod h1:N6XE8Q0JKgBN2fAhkUQtqK9LT7rEGR6+Wu/Rtbal1iI= go.opentelemetry.io/otel v1.27.0 h1:9BZoF3yMK/O1AafMiQTVu0YDj5Ea4hPhxCs7sGva+cg= From e281d010e09a2264aa631eb3534fdc65c1b77b42 Mon Sep 17 00:00:00 2001 From: Zhonghao Zhao Date: Mon, 6 Jan 2025 22:15:24 +0000 Subject: [PATCH 7/7] Revert back to use constant definition for semcov. --- exporter/awsxrayexporter/go.mod | 4 +- exporter/awsxrayexporter/go.sum | 8 +- .../internal/translator/aws.go | 7 +- .../internal/translator/aws_test.go | 9 +- .../internal/translator/cause.go | 5 +- .../internal/translator/cause_test.go | 39 +++--- .../internal/translator/http.go | 43 +++--- .../internal/translator/http_test.go | 123 +++++++++--------- go.mod | 4 +- go.sum | 7 +- 10 files changed, 130 insertions(+), 119 deletions(-) diff --git a/exporter/awsxrayexporter/go.mod b/exporter/awsxrayexporter/go.mod index b71030c06aa3..8125c4e0f4c9 100644 --- a/exporter/awsxrayexporter/go.mod +++ b/exporter/awsxrayexporter/go.mod @@ -8,14 +8,14 @@ require ( github.com/open-telemetry/opentelemetry-collector-contrib/internal/aws/awsutil v0.103.0 github.com/open-telemetry/opentelemetry-collector-contrib/internal/aws/xray v0.103.0 github.com/open-telemetry/opentelemetry-collector-contrib/internal/coreinternal v0.103.0 - github.com/stretchr/testify v1.10.0 + github.com/stretchr/testify v1.9.0 go.opentelemetry.io/collector/component v0.103.0 go.opentelemetry.io/collector/confmap v0.103.0 go.opentelemetry.io/collector/consumer v0.103.0 go.opentelemetry.io/collector/exporter v0.103.0 go.opentelemetry.io/collector/featuregate v1.10.0 go.opentelemetry.io/collector/pdata v1.10.0 - go.opentelemetry.io/collector/semconv v0.116.0 + go.opentelemetry.io/collector/semconv v0.103.0 go.opentelemetry.io/otel/metric v1.27.0 go.opentelemetry.io/otel/trace v1.27.0 go.uber.org/goleak v1.3.0 diff --git a/exporter/awsxrayexporter/go.sum b/exporter/awsxrayexporter/go.sum index 9c37e7411cb8..63352824831a 100644 --- a/exporter/awsxrayexporter/go.sum +++ b/exporter/awsxrayexporter/go.sum @@ -90,8 +90,8 @@ github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+ github.com/stretchr/objx v0.5.2 h1:xuMeJ0Sdp5ZMRXx/aWO6RZxdr3beISkG5/G/aIRr3pY= github.com/stretchr/objx v0.5.2/go.mod h1:FRsXN1f5AsAjCGJKqEizvkpNtU+EGNCLh3NxZ/8L+MA= github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI= -github.com/stretchr/testify v1.10.0 h1:Xv5erBjTwe/5IxqUQTdXv5kgmIvbHo3QQyRwhJsOfJA= -github.com/stretchr/testify v1.10.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY= +github.com/stretchr/testify v1.9.0 h1:HtqpIVDClZ4nwg75+f6Lvsy/wHu+3BoSGCbBAcpTsTg= +github.com/stretchr/testify v1.9.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY= github.com/yuin/goldmark v1.1.27/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= github.com/yuin/goldmark v1.2.1/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= go.opentelemetry.io/collector v0.103.0 h1:mssWo1y31p1F/SRsSBnVUX6YocgawCqM1blpE+hkWog= @@ -118,8 +118,8 @@ go.opentelemetry.io/collector/pdata/testdata v0.103.0 h1:iI6NOE0L2je/bxlWzAWHQ/y go.opentelemetry.io/collector/pdata/testdata v0.103.0/go.mod h1:tLzRhb/h37/9wFRQVr+CxjKi5qmhSRpCAiOlhwRkeEk= go.opentelemetry.io/collector/receiver v0.103.0 h1:V3JBKkX+7e/NYpDDZVyeu2VQB1/lLFuoJFPfupdCcZs= go.opentelemetry.io/collector/receiver v0.103.0/go.mod h1:Yybv4ynKFdMOYViWWPMmjkugR89FSQN0P37wP6mX6qM= -go.opentelemetry.io/collector/semconv v0.116.0 h1:63xCZomsKJAWmKGWD3lnORiE3WKW6AO4LjnzcHzGx3Y= -go.opentelemetry.io/collector/semconv v0.116.0/go.mod h1:N6XE8Q0JKgBN2fAhkUQtqK9LT7rEGR6+Wu/Rtbal1iI= +go.opentelemetry.io/collector/semconv v0.103.0 h1:5tlVoZlo9USHAU2Bz4YrEste0Vm5AMufXkYJhAVve1Q= +go.opentelemetry.io/collector/semconv v0.103.0/go.mod h1:yMVUCNoQPZVq/IPfrHrnntZTWsLf5YGZ7qwKulIl5hw= go.opentelemetry.io/otel v1.27.0 h1:9BZoF3yMK/O1AafMiQTVu0YDj5Ea4hPhxCs7sGva+cg= go.opentelemetry.io/otel v1.27.0/go.mod h1:DMpAK8fzYRzs+bi3rS5REupisuqTheUlSZJ1WnZaPAQ= go.opentelemetry.io/otel/exporters/prometheus v0.49.0 h1:Er5I1g/YhfYv9Affk9nJLfH/+qCCVVg1f2R9AbJfqDQ= diff --git a/exporter/awsxrayexporter/internal/translator/aws.go b/exporter/awsxrayexporter/internal/translator/aws.go index 52cd9b035c89..e312e27cf1ff 100644 --- a/exporter/awsxrayexporter/internal/translator/aws.go +++ b/exporter/awsxrayexporter/internal/translator/aws.go @@ -9,12 +9,15 @@ import ( "github.com/aws/aws-sdk-go/aws" "go.opentelemetry.io/collector/pdata/pcommon" - conventionsv127 "go.opentelemetry.io/collector/semconv/v1.27.0" conventions "go.opentelemetry.io/collector/semconv/v1.6.1" awsxray "github.com/open-telemetry/opentelemetry-collector-contrib/internal/aws/xray" ) +const ( + AttributeTelemetryDistroVersion = "telemetry.distro.version" +) + func makeAws(attributes map[string]pcommon.Value, resource pcommon.Resource, logGroupNames []string) (map[string]pcommon.Value, *awsxray.AWSData) { var ( cloud string @@ -91,7 +94,7 @@ func makeAws(attributes map[string]pcommon.Value, resource pcommon.Resource, log sdkLanguage = value.Str() case conventions.AttributeTelemetrySDKVersion: sdkVersion = value.Str() - case conventions.AttributeTelemetryAutoVersion, conventionsv127.AttributeTelemetryDistroVersion: + case conventions.AttributeTelemetryAutoVersion, AttributeTelemetryDistroVersion: autoVersion = value.Str() case conventions.AttributeContainerID: containerID = value.Str() diff --git a/exporter/awsxrayexporter/internal/translator/aws_test.go b/exporter/awsxrayexporter/internal/translator/aws_test.go index fb9222da7450..4c8c78ae3c25 100644 --- a/exporter/awsxrayexporter/internal/translator/aws_test.go +++ b/exporter/awsxrayexporter/internal/translator/aws_test.go @@ -9,7 +9,6 @@ import ( "github.com/aws/aws-sdk-go/aws" "github.com/stretchr/testify/assert" "go.opentelemetry.io/collector/pdata/pcommon" - conventionsv127 "go.opentelemetry.io/collector/semconv/v1.27.0" conventions "go.opentelemetry.io/collector/semconv/v1.6.1" awsxray "github.com/open-telemetry/opentelemetry-collector-contrib/internal/aws/xray" @@ -364,10 +363,10 @@ func TestJavaAutoInstrumentation(t *testing.T) { func TestJavaAutoInstrumentationStable(t *testing.T) { attributes := make(map[string]pcommon.Value) resource := pcommon.NewResource() - resource.Attributes().PutStr(conventionsv127.AttributeTelemetrySDKName, "opentelemetry") - resource.Attributes().PutStr(conventionsv127.AttributeTelemetrySDKLanguage, "java") - resource.Attributes().PutStr(conventionsv127.AttributeTelemetrySDKVersion, "1.2.3") - resource.Attributes().PutStr(conventionsv127.AttributeTelemetryDistroVersion, "3.4.5") + resource.Attributes().PutStr(conventions.AttributeTelemetrySDKName, "opentelemetry") + resource.Attributes().PutStr(conventions.AttributeTelemetrySDKLanguage, "java") + resource.Attributes().PutStr(conventions.AttributeTelemetrySDKVersion, "1.2.3") + resource.Attributes().PutStr(AttributeTelemetryDistroVersion, "3.4.5") filtered, awsData := makeAws(attributes, resource, nil) diff --git a/exporter/awsxrayexporter/internal/translator/cause.go b/exporter/awsxrayexporter/internal/translator/cause.go index 4f223b899cf6..a41f832d8442 100644 --- a/exporter/awsxrayexporter/internal/translator/cause.go +++ b/exporter/awsxrayexporter/internal/translator/cause.go @@ -14,7 +14,6 @@ import ( "github.com/aws/aws-sdk-go/aws" "go.opentelemetry.io/collector/pdata/pcommon" "go.opentelemetry.io/collector/pdata/ptrace" - conventionsv127 "go.opentelemetry.io/collector/semconv/v1.27.0" conventions "go.opentelemetry.io/collector/semconv/v1.6.1" awsxray "github.com/open-telemetry/opentelemetry-collector-contrib/internal/aws/xray" @@ -88,7 +87,7 @@ func makeCause(span ptrace.Span, attributes map[string]pcommon.Value, resource p parsed := parseException(exceptionType, message, stacktrace, isRemote, language) exceptions = append(exceptions, parsed...) } else if isAwsSdkSpan && event.Name() == AwsIndividualHTTPEventName { - errorCode, ok1 := event.Attributes().Get(conventionsv127.AttributeHTTPResponseStatusCode) + errorCode, ok1 := event.Attributes().Get(AttributeHTTPResponseStatusCode) errorMessage, ok2 := event.Attributes().Get(AwsIndividualHTTPErrorMsgAttr) if ok1 && ok2 { eventEpochTime := event.Timestamp().AsTime().UnixMicro() @@ -151,7 +150,7 @@ func makeCause(span ptrace.Span, attributes map[string]pcommon.Value, resource p val, ok := span.Attributes().Get(conventions.AttributeHTTPStatusCode) if !ok { - val, ok = span.Attributes().Get(conventionsv127.AttributeHTTPResponseStatusCode) + val, ok = span.Attributes().Get(AttributeHTTPResponseStatusCode) } switch { diff --git a/exporter/awsxrayexporter/internal/translator/cause_test.go b/exporter/awsxrayexporter/internal/translator/cause_test.go index f9e11cacc68f..467f6828fc13 100644 --- a/exporter/awsxrayexporter/internal/translator/cause_test.go +++ b/exporter/awsxrayexporter/internal/translator/cause_test.go @@ -12,7 +12,6 @@ import ( "github.com/stretchr/testify/require" "go.opentelemetry.io/collector/pdata/pcommon" "go.opentelemetry.io/collector/pdata/ptrace" - conventionsv127 "go.opentelemetry.io/collector/semconv/v1.27.0" conventions "go.opentelemetry.io/collector/semconv/v1.6.1" ) @@ -69,7 +68,7 @@ func TestMakeCauseAwsSdkSpan(t *testing.T) { event1 := span.Events().AppendEmpty() event1.SetName(AwsIndividualHTTPEventName) - event1.Attributes().PutStr(conventionsv127.AttributeHTTPResponseStatusCode, "503") + event1.Attributes().PutStr(AttributeHTTPResponseStatusCode, "503") event1.Attributes().PutStr(AwsIndividualHTTPErrorMsgAttr, "service is temporarily unavailable") timestamp := pcommon.NewTimestampFromTime(time.UnixMicro(1696954761000001)) event1.SetTimestamp(timestamp) @@ -200,9 +199,9 @@ func TestCauseWithStatusMessage(t *testing.T) { func TestCauseWithStatusMessageStable(t *testing.T) { errorMsg := "this is a test" attributes := make(map[string]any) - attributes[conventionsv127.AttributeHTTPRequestMethod] = "POST" - attributes[conventionsv127.AttributeURLFull] = "https://api.example.com/widgets" - attributes[conventionsv127.AttributeHTTPResponseStatusCode] = 500 + attributes[AttributeHTTPRequestMethod] = "POST" + attributes[AttributeURLFull] = "https://api.example.com/widgets" + attributes[AttributeHTTPResponseStatusCode] = 500 span := constructExceptionServerSpan(attributes, ptrace.StatusCodeError) span.Status().SetMessage(errorMsg) filtered, _ := makeHTTP(span) @@ -250,9 +249,9 @@ func TestCauseWithHttpStatusMessage(t *testing.T) { func TestCauseWithHttpStatusMessageStable(t *testing.T) { errorMsg := "this is a test" attributes := make(map[string]any) - attributes[conventions.AttributeHTTPMethod] = "POST" - attributes[conventions.AttributeHTTPURL] = "https://api.example.com/widgets" - attributes[conventionsv127.AttributeHTTPResponseStatusCode] = 500 + attributes[AttributeHTTPRequestMethod] = "POST" + attributes[AttributeURLFull] = "https://api.example.com/widgets" + attributes[AttributeHTTPResponseStatusCode] = 500 attributes["http.status_text"] = errorMsg span := constructExceptionServerSpan(attributes, ptrace.StatusCodeError) filtered, _ := makeHTTP(span) @@ -299,9 +298,9 @@ func TestCauseWithZeroStatusMessageAndFaultHttpCode(t *testing.T) { func TestCauseWithZeroStatusMessageAndFaultHttpCodeStable(t *testing.T) { errorMsg := "this is a test" attributes := make(map[string]any) - attributes[conventionsv127.AttributeHTTPRequestMethod] = "POST" - attributes[conventionsv127.AttributeURLFull] = "https://api.example.com/widgets" - attributes[conventionsv127.AttributeHTTPResponseStatusCode] = 500 + attributes[AttributeHTTPRequestMethod] = "POST" + attributes[AttributeURLFull] = "https://api.example.com/widgets" + attributes[AttributeHTTPResponseStatusCode] = 500 attributes["http.status_text"] = errorMsg span := constructExceptionServerSpan(attributes, ptrace.StatusCodeUnset) @@ -416,9 +415,9 @@ func TestCauseWithZeroStatusMessageAndFaultErrorCode(t *testing.T) { func TestCauseWithZeroStatusMessageAndFaultErrorCodeStable(t *testing.T) { errorMsg := "this is a test" attributes := make(map[string]any) - attributes[conventionsv127.AttributeHTTPRequestMethod] = "POST" - attributes[conventionsv127.AttributeURLFull] = "https://api.example.com/widgets" - attributes[conventionsv127.AttributeHTTPResponseStatusCode] = 400 + attributes[AttributeHTTPRequestMethod] = "POST" + attributes[AttributeURLFull] = "https://api.example.com/widgets" + attributes[AttributeHTTPResponseStatusCode] = 400 attributes["http.status_text"] = errorMsg span := constructExceptionServerSpan(attributes, ptrace.StatusCodeUnset) @@ -461,9 +460,9 @@ func TestCauseWithClientErrorMessage(t *testing.T) { func TestCauseWithClientErrorMessageStable(t *testing.T) { errorMsg := "this is a test" attributes := make(map[string]any) - attributes[conventionsv127.AttributeHTTPRequestMethod] = "POST" - attributes[conventionsv127.AttributeURLFull] = "https://api.example.com/widgets" - attributes[conventionsv127.AttributeHTTPResponseStatusCode] = 499 + attributes[AttributeHTTPRequestMethod] = "POST" + attributes[AttributeURLFull] = "https://api.example.com/widgets" + attributes[AttributeHTTPResponseStatusCode] = 499 attributes["http.status_text"] = errorMsg span := constructExceptionServerSpan(attributes, ptrace.StatusCodeError) @@ -503,9 +502,9 @@ func TestCauseWithThrottled(t *testing.T) { func TestCauseWithThrottledStable(t *testing.T) { errorMsg := "this is a test" attributes := make(map[string]any) - attributes[conventionsv127.AttributeHTTPRequestMethod] = "POST" - attributes[conventionsv127.AttributeURLFull] = "https://api.example.com/widgets" - attributes[conventionsv127.AttributeHTTPResponseStatusCode] = 429 + attributes[AttributeHTTPRequestMethod] = "POST" + attributes[AttributeURLFull] = "https://api.example.com/widgets" + attributes[AttributeHTTPResponseStatusCode] = 429 attributes["http.status_text"] = errorMsg span := constructExceptionServerSpan(attributes, ptrace.StatusCodeError) diff --git a/exporter/awsxrayexporter/internal/translator/http.go b/exporter/awsxrayexporter/internal/translator/http.go index 445a30f8815b..475d5fc89aa7 100644 --- a/exporter/awsxrayexporter/internal/translator/http.go +++ b/exporter/awsxrayexporter/internal/translator/http.go @@ -10,12 +10,25 @@ import ( "github.com/aws/aws-sdk-go/aws" "go.opentelemetry.io/collector/pdata/pcommon" "go.opentelemetry.io/collector/pdata/ptrace" - conventionsv127 "go.opentelemetry.io/collector/semconv/v1.27.0" conventions "go.opentelemetry.io/collector/semconv/v1.6.1" awsxray "github.com/open-telemetry/opentelemetry-collector-contrib/internal/aws/xray" ) +const ( + AttributeHTTPRequestMethod = "http.request.method" + AttributeHTTPResponseStatusCode = "http.response.status_code" + AttributeServerAddress = "server.address" + AttributeServerPort = "server.port" + AttributeNetworkPeerAddress = "network.peer.address" + AttributeClientAddress = "client.address" + AttributeURLScheme = "url.scheme" + AttributeURLFull = "url.full" + AttributeURLPath = "url.path" + AttributeURLQuery = "url.query" + AttributeUserAgentOriginal = "user_agent.original" +) + func makeHTTP(span ptrace.Span) (map[string]pcommon.Value, *awsxray.HTTPData) { var ( info = awsxray.HTTPData{ @@ -36,30 +49,30 @@ func makeHTTP(span ptrace.Span) (map[string]pcommon.Value, *awsxray.HTTPData) { span.Attributes().Range(func(key string, value pcommon.Value) bool { switch key { - case conventions.AttributeHTTPMethod, conventionsv127.AttributeHTTPRequestMethod: + case conventions.AttributeHTTPMethod, AttributeHTTPRequestMethod: info.Request.Method = awsxray.String(value.Str()) hasHTTP = true case conventions.AttributeHTTPClientIP: info.Request.ClientIP = awsxray.String(value.Str()) hasHTTP = true - case conventions.AttributeHTTPUserAgent, conventionsv127.AttributeUserAgentOriginal: + case conventions.AttributeHTTPUserAgent, AttributeUserAgentOriginal: info.Request.UserAgent = awsxray.String(value.Str()) hasHTTP = true - case conventions.AttributeHTTPStatusCode, conventionsv127.AttributeHTTPResponseStatusCode: + case conventions.AttributeHTTPStatusCode, AttributeHTTPResponseStatusCode: info.Response.Status = aws.Int64(value.Int()) hasHTTP = true - case conventions.AttributeHTTPURL, conventionsv127.AttributeURLFull: + case conventions.AttributeHTTPURL, AttributeURLFull: urlParts[conventions.AttributeHTTPURL] = value.Str() hasHTTP = true hasHTTPRequestURLAttributes = true - case conventions.AttributeHTTPScheme, conventionsv127.AttributeURLScheme: + case conventions.AttributeHTTPScheme, AttributeURLScheme: urlParts[conventions.AttributeHTTPScheme] = value.Str() hasHTTP = true case conventions.AttributeHTTPHost: urlParts[key] = value.Str() hasHTTP = true hasHTTPRequestURLAttributes = true - case conventions.AttributeHTTPTarget, conventionsv127.AttributeURLQuery: + case conventions.AttributeHTTPTarget, AttributeURLQuery: urlParts[conventions.AttributeHTTPTarget] = value.Str() hasHTTP = true case conventions.AttributeHTTPServerName: @@ -94,7 +107,7 @@ func makeHTTP(span ptrace.Span) (map[string]pcommon.Value, *awsxray.HTTPData) { urlParts[key] = value.Str() hasHTTPRequestURLAttributes = true hasNetPeerAddr = true - case conventionsv127.AttributeNetworkPeerAddress: + case AttributeNetworkPeerAddress: // Prefer HTTP forwarded information (AttributeHTTPClientIP) when present. if net.ParseIP(value.Str()) != nil { if info.Request.ClientIP == nil { @@ -103,17 +116,17 @@ func makeHTTP(span ptrace.Span) (map[string]pcommon.Value, *awsxray.HTTPData) { hasHTTPRequestURLAttributes = true hasNetPeerAddr = true } - case conventionsv127.AttributeClientAddress: + case AttributeClientAddress: if net.ParseIP(value.Str()) != nil { info.Request.ClientIP = awsxray.String(value.Str()) } - case conventionsv127.AttributeURLPath: + case AttributeURLPath: urlParts[key] = value.Str() hasHTTP = true - case conventionsv127.AttributeServerAddress: + case AttributeServerAddress: urlParts[key] = value.Str() hasHTTPRequestURLAttributes = true - case conventionsv127.AttributeServerPort: + case AttributeServerPort: urlParts[key] = value.Str() if len(urlParts[key]) == 0 { urlParts[key] = strconv.FormatInt(value.Int(), 10) @@ -234,13 +247,13 @@ func constructServerURL(urlParts map[string]string) string { if !ok { host, ok = urlParts[conventions.AttributeHostName] if !ok { - host = urlParts[conventionsv127.AttributeServerAddress] + host = urlParts[AttributeServerAddress] } } } port, ok = urlParts[conventions.AttributeNetHostPort] if !ok { - port, ok = urlParts[conventionsv127.AttributeServerPort] + port, ok = urlParts[AttributeServerPort] if !ok { port = "" } @@ -254,7 +267,7 @@ func constructServerURL(urlParts map[string]string) string { if ok { url += target } else { - path, ok := urlParts[conventionsv127.AttributeURLPath] + path, ok := urlParts[AttributeURLPath] if ok { url += path } else { diff --git a/exporter/awsxrayexporter/internal/translator/http_test.go b/exporter/awsxrayexporter/internal/translator/http_test.go index 171d3f0b455b..d939eb45486a 100644 --- a/exporter/awsxrayexporter/internal/translator/http_test.go +++ b/exporter/awsxrayexporter/internal/translator/http_test.go @@ -13,7 +13,6 @@ import ( "github.com/stretchr/testify/require" "go.opentelemetry.io/collector/pdata/pcommon" "go.opentelemetry.io/collector/pdata/ptrace" - conventionsv127 "go.opentelemetry.io/collector/semconv/v1.27.0" conventions "go.opentelemetry.io/collector/semconv/v1.6.1" ) @@ -37,9 +36,9 @@ func TestClientSpanWithURLAttribute(t *testing.T) { func TestClientSpanWithURLAttributeStable(t *testing.T) { attributes := make(map[string]any) - attributes[conventionsv127.AttributeHTTPRequestMethod] = "GET" - attributes[conventionsv127.AttributeURLFull] = "https://api.example.com/users/junit" - attributes[conventionsv127.AttributeHTTPResponseStatusCode] = 200 + attributes[AttributeHTTPRequestMethod] = "GET" + attributes[AttributeURLFull] = "https://api.example.com/users/junit" + attributes[AttributeHTTPResponseStatusCode] = 200 span := constructHTTPClientSpan(attributes) filtered, httpData := makeHTTP(span) @@ -76,11 +75,11 @@ func TestClientSpanWithSchemeHostTargetAttributes(t *testing.T) { func TestClientSpanWithSchemeHostTargetAttributesStable(t *testing.T) { attributes := make(map[string]any) - attributes[conventionsv127.AttributeHTTPRequestMethod] = "GET" - attributes[conventionsv127.AttributeURLScheme] = "https" + attributes[AttributeHTTPRequestMethod] = "GET" + attributes[AttributeURLScheme] = "https" attributes[conventions.AttributeHTTPHost] = "api.example.com" - attributes[conventionsv127.AttributeURLQuery] = "/users/junit" - attributes[conventionsv127.AttributeHTTPResponseStatusCode] = 200 + attributes[AttributeURLQuery] = "/users/junit" + attributes[AttributeHTTPResponseStatusCode] = 200 attributes["user.id"] = "junit" span := constructHTTPClientSpan(attributes) @@ -123,13 +122,13 @@ func TestClientSpanWithPeerAttributes(t *testing.T) { func TestClientSpanWithPeerAttributesStable(t *testing.T) { attributes := make(map[string]any) - attributes[conventionsv127.AttributeHTTPRequestMethod] = "GET" - attributes[conventionsv127.AttributeURLScheme] = "http" + attributes[AttributeHTTPRequestMethod] = "GET" + attributes[AttributeURLScheme] = "http" attributes[conventions.AttributeNetPeerName] = "kb234.example.com" attributes[conventions.AttributeNetPeerPort] = 8080 attributes[conventions.AttributeNetPeerIP] = "10.8.17.36" - attributes[conventionsv127.AttributeURLQuery] = "/users/junit" - attributes[conventionsv127.AttributeHTTPResponseStatusCode] = 200 + attributes[AttributeURLQuery] = "/users/junit" + attributes[AttributeHTTPResponseStatusCode] = 200 span := constructHTTPClientSpan(attributes) filtered, httpData := makeHTTP(span) @@ -162,9 +161,9 @@ func TestClientSpanWithHttpPeerAttributes(t *testing.T) { func TestClientSpanWithHttpPeerAttributesStable(t *testing.T) { attributes := make(map[string]any) - attributes[conventionsv127.AttributeURLFull] = "https://api.example.com/users/junit" - attributes[conventionsv127.AttributeClientAddress] = "1.2.3.4" - attributes[conventionsv127.AttributeNetworkPeerAddress] = "10.8.17.36" + attributes[AttributeURLFull] = "https://api.example.com/users/junit" + attributes[AttributeClientAddress] = "1.2.3.4" + attributes[AttributeNetworkPeerAddress] = "10.8.17.36" span := constructHTTPClientSpan(attributes) filtered, httpData := makeHTTP(span) @@ -235,11 +234,11 @@ func TestServerSpanWithURLAttribute(t *testing.T) { func TestServerSpanWithURLAttributeStable(t *testing.T) { attributes := make(map[string]any) - attributes[conventionsv127.AttributeHTTPRequestMethod] = "GET" - attributes[conventionsv127.AttributeURLFull] = "https://api.example.com/users/junit" - attributes[conventionsv127.AttributeClientAddress] = "192.168.15.32" - attributes[conventionsv127.AttributeUserAgentOriginal] = "PostmanRuntime/7.21.0" - attributes[conventionsv127.AttributeHTTPResponseStatusCode] = 200 + attributes[AttributeHTTPRequestMethod] = "GET" + attributes[AttributeURLFull] = "https://api.example.com/users/junit" + attributes[AttributeClientAddress] = "192.168.15.32" + attributes[AttributeUserAgentOriginal] = "PostmanRuntime/7.21.0" + attributes[AttributeHTTPResponseStatusCode] = 200 span := constructHTTPServerSpan(attributes) filtered, httpData := makeHTTP(span) @@ -276,12 +275,12 @@ func TestServerSpanWithSchemeHostTargetAttributes(t *testing.T) { func TestServerSpanWithSchemeHostTargetAttributesStable(t *testing.T) { attributes := make(map[string]any) - attributes[conventionsv127.AttributeHTTPRequestMethod] = "GET" - attributes[conventionsv127.AttributeURLScheme] = "https" - attributes[conventionsv127.AttributeServerAddress] = "api.example.com" - attributes[conventionsv127.AttributeURLQuery] = "/users/junit" - attributes[conventionsv127.AttributeClientAddress] = "192.168.15.32" - attributes[conventionsv127.AttributeHTTPResponseStatusCode] = 200 + attributes[AttributeHTTPRequestMethod] = "GET" + attributes[AttributeURLScheme] = "https" + attributes[AttributeServerAddress] = "api.example.com" + attributes[AttributeURLQuery] = "/users/junit" + attributes[AttributeClientAddress] = "192.168.15.32" + attributes[AttributeHTTPResponseStatusCode] = 200 span := constructHTTPServerSpan(attributes) filtered, httpData := makeHTTP(span) @@ -319,13 +318,13 @@ func TestServerSpanWithSchemeServernamePortTargetAttributes(t *testing.T) { func TestServerSpanWithSchemeServernamePortTargetAttributesStable(t *testing.T) { attributes := make(map[string]any) - attributes[conventionsv127.AttributeHTTPRequestMethod] = "GET" - attributes[conventionsv127.AttributeURLScheme] = "https" - attributes[conventionsv127.AttributeServerAddress] = "api.example.com" - attributes[conventionsv127.AttributeServerPort] = 443 - attributes[conventionsv127.AttributeURLQuery] = "/users/junit" - attributes[conventionsv127.AttributeClientAddress] = "192.168.15.32" - attributes[conventionsv127.AttributeHTTPResponseStatusCode] = 200 + attributes[AttributeHTTPRequestMethod] = "GET" + attributes[AttributeURLScheme] = "https" + attributes[AttributeServerAddress] = "api.example.com" + attributes[AttributeServerPort] = 443 + attributes[AttributeURLQuery] = "/users/junit" + attributes[AttributeClientAddress] = "192.168.15.32" + attributes[AttributeHTTPResponseStatusCode] = 200 span := constructHTTPServerSpan(attributes) filtered, httpData := makeHTTP(span) @@ -365,13 +364,13 @@ func TestServerSpanWithSchemeNamePortTargetAttributes(t *testing.T) { func TestServerSpanWithSchemeNamePortTargetAttributesStable(t *testing.T) { attributes := make(map[string]any) - attributes[conventionsv127.AttributeHTTPRequestMethod] = "GET" - attributes[conventionsv127.AttributeURLScheme] = "http" - attributes[conventionsv127.AttributeServerAddress] = "kb234.example.com" - attributes[conventionsv127.AttributeServerPort] = 8080 - attributes[conventionsv127.AttributeURLPath] = "/users/junit" - attributes[conventionsv127.AttributeClientAddress] = "192.168.15.32" - attributes[conventionsv127.AttributeHTTPResponseStatusCode] = 200 + attributes[AttributeHTTPRequestMethod] = "GET" + attributes[AttributeURLScheme] = "http" + attributes[AttributeServerAddress] = "kb234.example.com" + attributes[AttributeServerPort] = 8080 + attributes[AttributeURLPath] = "/users/junit" + attributes[AttributeClientAddress] = "192.168.15.32" + attributes[AttributeHTTPResponseStatusCode] = 200 span := constructHTTPServerSpan(attributes) timeEvents := constructTimedEventsWithReceivedMessageEvent(span.EndTimestamp()) timeEvents.CopyTo(span.Events()) @@ -415,13 +414,13 @@ func TestSpanWithNotEnoughHTTPRequestURLAttributes(t *testing.T) { func TestSpanWithNotEnoughHTTPRequestURLAttributesStable(t *testing.T) { attributes := make(map[string]any) - attributes[conventionsv127.AttributeHTTPRequestMethod] = "GET" - attributes[conventionsv127.AttributeURLScheme] = "http" - attributes[conventionsv127.AttributeClientAddress] = "192.168.15.32" - attributes[conventionsv127.AttributeUserAgentOriginal] = "PostmanRuntime/7.21.0" - attributes[conventionsv127.AttributeURLPath] = "/users/junit" - attributes[conventionsv127.AttributeServerPort] = 443 - attributes[conventionsv127.AttributeHTTPResponseStatusCode] = 200 + attributes[AttributeHTTPRequestMethod] = "GET" + attributes[AttributeURLScheme] = "http" + attributes[AttributeClientAddress] = "192.168.15.32" + attributes[AttributeUserAgentOriginal] = "PostmanRuntime/7.21.0" + attributes[AttributeURLPath] = "/users/junit" + attributes[AttributeServerPort] = 443 + attributes[AttributeHTTPResponseStatusCode] = 200 span := constructHTTPServerSpan(attributes) timeEvents := constructTimedEventsWithReceivedMessageEvent(span.EndTimestamp()) timeEvents.CopyTo(span.Events()) @@ -441,20 +440,20 @@ func TestSpanWithNotEnoughHTTPRequestURLAttributesStable(t *testing.T) { func TestSpanWithNotEnoughHTTPRequestURLAttributesDuplicated(t *testing.T) { attributes := make(map[string]any) attributes[conventions.AttributeHTTPMethod] = "GET" - attributes[conventionsv127.AttributeHTTPRequestMethod] = "GET" + attributes[AttributeHTTPRequestMethod] = "GET" attributes[conventions.AttributeHTTPScheme] = "http" - attributes[conventionsv127.AttributeURLScheme] = "http" + attributes[AttributeURLScheme] = "http" attributes[conventions.AttributeHTTPClientIP] = "192.168.15.32" - attributes[conventionsv127.AttributeClientAddress] = "192.168.15.32" + attributes[AttributeClientAddress] = "192.168.15.32" attributes[conventions.AttributeHTTPUserAgent] = "PostmanRuntime/7.21.0" - attributes[conventionsv127.AttributeUserAgentOriginal] = "PostmanRuntime/7.21.0" + attributes[AttributeUserAgentOriginal] = "PostmanRuntime/7.21.0" attributes[conventions.AttributeHTTPTarget] = "/users/junit" - attributes[conventionsv127.AttributeURLPath] = "/users/junit" + attributes[AttributeURLPath] = "/users/junit" attributes[conventions.AttributeNetHostPort] = 443 - attributes[conventionsv127.AttributeServerPort] = 443 + attributes[AttributeServerPort] = 443 attributes[conventions.AttributeNetPeerPort] = 8080 attributes[conventions.AttributeHTTPStatusCode] = 200 - attributes[conventionsv127.AttributeHTTPResponseStatusCode] = 200 + attributes[AttributeHTTPResponseStatusCode] = 200 span := constructHTTPServerSpan(attributes) timeEvents := constructTimedEventsWithReceivedMessageEvent(span.EndTimestamp()) timeEvents.CopyTo(span.Events()) @@ -473,8 +472,8 @@ func TestSpanWithNotEnoughHTTPRequestURLAttributesDuplicated(t *testing.T) { func TestSpanWithClientAddrWithoutNetworkPeerAddr(t *testing.T) { attributes := make(map[string]any) - attributes[conventionsv127.AttributeURLFull] = "https://api.example.com/users/junit" - attributes[conventionsv127.AttributeClientAddress] = "192.168.15.32" + attributes[AttributeURLFull] = "https://api.example.com/users/junit" + attributes[AttributeClientAddress] = "192.168.15.32" span := constructHTTPServerSpan(attributes) _, httpData := makeHTTP(span) @@ -483,9 +482,9 @@ func TestSpanWithClientAddrWithoutNetworkPeerAddr(t *testing.T) { } func TestSpanWithClientAddrAndNetworkPeerAddr(t *testing.T) { attributes := make(map[string]any) - attributes[conventionsv127.AttributeURLFull] = "https://api.example.com/users/junit" - attributes[conventionsv127.AttributeClientAddress] = "192.168.15.32" - attributes[conventionsv127.AttributeNetworkPeerAddress] = "192.168.15.32" + attributes[AttributeURLFull] = "https://api.example.com/users/junit" + attributes[AttributeClientAddress] = "192.168.15.32" + attributes[AttributeNetworkPeerAddress] = "192.168.15.32" span := constructHTTPServerSpan(attributes) _, httpData := makeHTTP(span) @@ -496,9 +495,9 @@ func TestSpanWithClientAddrAndNetworkPeerAddr(t *testing.T) { func TestSpanWithClientAddrNotIP(t *testing.T) { attributes := make(map[string]any) - attributes[conventionsv127.AttributeURLFull] = "https://api.example.com/users/junit" - attributes[conventionsv127.AttributeClientAddress] = "api.example.com" - attributes[conventionsv127.AttributeNetworkPeerAddress] = "api.example.com" + attributes[AttributeURLFull] = "https://api.example.com/users/junit" + attributes[AttributeClientAddress] = "api.example.com" + attributes[AttributeNetworkPeerAddress] = "api.example.com" span := constructHTTPServerSpan(attributes) _, httpData := makeHTTP(span) diff --git a/go.mod b/go.mod index 81eb8d6284d7..6ef036a1d2e9 100644 --- a/go.mod +++ b/go.mod @@ -668,7 +668,7 @@ require ( github.com/spf13/viper v1.19.0 // indirect github.com/stormcat24/protodep v0.1.8 // indirect github.com/stretchr/objx v0.5.2 // indirect - github.com/stretchr/testify v1.10.0 // indirect + github.com/stretchr/testify v1.9.0 // indirect github.com/subosito/gotenv v1.6.0 // indirect github.com/syndtr/gocapability v0.0.0-20200815063812-42c35b437635 // indirect github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/common v1.0.940 // indirect @@ -727,7 +727,7 @@ require ( go.opentelemetry.io/collector/featuregate v1.10.0 // indirect go.opentelemetry.io/collector/filter v0.103.0 // indirect go.opentelemetry.io/collector/pdata v1.10.0 // indirect - go.opentelemetry.io/collector/semconv v0.116.0 // indirect + go.opentelemetry.io/collector/semconv v0.103.0 // indirect go.opentelemetry.io/collector/service v0.103.0 // indirect go.opentelemetry.io/contrib/config v0.7.0 // indirect go.opentelemetry.io/contrib/instrumentation/google.golang.org/grpc/otelgrpc v0.52.0 // indirect diff --git a/go.sum b/go.sum index cdb6e55401e1..f69cba1993a7 100644 --- a/go.sum +++ b/go.sum @@ -2181,9 +2181,8 @@ github.com/stretchr/testify v1.8.1/go.mod h1:w2LPCIKwWwSfY2zedu0+kehJoqGctiVI29o github.com/stretchr/testify v1.8.2/go.mod h1:w2LPCIKwWwSfY2zedu0+kehJoqGctiVI29o6fzry7u4= github.com/stretchr/testify v1.8.3/go.mod h1:sz/lmYIOXD/1dqDmKjjqLyZ2RngseejIcXlSw2iwfAo= github.com/stretchr/testify v1.8.4/go.mod h1:sz/lmYIOXD/1dqDmKjjqLyZ2RngseejIcXlSw2iwfAo= +github.com/stretchr/testify v1.9.0 h1:HtqpIVDClZ4nwg75+f6Lvsy/wHu+3BoSGCbBAcpTsTg= github.com/stretchr/testify v1.9.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY= -github.com/stretchr/testify v1.10.0 h1:Xv5erBjTwe/5IxqUQTdXv5kgmIvbHo3QQyRwhJsOfJA= -github.com/stretchr/testify v1.10.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY= github.com/subosito/gotenv v1.2.0/go.mod h1:N0PQaV/YGNqwC0u51sEeR/aUtSLEXKX9iv69rRypqCw= github.com/subosito/gotenv v1.6.0 h1:9NlTDc1FTs4qu0DDq7AEtTPNw6SVm7uBMsUCUjABIf8= github.com/subosito/gotenv v1.6.0/go.mod h1:Dk4QP5c2W3ibzajGcXpNraDfq2IrhjMIvMSWPKKo0FU= @@ -2391,8 +2390,8 @@ go.opentelemetry.io/collector/receiver v0.103.0 h1:V3JBKkX+7e/NYpDDZVyeu2VQB1/lL go.opentelemetry.io/collector/receiver v0.103.0/go.mod h1:Yybv4ynKFdMOYViWWPMmjkugR89FSQN0P37wP6mX6qM= go.opentelemetry.io/collector/receiver/otlpreceiver v0.103.0 h1:TycVVl4AWioV6kWeFcCIk2QuKfXOzn88yw989opsMdE= go.opentelemetry.io/collector/receiver/otlpreceiver v0.103.0/go.mod h1:jAbzL5lwOGG93YbcPZ6aFZIZq+tjYQ+BS3vKKT2nRgw= -go.opentelemetry.io/collector/semconv v0.116.0 h1:63xCZomsKJAWmKGWD3lnORiE3WKW6AO4LjnzcHzGx3Y= -go.opentelemetry.io/collector/semconv v0.116.0/go.mod h1:N6XE8Q0JKgBN2fAhkUQtqK9LT7rEGR6+Wu/Rtbal1iI= +go.opentelemetry.io/collector/semconv v0.103.0 h1:5tlVoZlo9USHAU2Bz4YrEste0Vm5AMufXkYJhAVve1Q= +go.opentelemetry.io/collector/semconv v0.103.0/go.mod h1:yMVUCNoQPZVq/IPfrHrnntZTWsLf5YGZ7qwKulIl5hw= go.opentelemetry.io/collector/service v0.103.0 h1:e4Eri4jo+YOuEK0+/JE9SUdT/NZaJ2jz/ROJlmLn96s= go.opentelemetry.io/collector/service v0.103.0/go.mod h1:p1mlniiC1MuPN5FANYJYgf5V5CGFP0hNqWfI8t7Aw8M= go.opentelemetry.io/contrib/config v0.7.0 h1:b1rK5tGTuhhPirJiMxOcyQfZs76j2VapY6ODn3b2Dbs=