Skip to content

Commit

Permalink
Remove changes to Dynamo attribute setter
Browse files Browse the repository at this point in the history
  • Loading branch information
lukestoward committed Nov 2, 2022
1 parent d2a9358 commit 83bf151
Show file tree
Hide file tree
Showing 7 changed files with 1 addition and 73 deletions.
3 changes: 1 addition & 2 deletions CHANGELOG.md
Expand Up @@ -10,8 +10,7 @@ This project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.htm

### Added

- `instrumentation/github.com/aws/aws-sdk-go-v2/otelaws`: Add `aws.table_name` attribute to all supporting DynamoDB operations (#2879).
- `instrumentation/github.com/aws/aws-sdk-go-v2/otelaws`: Add `aws.queue_url` & `messaging.url` attributes to all supporting SQS operations (#2879).
- `instrumentation/github.com/aws/aws-sdk-go-v2/otelaws`: Add semconv `messaging.url` & `messaging.system` attributes to all supporting SQS operations (#2879).

## [1.11.1/0.36.4/0.5.2]

Expand Down
12 changes: 0 additions & 12 deletions instrumentation/github.com/aws/aws-sdk-go-v2/otelaws/attributes.go
Expand Up @@ -31,8 +31,6 @@ const (
RegionKey attribute.Key = "aws.region"
ServiceKey attribute.Key = "aws.service"
RequestIDKey attribute.Key = "aws.request_id"
TableNameKey attribute.Key = "aws.table_name"
QueueURLKey attribute.Key = "aws.queue_url"
)

var servicemap = map[string]AttributeSetter{
Expand Down Expand Up @@ -60,16 +58,6 @@ func RequestIDAttr(requestID string) attribute.KeyValue {
return RequestIDKey.String(requestID)
}

// TableNameAttr returns the AWS table name attribute for a single table name.
func TableNameAttr(tableName string) attribute.KeyValue {
return TableNameKey.String(tableName)
}

// QueueURLAttr returns the AWS queue URL attribute.
func QueueURLAttr(queueURL string) attribute.KeyValue {
return QueueURLKey.String(queueURL)
}

// DefaultAttributeSetter checks to see if there are service specific attributes available to set for the AWS service.
// If there are service specific attributes available then they will be included.
func DefaultAttributeSetter(ctx context.Context, in middleware.InitializeInput) []attribute.KeyValue {
Expand Down
Expand Up @@ -45,15 +45,3 @@ func TestRequestIDAttr(t *testing.T) {
attr := RequestIDAttr(requestID)
assert.Equal(t, attribute.String("aws.request_id", requestID), attr)
}

func TestTableNameAttr(t *testing.T) {
tableName := "test-table-name"
attr := TableNameAttr(tableName)
assert.Equal(t, attribute.String("aws.table_name", tableName), attr)
}

func TestQueueURLAttr(t *testing.T) {
queueURL := "test-queue-url"
attr := QueueURLAttr(queueURL)
assert.Equal(t, attribute.String("aws.queue_url", queueURL), attr)
}
Expand Up @@ -32,7 +32,6 @@ func DynamoDBAttributeSetter(ctx context.Context, in middleware.InitializeInput)
switch v := in.Parameters.(type) {
case *dynamodb.GetItemInput:
dynamodbAttributes = append(dynamodbAttributes, semconv.AWSDynamoDBTableNamesKey.String(*v.TableName))
dynamodbAttributes = append(dynamodbAttributes, TableNameAttr(*v.TableName))

if v.ConsistentRead != nil {
dynamodbAttributes = append(dynamodbAttributes, semconv.AWSDynamoDBConsistentReadKey.Bool(*v.ConsistentRead))
Expand All @@ -58,7 +57,6 @@ func DynamoDBAttributeSetter(ctx context.Context, in middleware.InitializeInput)

case *dynamodb.CreateTableInput:
dynamodbAttributes = append(dynamodbAttributes, semconv.AWSDynamoDBTableNamesKey.String(*v.TableName))
dynamodbAttributes = append(dynamodbAttributes, TableNameAttr(*v.TableName))

if v.GlobalSecondaryIndexes != nil {
globalindexes, _ := json.Marshal(v.GlobalSecondaryIndexes)
Expand All @@ -77,15 +75,12 @@ func DynamoDBAttributeSetter(ctx context.Context, in middleware.InitializeInput)

case *dynamodb.DeleteItemInput:
dynamodbAttributes = append(dynamodbAttributes, semconv.AWSDynamoDBTableNamesKey.String(*v.TableName))
dynamodbAttributes = append(dynamodbAttributes, TableNameAttr(*v.TableName))

case *dynamodb.DeleteTableInput:
dynamodbAttributes = append(dynamodbAttributes, semconv.AWSDynamoDBTableNamesKey.String(*v.TableName))
dynamodbAttributes = append(dynamodbAttributes, TableNameAttr(*v.TableName))

case *dynamodb.DescribeTableInput:
dynamodbAttributes = append(dynamodbAttributes, semconv.AWSDynamoDBTableNamesKey.String(*v.TableName))
dynamodbAttributes = append(dynamodbAttributes, TableNameAttr(*v.TableName))

case *dynamodb.ListTablesInput:
if v.ExclusiveStartTableName != nil {
Expand All @@ -98,11 +93,9 @@ func DynamoDBAttributeSetter(ctx context.Context, in middleware.InitializeInput)

case *dynamodb.PutItemInput:
dynamodbAttributes = append(dynamodbAttributes, semconv.AWSDynamoDBTableNamesKey.String(*v.TableName))
dynamodbAttributes = append(dynamodbAttributes, TableNameAttr(*v.TableName))

case *dynamodb.QueryInput:
dynamodbAttributes = append(dynamodbAttributes, semconv.AWSDynamoDBTableNamesKey.String(*v.TableName))
dynamodbAttributes = append(dynamodbAttributes, TableNameAttr(*v.TableName))

if v.ConsistentRead != nil {
dynamodbAttributes = append(dynamodbAttributes, semconv.AWSDynamoDBConsistentReadKey.Bool(*v.ConsistentRead))
Expand All @@ -128,7 +121,6 @@ func DynamoDBAttributeSetter(ctx context.Context, in middleware.InitializeInput)

case *dynamodb.ScanInput:
dynamodbAttributes = append(dynamodbAttributes, semconv.AWSDynamoDBTableNamesKey.String(*v.TableName))
dynamodbAttributes = append(dynamodbAttributes, TableNameAttr(*v.TableName))

if v.ConsistentRead != nil {
dynamodbAttributes = append(dynamodbAttributes, semconv.AWSDynamoDBConsistentReadKey.Bool(*v.ConsistentRead))
Expand Down Expand Up @@ -158,11 +150,9 @@ func DynamoDBAttributeSetter(ctx context.Context, in middleware.InitializeInput)

case *dynamodb.UpdateItemInput:
dynamodbAttributes = append(dynamodbAttributes, semconv.AWSDynamoDBTableNamesKey.String(*v.TableName))
dynamodbAttributes = append(dynamodbAttributes, TableNameAttr(*v.TableName))

case *dynamodb.UpdateTableInput:
dynamodbAttributes = append(dynamodbAttributes, semconv.AWSDynamoDBTableNamesKey.String(*v.TableName))
dynamodbAttributes = append(dynamodbAttributes, TableNameAttr(*v.TableName))

if v.AttributeDefinitions != nil {
attributedefinitions, _ := json.Marshal(v.AttributeDefinitions)
Expand Down
Expand Up @@ -128,7 +128,6 @@ func TestDynamodbTagsCreateTableInput(t *testing.T) {
attributes := DynamoDBAttributeSetter(context.TODO(), input)

assert.Contains(t, attributes, attribute.String("aws.dynamodb.table_names", "table1"))
assert.Contains(t, attributes, attribute.String("aws.table_name", "table1"))
assert.Contains(t, attributes, attribute.String("aws.dynamodb.global_secondary_indexes", "[{\"IndexName\":\"index1\",\"KeySchema\":[{\"AttributeName\":\"attributename\",\"KeyType\":\"HASH\"}],\"Projection\":{\"NonKeyAttributes\":[\"non-key-attributes\"],\"ProjectionType\":\"\"},\"ProvisionedThroughput\":null}]"))
assert.Contains(t, attributes, attribute.String("aws.dynamodb.local_secondary_indexes", "[{\"IndexName\":\"index2\",\"KeySchema\":[{\"AttributeName\":\"attributename\",\"KeyType\":\"HASH\"}],\"Projection\":null}]"))
assert.Contains(t, attributes, attribute.Int("aws.dynamodb.provisioned_read_capacity", 123))
Expand All @@ -147,7 +146,6 @@ func TestDynamodbTagsDeleteItemInput(t *testing.T) {
attributes := DynamoDBAttributeSetter(context.TODO(), input)

assert.Contains(t, attributes, attribute.String("aws.dynamodb.table_names", "table1"))
assert.Contains(t, attributes, attribute.String("aws.table_name", "table1"))
}

func TestDynamodbTagsDeleteTableInput(t *testing.T) {
Expand All @@ -159,7 +157,6 @@ func TestDynamodbTagsDeleteTableInput(t *testing.T) {
attributes := DynamoDBAttributeSetter(context.TODO(), input)

assert.Contains(t, attributes, attribute.String("aws.dynamodb.table_names", "table1"))
assert.Contains(t, attributes, attribute.String("aws.table_name", "table1"))
}

func TestDynamodbTagsDescribeTableInput(t *testing.T) {
Expand All @@ -171,7 +168,6 @@ func TestDynamodbTagsDescribeTableInput(t *testing.T) {
attributes := DynamoDBAttributeSetter(context.TODO(), input)

assert.Contains(t, attributes, attribute.String("aws.dynamodb.table_names", "table1"))
assert.Contains(t, attributes, attribute.String("aws.table_name", "table1"))
}

func TestDynamodbTagsListTablesInput(t *testing.T) {
Expand Down Expand Up @@ -202,7 +198,6 @@ func TestDynamodbTagsPutItemInput(t *testing.T) {
attributes := DynamoDBAttributeSetter(context.TODO(), input)

assert.Contains(t, attributes, attribute.String("aws.dynamodb.table_names", "table1"))
assert.Contains(t, attributes, attribute.String("aws.table_name", "table1"))
}

func TestDynamodbTagsQueryInput(t *testing.T) {
Expand All @@ -229,7 +224,6 @@ func TestDynamodbTagsQueryInput(t *testing.T) {
attributes := DynamoDBAttributeSetter(context.TODO(), input)

assert.Contains(t, attributes, attribute.String("aws.dynamodb.table_names", "table1"))
assert.Contains(t, attributes, attribute.String("aws.table_name", "table1"))
assert.Contains(t, attributes, attribute.Bool("aws.dynamodb.consistent_read", true))
assert.Contains(t, attributes, attribute.String("aws.dynamodb.index_name", "index1"))
assert.Contains(t, attributes, attribute.Int("aws.dynamodb.limit", 10))
Expand All @@ -255,7 +249,6 @@ func TestDynamodbTagsScanInput(t *testing.T) {
attributes := DynamoDBAttributeSetter(context.TODO(), input)

assert.Contains(t, attributes, attribute.String("aws.dynamodb.table_names", "my-table"))
assert.Contains(t, attributes, attribute.String("aws.table_name", "my-table"))
assert.Contains(t, attributes, attribute.Bool("aws.dynamodb.consistent_read", true))
assert.Contains(t, attributes, attribute.String("aws.dynamodb.index_name", "index1"))
assert.Contains(t, attributes, attribute.Int("aws.dynamodb.limit", 10))
Expand All @@ -282,7 +275,6 @@ func TestDynamodbTagsUpdateItemInput(t *testing.T) {
attributes := DynamoDBAttributeSetter(context.TODO(), input)

assert.Contains(t, attributes, attribute.String("aws.dynamodb.table_names", "my-table"))
assert.Contains(t, attributes, attribute.String("aws.table_name", "my-table"))
}

func TestDynamodbTagsUpdateTableInput(t *testing.T) {
Expand Down Expand Up @@ -322,7 +314,6 @@ func TestDynamodbTagsUpdateTableInput(t *testing.T) {
attributes := DynamoDBAttributeSetter(context.TODO(), input)

assert.Contains(t, attributes, attribute.String("aws.dynamodb.table_names", "my-table"))
assert.Contains(t, attributes, attribute.String("aws.table_name", "my-table"))
assert.Contains(t, attributes, attribute.String("aws.dynamodb.attribute_definitions", "[{\"AttributeName\":\"id\",\"AttributeType\":\"S\"}]"))
assert.Contains(t, attributes, attribute.String("aws.dynamodb.global_secondary_index_updates", "[{\"Create\":{\"IndexName\":\"index1\",\"KeySchema\":[{\"AttributeName\":\"attribute\",\"KeyType\":\"HASH\"}],\"Projection\":{\"NonKeyAttributes\":[\"attribute1\",\"attribute2\"],\"ProjectionType\":\"ALL\"},\"ProvisionedThroughput\":null},\"Delete\":null,\"Update\":null}]"))
assert.Contains(t, attributes, attribute.Int("aws.dynamodb.provisioned_read_capacity", 123))
Expand Down
Expand Up @@ -30,46 +30,32 @@ func SQSAttributeSetter(ctx context.Context, in middleware.InitializeInput) []at

switch v := in.Parameters.(type) {
case *sqs.DeleteMessageBatchInput:
sqsAttributes = append(sqsAttributes, QueueURLKey.String(*v.QueueUrl))
sqsAttributes = append(sqsAttributes, semconv.MessagingURLKey.String(*v.QueueUrl))
case *sqs.DeleteMessageInput:
sqsAttributes = append(sqsAttributes, QueueURLKey.String(*v.QueueUrl))
sqsAttributes = append(sqsAttributes, semconv.MessagingURLKey.String(*v.QueueUrl))
case *sqs.DeleteQueueInput:
sqsAttributes = append(sqsAttributes, QueueURLKey.String(*v.QueueUrl))
sqsAttributes = append(sqsAttributes, semconv.MessagingURLKey.String(*v.QueueUrl))
case *sqs.GetQueueAttributesInput:
sqsAttributes = append(sqsAttributes, QueueURLKey.String(*v.QueueUrl))
sqsAttributes = append(sqsAttributes, semconv.MessagingURLKey.String(*v.QueueUrl))
case *sqs.ListDeadLetterSourceQueuesInput:
sqsAttributes = append(sqsAttributes, QueueURLKey.String(*v.QueueUrl))
sqsAttributes = append(sqsAttributes, semconv.MessagingURLKey.String(*v.QueueUrl))
case *sqs.ListQueueTagsInput:
sqsAttributes = append(sqsAttributes, QueueURLKey.String(*v.QueueUrl))
sqsAttributes = append(sqsAttributes, semconv.MessagingURLKey.String(*v.QueueUrl))
case *sqs.PurgeQueueInput:
sqsAttributes = append(sqsAttributes, QueueURLKey.String(*v.QueueUrl))
sqsAttributes = append(sqsAttributes, semconv.MessagingURLKey.String(*v.QueueUrl))
case *sqs.ReceiveMessageInput:
sqsAttributes = append(sqsAttributes, QueueURLKey.String(*v.QueueUrl))
sqsAttributes = append(sqsAttributes, semconv.MessagingURLKey.String(*v.QueueUrl))
case *sqs.RemovePermissionInput:
sqsAttributes = append(sqsAttributes, QueueURLKey.String(*v.QueueUrl))
sqsAttributes = append(sqsAttributes, semconv.MessagingURLKey.String(*v.QueueUrl))
case *sqs.SendMessageBatchInput:
sqsAttributes = append(sqsAttributes, QueueURLKey.String(*v.QueueUrl))
sqsAttributes = append(sqsAttributes, semconv.MessagingURLKey.String(*v.QueueUrl))
case *sqs.SendMessageInput:
sqsAttributes = append(sqsAttributes, QueueURLKey.String(*v.QueueUrl))
sqsAttributes = append(sqsAttributes, semconv.MessagingURLKey.String(*v.QueueUrl))
case *sqs.SetQueueAttributesInput:
sqsAttributes = append(sqsAttributes, QueueURLKey.String(*v.QueueUrl))
sqsAttributes = append(sqsAttributes, semconv.MessagingURLKey.String(*v.QueueUrl))
case *sqs.TagQueueInput:
sqsAttributes = append(sqsAttributes, QueueURLKey.String(*v.QueueUrl))
sqsAttributes = append(sqsAttributes, semconv.MessagingURLKey.String(*v.QueueUrl))
case *sqs.UntagQueueInput:
sqsAttributes = append(sqsAttributes, QueueURLKey.String(*v.QueueUrl))
sqsAttributes = append(sqsAttributes, semconv.MessagingURLKey.String(*v.QueueUrl))
}

Expand Down
Expand Up @@ -35,7 +35,6 @@ func TestSQSDeleteMessageBatchInput(t *testing.T) {

attributes := SQSAttributeSetter(context.TODO(), input)

assert.Contains(t, attributes, attribute.String("aws.queue_url", "test-queue-url"))
assert.Contains(t, attributes, attribute.String("messaging.url", "test-queue-url"))
}

Expand All @@ -48,7 +47,6 @@ func TestSQSDeleteMessageInput(t *testing.T) {

attributes := SQSAttributeSetter(context.TODO(), input)

assert.Contains(t, attributes, attribute.String("aws.queue_url", "test-queue-url"))
assert.Contains(t, attributes, attribute.String("messaging.url", "test-queue-url"))
}

Expand All @@ -61,7 +59,6 @@ func TestSQSDeleteQueueInput(t *testing.T) {

attributes := SQSAttributeSetter(context.TODO(), input)

assert.Contains(t, attributes, attribute.String("aws.queue_url", "test-queue-url"))
assert.Contains(t, attributes, attribute.String("messaging.url", "test-queue-url"))
}

Expand All @@ -74,7 +71,6 @@ func TestSQSGetQueueAttributesInput(t *testing.T) {

attributes := SQSAttributeSetter(context.TODO(), input)

assert.Contains(t, attributes, attribute.String("aws.queue_url", "test-queue-url"))
assert.Contains(t, attributes, attribute.String("messaging.url", "test-queue-url"))
}

Expand All @@ -87,7 +83,6 @@ func TestSQSListDeadLetterSourceQueuesInput(t *testing.T) {

attributes := SQSAttributeSetter(context.TODO(), input)

assert.Contains(t, attributes, attribute.String("aws.queue_url", "test-queue-url"))
assert.Contains(t, attributes, attribute.String("messaging.url", "test-queue-url"))
}

Expand All @@ -100,7 +95,6 @@ func TestSQSListQueueTagsInput(t *testing.T) {

attributes := SQSAttributeSetter(context.TODO(), input)

assert.Contains(t, attributes, attribute.String("aws.queue_url", "test-queue-url"))
assert.Contains(t, attributes, attribute.String("messaging.url", "test-queue-url"))
}

Expand All @@ -113,7 +107,6 @@ func TestSQSPurgeQueueInput(t *testing.T) {

attributes := SQSAttributeSetter(context.TODO(), input)

assert.Contains(t, attributes, attribute.String("aws.queue_url", "test-queue-url"))
assert.Contains(t, attributes, attribute.String("messaging.url", "test-queue-url"))
}

Expand All @@ -126,7 +119,6 @@ func TestSQSReceiveMessageInput(t *testing.T) {

attributes := SQSAttributeSetter(context.TODO(), input)

assert.Contains(t, attributes, attribute.String("aws.queue_url", "test-queue-url"))
assert.Contains(t, attributes, attribute.String("messaging.url", "test-queue-url"))
}

Expand All @@ -139,7 +131,6 @@ func TestSQSRemovePermissionInput(t *testing.T) {

attributes := SQSAttributeSetter(context.TODO(), input)

assert.Contains(t, attributes, attribute.String("aws.queue_url", "test-queue-url"))
assert.Contains(t, attributes, attribute.String("messaging.url", "test-queue-url"))
}

Expand All @@ -152,7 +143,6 @@ func TestSQSSendMessageBatchInput(t *testing.T) {

attributes := SQSAttributeSetter(context.TODO(), input)

assert.Contains(t, attributes, attribute.String("aws.queue_url", "test-queue-url"))
assert.Contains(t, attributes, attribute.String("messaging.url", "test-queue-url"))
}

Expand All @@ -165,7 +155,6 @@ func TestSQSSendMessageInput(t *testing.T) {

attributes := SQSAttributeSetter(context.TODO(), input)

assert.Contains(t, attributes, attribute.String("aws.queue_url", "test-queue-url"))
assert.Contains(t, attributes, attribute.String("messaging.url", "test-queue-url"))
}

Expand All @@ -178,7 +167,6 @@ func TestSQSSetQueueAttributesInput(t *testing.T) {

attributes := SQSAttributeSetter(context.TODO(), input)

assert.Contains(t, attributes, attribute.String("aws.queue_url", "test-queue-url"))
assert.Contains(t, attributes, attribute.String("messaging.url", "test-queue-url"))
}

Expand All @@ -191,7 +179,6 @@ func TestSQSTagQueueInput(t *testing.T) {

attributes := SQSAttributeSetter(context.TODO(), input)

assert.Contains(t, attributes, attribute.String("aws.queue_url", "test-queue-url"))
assert.Contains(t, attributes, attribute.String("messaging.url", "test-queue-url"))
}

Expand All @@ -204,6 +191,5 @@ func TestSQSUntagQueueInput(t *testing.T) {

attributes := SQSAttributeSetter(context.TODO(), input)

assert.Contains(t, attributes, attribute.String("aws.queue_url", "test-queue-url"))
assert.Contains(t, attributes, attribute.String("messaging.url", "test-queue-url"))
}

0 comments on commit 83bf151

Please sign in to comment.