From e281d010e09a2264aa631eb3534fdc65c1b77b42 Mon Sep 17 00:00:00 2001 From: Zhonghao Zhao Date: Mon, 6 Jan 2025 22:15:24 +0000 Subject: [PATCH] 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=