diff --git a/CHANGELOG.md b/CHANGELOG.md index 3d0f0d2da52..c3a15878186 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -48,8 +48,9 @@ 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/labstack/echo/otelecho/test`, use `Version` function instead. (#7090) - The deprecated `SemVersion` function is removed in `go.opentelemetry.io/contrib/instrumentation/github.com/emicklei/go-restful/otelrestful`, use `Version` function instead. (#7091) - The deprecated `SemVersion` function is removed in `go.opentelemetry.io/contrib/instrumentation/github.com/emicklei/go-restful/otelrestful/test`, use `Version` function instead. (#7092) -- The deprecated `SemVersion` function is removed in `go.opentelemetry.io/contrib/instrumentation/github.com/aws/aws-sdk-go-v2/otelaws`, use `Version` function instead. (#7154) - The deprecated `UnaryServerInterceptor` in `go.opentelemetry.io/contrib/instrumentation/google.golang.org/grpc/otelgrpc` is removed, use `NewServerHandler` instead. (#7115) +- The deprecated `AttributeSetter` function is removed in `go.opentelemetry.io/contrib/instrumentation/github.com/aws/aws-sdk-go-v2/otelaws`, use the `AttributeBuilder` function instead. (#7137) +- The deprecated `SemVersion` function is removed in `go.opentelemetry.io/contrib/instrumentation/github.com/aws/aws-sdk-go-v2/otelaws`, use `Version` function instead. (#7154) diff --git a/instrumentation/github.com/aws/aws-sdk-go-v2/otelaws/aws.go b/instrumentation/github.com/aws/aws-sdk-go-v2/otelaws/aws.go index c338b8ac5cd..acf48dc54ae 100644 --- a/instrumentation/github.com/aws/aws-sdk-go-v2/otelaws/aws.go +++ b/instrumentation/github.com/aws/aws-sdk-go-v2/otelaws/aws.go @@ -27,11 +27,6 @@ const ( type spanTimestampKey struct{} -// AttributeSetter returns an array of KeyValue pairs, it can be used to set custom attributes. -// -// Deprecated: Use AttributeBuilder instead. This will be removed in a future release. -type AttributeSetter func(context.Context, middleware.InitializeInput) []attribute.KeyValue - // AttributeBuilder returns an array of KeyValue pairs, it can be used to set custom attributes. type AttributeBuilder func(ctx context.Context, in middleware.InitializeInput, out middleware.InitializeOutput) []attribute.KeyValue diff --git a/instrumentation/github.com/aws/aws-sdk-go-v2/otelaws/config.go b/instrumentation/github.com/aws/aws-sdk-go-v2/otelaws/config.go index 385ba6b8561..7f7f276f188 100755 --- a/instrumentation/github.com/aws/aws-sdk-go-v2/otelaws/config.go +++ b/instrumentation/github.com/aws/aws-sdk-go-v2/otelaws/config.go @@ -4,11 +4,6 @@ package otelaws // import "go.opentelemetry.io/contrib/instrumentation/github.com/aws/aws-sdk-go-v2/otelaws" import ( - "context" - - "github.com/aws/smithy-go/middleware" - - "go.opentelemetry.io/otel/attribute" "go.opentelemetry.io/otel/propagation" "go.opentelemetry.io/otel/trace" ) @@ -52,19 +47,6 @@ func WithTextMapPropagator(propagator propagation.TextMapPropagator) Option { }) } -// WithAttributeSetter specifies an attribute setter function for setting service specific attributes. -// If none is specified, the service will be determined by the DefaultAttributeBuilder function and the corresponding attributes will be included. -func WithAttributeSetter(attributesetters ...AttributeSetter) Option { - var attributeBuilders []AttributeBuilder - for _, setter := range attributesetters { - attributeBuilders = append(attributeBuilders, func(ctx context.Context, in middleware.InitializeInput, out middleware.InitializeOutput) []attribute.KeyValue { - return setter(ctx, in) - }) - } - - return WithAttributeBuilder(attributeBuilders...) -} - // WithAttributeBuilder specifies an attribute setter function for setting service specific attributes. // If none is specified, the service will be determined by the DefaultAttributeBuilder function and the corresponding attributes will be included. func WithAttributeBuilder(attributeBuilders ...AttributeBuilder) Option { 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..1be57596f56 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,90 +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 { responseStatus int