From 030191b1a91fc76b0ffcd726741005868df5b03b Mon Sep 17 00:00:00 2001 From: Dithi Date: Wed, 2 Apr 2025 23:45:45 +0530 Subject: [PATCH 1/2] removed DynamoDBAttributeSetter and TestDynamodbTagsCustomSetter --- CHANGELOG.md | 3 + .../otelaws/dynamodbattributes.go | 7 -- .../otelaws/test/dynamodbattributes_test.go | 83 ------------------- 3 files changed, 3 insertions(+), 90 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index b89474c4e23..2aea524d0a7 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -41,6 +41,9 @@ This project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.htm - The deprecated `SemVersion` function in `go.opentelemetry.io/contrib/samplers/probability/consistent` is removed, use `Version` instead. (#7072) - The deprecated `SemVersion` function is removed in `go.opentelemetry.io/contrib/instrumentation/github.com/gorilla/mux/otelmux`, use `Version` function instead. (#7084) - The deprecated `SemVersion` function is removed in `go.opentelemetry.io/contrib/instrumentation/github.com/gin-gonic/gin/otelgin`, use `Version` function instead. (#7085) +- The deprecated `DynamoDBAttributeSetter` function is removed `opentelemetry-go-contrib/instrumentation/github.com/aws/aws-sdk-go-v2/otelaws/dynamodbattributes.go` , use `Version` function instead.(#7099) +- The deprecated `TestDynamodbTagsCustomSetter` function is removed `opentelemetry-go-contrib/instrumentation/github.com/aws/aws-sdk-go-v2/otelaws/test/dynamodbattributes_test.go` , use `Version` function instead.(#7099) + diff --git a/instrumentation/github.com/aws/aws-sdk-go-v2/otelaws/dynamodbattributes.go b/instrumentation/github.com/aws/aws-sdk-go-v2/otelaws/dynamodbattributes.go index def2eff930d..2bd8f35725b 100644 --- a/instrumentation/github.com/aws/aws-sdk-go-v2/otelaws/dynamodbattributes.go +++ b/instrumentation/github.com/aws/aws-sdk-go-v2/otelaws/dynamodbattributes.go @@ -14,13 +14,6 @@ import ( semconv "go.opentelemetry.io/otel/semconv/v1.21.0" ) -// DynamoDBAttributeSetter sets DynamoDB specific attributes depending on the DynamoDB operation being performed. -// -// Deprecated: Use DynamoDBAttributeBuilder instead. This will be removed in a future release. -func DynamoDBAttributeSetter(ctx context.Context, in middleware.InitializeInput) []attribute.KeyValue { - return DynamoDBAttributeBuilder(ctx, in, middleware.InitializeOutput{}) -} - // DynamoDBAttributeBuilder sets DynamoDB specific attributes depending on the DynamoDB operation being performed. func DynamoDBAttributeBuilder(ctx context.Context, in middleware.InitializeInput, out middleware.InitializeOutput) []attribute.KeyValue { dynamodbAttributes := []attribute.KeyValue{semconv.DBSystemDynamoDB} diff --git a/instrumentation/github.com/aws/aws-sdk-go-v2/otelaws/test/dynamodbattributes_test.go b/instrumentation/github.com/aws/aws-sdk-go-v2/otelaws/test/dynamodbattributes_test.go index e5564437fd5..aa476a1fdd1 100644 --- a/instrumentation/github.com/aws/aws-sdk-go-v2/otelaws/test/dynamodbattributes_test.go +++ b/instrumentation/github.com/aws/aws-sdk-go-v2/otelaws/test/dynamodbattributes_test.go @@ -105,89 +105,6 @@ func TestDynamodbTags(t *testing.T) { }) } -//nolint:staticcheck // Tests for deprecated AttributeSetter that will be removed in the future release. -func TestDynamodbTagsCustomSetter(t *testing.T) { - cases := struct { - responseStatus int - expectedRegion string - expectedStatusCode int - expectedError codes.Code - }{ - responseStatus: http.StatusOK, - expectedRegion: "us-west-2", - expectedStatusCode: http.StatusOK, - } - - server := httptest.NewServer(http.HandlerFunc( - func(w http.ResponseWriter, r *http.Request) { - w.WriteHeader(cases.responseStatus) - })) - defer server.Close() - - t.Run("dynamodb tags", func(t *testing.T) { - sr := tracetest.NewSpanRecorder() - provider := sdktrace.NewTracerProvider(sdktrace.WithSpanProcessor(sr)) - - svc := dynamodb.New(dynamodb.Options{ - Region: cases.expectedRegion, - BaseEndpoint: &server.URL, - AuthSchemeResolver: &dynamoDBAuthResolver{}, - Retryer: aws.NopRetryer{}, - }) - - mycustomsetter := otelaws.AttributeSetter(func(context.Context, middleware.InitializeInput) []attribute.KeyValue { - customAttributes := []attribute.KeyValue{ - { - Key: "customattribute2key", - Value: attribute.StringValue("customattribute2value"), - }, - { - Key: "customattribute1key", - Value: attribute.StringValue("customattribute1value"), - }, - } - - return customAttributes - }) - - _, err := svc.GetItem(context.Background(), &dynamodb.GetItemInput{ - TableName: aws.String("table1"), - ConsistentRead: aws.Bool(false), - ProjectionExpression: aws.String("test"), - Key: map[string]dtypes.AttributeValue{ - "id": &dtypes.AttributeValueMemberS{Value: "test"}, - }, - }, func(options *dynamodb.Options) { - otelaws.AppendMiddlewares( - &options.APIOptions, otelaws.WithAttributeSetter(otelaws.DynamoDBAttributeSetter, mycustomsetter), otelaws.WithTracerProvider(provider)) - }) - - if cases.expectedError == codes.Unset { - assert.NoError(t, err) - } else { - assert.Error(t, err) - } - - spans := sr.Ended() - require.Len(t, spans, 1) - span := spans[0] - - assert.Equal(t, "DynamoDB.GetItem", span.Name()) - assert.Equal(t, trace.SpanKindClient, span.SpanKind()) - attrs := span.Attributes() - assert.Contains(t, attrs, attribute.Int("http.status_code", cases.expectedStatusCode)) - assert.Contains(t, attrs, attribute.String("rpc.service", "DynamoDB")) - assert.Contains(t, attrs, attribute.String("aws.region", cases.expectedRegion)) - assert.Contains(t, attrs, attribute.String("rpc.method", "GetItem")) - assert.Contains(t, attrs, attribute.StringSlice( - "aws.dynamodb.table_names", []string{"table1"}, - )) - assert.Contains(t, attrs, attribute.String("aws.dynamodb.projection", "test")) - assert.Contains(t, attrs, attribute.Bool("aws.dynamodb.consistent_read", false)) - assert.Contains(t, attrs, attribute.String("customattribute2key", "customattribute2value")) - assert.Contains(t, attrs, attribute.String("customattribute1key", "customattribute1value")) - }) -} func TestDynamodbTagsCustomBuilder(t *testing.T) { cases := struct { From 6f80e97754b71469935ef430a776bd9d13f378f3 Mon Sep 17 00:00:00 2001 From: Dithi Date: Thu, 3 Apr 2025 16:40:25 +0530 Subject: [PATCH 2/2] Updated changelog entry as per feedback --- CHANGELOG.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 2aea524d0a7..34fdbeb0919 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -42,8 +42,8 @@ This project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.htm - The deprecated `SemVersion` function is removed in `go.opentelemetry.io/contrib/instrumentation/github.com/gorilla/mux/otelmux`, use `Version` function instead. (#7084) - The deprecated `SemVersion` function is removed in `go.opentelemetry.io/contrib/instrumentation/github.com/gin-gonic/gin/otelgin`, use `Version` function instead. (#7085) - The deprecated `DynamoDBAttributeSetter` function is removed `opentelemetry-go-contrib/instrumentation/github.com/aws/aws-sdk-go-v2/otelaws/dynamodbattributes.go` , use `Version` function instead.(#7099) -- The deprecated `TestDynamodbTagsCustomSetter` function is removed `opentelemetry-go-contrib/instrumentation/github.com/aws/aws-sdk-go-v2/otelaws/test/dynamodbattributes_test.go` , use `Version` function instead.(#7099) - + +