-
Notifications
You must be signed in to change notification settings - Fork 39
/
Copy pathdynamodb_tags.go
62 lines (57 loc) · 1.57 KB
/
dynamodb_tags.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
// (c) Copyright IBM Corp. 2021
// (c) Copyright Instana Inc. 2021
package instaawssdk
import (
"github.com/aws/aws-sdk-go/aws"
"github.com/aws/aws-sdk-go/aws/request"
"github.com/aws/aws-sdk-go/service/dynamodb"
"github.com/opentracing/opentracing-go"
)
func extractDynamoDBTags(req *request.Request) (opentracing.Tags, error) {
var tags opentracing.Tags
switch params := req.Params.(type) {
case *dynamodb.CreateTableInput:
tags = opentracing.Tags{
dynamodbOp: "create",
dynamodbTable: aws.StringValue(params.TableName),
}
case *dynamodb.ListTablesInput:
tags = opentracing.Tags{
dynamodbOp: "list",
}
case *dynamodb.GetItemInput:
tags = opentracing.Tags{
dynamodbOp: "get",
dynamodbTable: aws.StringValue(params.TableName),
}
case *dynamodb.PutItemInput:
tags = opentracing.Tags{
dynamodbOp: "put",
dynamodbTable: aws.StringValue(params.TableName),
}
case *dynamodb.UpdateItemInput:
tags = opentracing.Tags{
dynamodbOp: "update",
dynamodbTable: aws.StringValue(params.TableName),
}
case *dynamodb.DeleteItemInput:
tags = opentracing.Tags{
dynamodbOp: "delete",
dynamodbTable: aws.StringValue(params.TableName),
}
case *dynamodb.QueryInput:
tags = opentracing.Tags{
dynamodbOp: "query",
dynamodbTable: aws.StringValue(params.TableName),
}
case *dynamodb.ScanInput:
tags = opentracing.Tags{
dynamodbOp: "scan",
dynamodbTable: aws.StringValue(params.TableName),
}
default:
return nil, errMethodNotInstrumented
}
tags[dynamodbRegion] = aws.StringValue(req.Config.Region)
return tags, nil
}