aws / aws-xray-sdk-go

AWS X-Ray SDK for the Go programming language.
Apache License 2.0
278 stars 118 forks source link

SDKV1 and SDKV2 sections in README are different which leads to confusion when migrating from SDKV1 to SDKV2 #368

Closed DanielBauman88 closed 2 years ago

DanielBauman88 commented 2 years ago

The README shows code snippets for how to integrate AWS clients with XRAY.

The sections I'm referring to are "AWS SDK Instrumentation" and "AWS SDK V2 Instrumentation".

The v1 snippet does not create a segment. The snippet will only work if a segment has already been created (or if run in a lambda where it is already available).

The v2 snippet does create a segment.

    ctx, root := xray.BeginSegment(context.TODO(), "AWSSDKV2_Dynamodb")
    defer root.Close(nil)

This is confusing because the two snippets are not doing the same thing. It is particularly confusing when migrating from SDKv1 to SDKv2 when your application runs in lambda. It looks as though you need to start creating segments which you never had to do before.

This should be improved so that both sections do the same thing. The creation of the segment could be included in both snippets with a comment that it isn't needed in lambda envs or other envs where the segment will be bootstrapped automatically.

wangzlei commented 2 years ago

This is a healthy suggestion, README should uniform the sample style of v1 and v2.

jj22ee commented 2 years ago

PR for this issue - https://github.com/aws/aws-xray-sdk-go/pull/370