Skip to content

Commit acaf06e

Browse files
User-agent redesign - add additional information to user-agent (#188)
* Added additional information to user-agent string * Update CHANGELOG --------- Co-authored-by: William Armiros <[email protected]>
1 parent 51df4f0 commit acaf06e

File tree

2 files changed

+16
-3
lines changed

2 files changed

+16
-3
lines changed

CHANGELOG.md

+1
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
All notable changes to this project will be documented in this file.
33

44
## 3.3.6 (2023-02-01)
5+
- User-agent redesign - add additional information to user-agent [PR #188](https://github.com/aws/aws-xray-daemon/pull/188)
56
- Remove custom backoff logic for sending segments [PR #186](https://github.com/aws/aws-xray-daemon/pull/186)
67

78
## 3.3.5 (2022-09-22)

pkg/conn/xray_client.go

+15-3
Original file line numberDiff line numberDiff line change
@@ -11,20 +11,25 @@ package conn
1111

1212
import (
1313
"os"
14+
"runtime"
1415
"strconv"
1516
"strings"
1617
"time"
1718

18-
"github.com/aws/aws-xray-daemon/pkg/cfg"
19-
2019
"github.com/aws/aws-sdk-go/aws"
2120
"github.com/aws/aws-sdk-go/aws/awserr"
2221
"github.com/aws/aws-sdk-go/aws/request"
2322
"github.com/aws/aws-sdk-go/aws/session"
2423
"github.com/aws/aws-sdk-go/service/xray"
24+
"github.com/aws/aws-xray-daemon/pkg/cfg"
2525
log "github.com/cihub/seelog"
2626
)
2727

28+
// Constant prefixes used to identify information in user-agent
29+
const agentPrefix = "xray-agent/xray-daemon/"
30+
const execEnvPrefix = " exec-env/"
31+
const osPrefix = " OS/"
32+
2833
// XRay defines X-Ray api call structure.
2934
type XRay interface {
3035
PutTraceSegments(input *xray.PutTraceSegmentsInput) (*xray.PutTraceSegmentsOutput, error)
@@ -51,9 +56,16 @@ func NewXRay(awsConfig *aws.Config, s *session.Session) XRay {
5156
x := xray.New(s, awsConfig)
5257
log.Debugf("Using Endpoint: %s", x.Endpoint)
5358

59+
execEnv := os.Getenv("AWS_EXECUTION_ENV")
60+
if execEnv == "" {
61+
execEnv = "UNKNOWN"
62+
}
63+
64+
osInformation := runtime.GOOS + "-" + runtime.GOARCH
65+
5466
x.Handlers.Build.PushBackNamed(request.NamedHandler{
5567
Name: "tracing.XRayVersionUserAgentHandler",
56-
Fn: request.MakeAddToUserAgentHandler("xray", cfg.Version, os.Getenv("AWS_EXECUTION_ENV")),
68+
Fn: request.MakeAddToUserAgentFreeFormHandler(agentPrefix + cfg.Version + execEnvPrefix + execEnv + osPrefix + osInformation),
5769
})
5870

5971
x.Handlers.Sign.PushFrontNamed(request.NamedHandler{

0 commit comments

Comments
 (0)