aws / aws-xray-sdk-go

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

using x-ray with aws-sdk-v2 makes the binary files bigger than expected #470

Open kuadrosx opened 5 months ago

kuadrosx commented 5 months ago

Hello,

I was migrating from aws-sdk-v1(in July 31, 2024 it will be in maintance mode) to aws-sdk-v2 and I noticed that the binary files got twice its size.

Using https://pkg.go.dev/github.com/Zxilly/go-size-analyzer I find out that it was because both sdk version were imported:

| 10.62%  | github.com/aws/aws-sdk-go-v2                 | 3.8 MB | vendor    |
| 6.02%   | github.com/aws/aws-sdk-go                    | 2.1 MB | vendor    |

after finish the migration I continue seeing aws-sdk-go being added to the binary, so using https://github.com/KyleBanks/depth I learn that xray was importing both SDKs.

I reproduced the issue using the sample app defined in this repository and adding 3 more version:

https://github.com/kuadrosx/aws-xray-sdk-go/tree/reproduce-big-files-issue/sample-apps

these are the sizes of each version:

 15M    ./http-server-sdk-v1-no-xray
 25M    ./http-server-sdk-v1
 11M    ./http-server-sdk-v2-no-xray
 34M    ./http-server-sdk-v2
 86M    .

I think the expected size should be around 21M or less.

wangzlei commented 4 months ago

Yes, the xray go sdk still using aws-sdk-v1 for sampling, it cause aws-sdk-v2 only customer's binary has to include aws-sdk-v1 dependencies.

I create an issue that migrate aws sdk v1 in sampling module to net/http https://github.com/aws/aws-xray-sdk-go/issues/473