Skip to content

Commit 4e12823

Browse files
committed
Migrate internal/aws/xray/testdata to aws-sdk-for-go-v2
1 parent ce93940 commit 4e12823

File tree

6 files changed

+78
-51
lines changed

6 files changed

+78
-51
lines changed

internal/aws/xray/testdata/sampleapp/go.mod

Lines changed: 18 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,28 @@ module github.com/open-telemetry/opentelemetry-collector-contrib/internal/aws/xr
33
go 1.23.0
44

55
require (
6-
github.com/aws/aws-sdk-go v1.55.7
7-
github.com/aws/aws-xray-sdk-go v1.8.5
6+
github.com/aws/aws-sdk-go-v2 v1.36.3
7+
github.com/aws/aws-sdk-go-v2/config v1.29.14
8+
github.com/aws/aws-sdk-go-v2/feature/dynamodb/attributevalue v1.18.12
9+
github.com/aws/aws-sdk-go-v2/service/dynamodb v1.42.4
10+
github.com/aws/aws-xray-sdk-go/v2 v2.0.0
811
)
912

1013
require (
1114
github.com/andybalholm/brotli v1.1.0 // indirect
12-
github.com/jmespath/go-jmespath v0.4.0 // indirect
15+
github.com/aws/aws-sdk-go-v2/credentials v1.17.67 // indirect
16+
github.com/aws/aws-sdk-go-v2/feature/ec2/imds v1.16.30 // indirect
17+
github.com/aws/aws-sdk-go-v2/internal/configsources v1.3.34 // indirect
18+
github.com/aws/aws-sdk-go-v2/internal/endpoints/v2 v2.6.34 // indirect
19+
github.com/aws/aws-sdk-go-v2/internal/ini v1.8.3 // indirect
20+
github.com/aws/aws-sdk-go-v2/service/dynamodbstreams v1.25.3 // indirect
21+
github.com/aws/aws-sdk-go-v2/service/internal/accept-encoding v1.12.3 // indirect
22+
github.com/aws/aws-sdk-go-v2/service/internal/endpoint-discovery v1.10.15 // indirect
23+
github.com/aws/aws-sdk-go-v2/service/internal/presigned-url v1.12.15 // indirect
24+
github.com/aws/aws-sdk-go-v2/service/sso v1.25.3 // indirect
25+
github.com/aws/aws-sdk-go-v2/service/ssooidc v1.30.1 // indirect
26+
github.com/aws/aws-sdk-go-v2/service/sts v1.33.19 // indirect
27+
github.com/aws/smithy-go v1.22.2 // indirect
1328
github.com/klauspost/compress v1.17.6 // indirect
1429
github.com/pkg/errors v0.9.1 // indirect
1530
github.com/stretchr/testify v1.10.0 // indirect
@@ -23,7 +38,6 @@ require (
2338
google.golang.org/genproto/googleapis/rpc v0.0.0-20241202173237-19429a94021a // indirect
2439
google.golang.org/grpc v1.70.0 // indirect
2540
google.golang.org/protobuf v1.36.5 // indirect
26-
gopkg.in/yaml.v2 v2.4.0 // indirect
2741
)
2842

2943
retract (

internal/aws/xray/testdata/sampleapp/go.sum

Lines changed: 38 additions & 12 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

internal/aws/xray/testdata/sampleapp/sample.go

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -6,15 +6,14 @@ package main
66
import (
77
"context"
88

9-
"github.com/aws/aws-sdk-go/aws"
10-
"github.com/aws/aws-sdk-go/aws/session"
11-
"github.com/aws/aws-sdk-go/service/dynamodb"
12-
"github.com/aws/aws-sdk-go/service/dynamodb/dynamodbattribute"
13-
"github.com/aws/aws-xray-sdk-go/xray"
9+
"github.com/aws/aws-sdk-go-v2/aws"
10+
"github.com/aws/aws-sdk-go-v2/config"
11+
"github.com/aws/aws-sdk-go-v2/feature/dynamodb/attributevalue"
12+
"github.com/aws/aws-sdk-go-v2/service/dynamodb"
13+
"github.com/aws/aws-xray-sdk-go/v2/instrumentation/awsv2"
14+
"github.com/aws/aws-xray-sdk-go/v2/xray"
1415
)
1516

16-
var dynamo *dynamodb.DynamoDB
17-
1817
const (
1918
existingTableName = "xray_sample_table"
2019
nonExistingTableName = "does_not_exist"
@@ -26,20 +25,21 @@ type Record struct {
2625
}
2726

2827
func main() {
29-
dynamo = dynamodb.New(session.Must(session.NewSession(
30-
&aws.Config{
31-
Region: aws.String("us-west-2"),
32-
},
33-
)))
34-
xray.AWS(dynamo.Client)
28+
cfg, err := config.LoadDefaultConfig(context.Background(), config.WithRegion("us-west-2"))
29+
if err != nil {
30+
panic(err)
31+
}
32+
awsv2.AWSV2Instrumentor(&cfg.APIOptions)
33+
34+
client := dynamodb.NewFromConfig(cfg)
3535

3636
ctx, seg := xray.BeginSegment(context.Background(), "DDB")
3737
seg.User = "xraysegmentdump"
38-
err := ddbExpectedFailure(ctx)
38+
err = ddbExpectedFailure(ctx, client)
3939
seg.Close(err)
4040
}
4141

42-
func ddbExpectedFailure(ctx context.Context) error {
42+
func ddbExpectedFailure(ctx context.Context, client *dynamodb.Client) error {
4343
err := xray.Capture(ctx, "DDB.DescribeExistingTableAndPutToMissingTable", func(ctx1 context.Context) error {
4444
err := xray.AddAnnotation(ctx1, "DDB.DescribeExistingTableAndPutToMissingTable.Annotation", "anno")
4545
if err != nil {
@@ -50,7 +50,7 @@ func ddbExpectedFailure(ctx context.Context) error {
5050
return err
5151
}
5252

53-
_, err = dynamo.DescribeTableWithContext(ctx1, &dynamodb.DescribeTableInput{
53+
_, err = client.DescribeTable(ctx1, &dynamodb.DescribeTableInput{
5454
TableName: aws.String(existingTableName),
5555
})
5656
if err != nil {
@@ -62,12 +62,12 @@ func ddbExpectedFailure(ctx context.Context) error {
6262
URL: "https://example.com/first/link",
6363
}
6464

65-
item, err := dynamodbattribute.MarshalMap(&r)
65+
item, err := attributevalue.MarshalMap(&r)
6666
if err != nil {
6767
return err
6868
}
6969

70-
_, err = dynamo.PutItemWithContext(ctx1, &dynamodb.PutItemInput{
70+
_, err = client.PutItem(ctx1, &dynamodb.PutItemInput{
7171
TableName: aws.String(nonExistingTableName),
7272
Item: item,
7373
})

internal/aws/xray/testdata/sampleserver/go.mod

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,10 @@ module github.com/open-telemetry/opentelemetry-collector-contrib/internal/aws/xr
22

33
go 1.23.0
44

5-
require github.com/aws/aws-xray-sdk-go v1.8.5
5+
require github.com/aws/aws-xray-sdk-go/v2 v2.0.0
66

77
require (
88
github.com/andybalholm/brotli v1.1.0 // indirect
9-
github.com/aws/aws-sdk-go v1.47.10 // indirect
10-
github.com/jmespath/go-jmespath v0.4.0 // indirect
119
github.com/klauspost/compress v1.17.6 // indirect
1210
github.com/pkg/errors v0.9.1 // indirect
1311
github.com/stretchr/testify v1.10.0 // indirect

internal/aws/xray/testdata/sampleserver/go.sum

Lines changed: 2 additions & 13 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

internal/aws/xray/testdata/sampleserver/sample.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import (
77
"net/http"
88
"time"
99

10-
"github.com/aws/aws-xray-sdk-go/xray"
10+
"github.com/aws/aws-xray-sdk-go/v2/xray"
1111
)
1212

1313
func main() {

0 commit comments

Comments
 (0)