Skip to content

Commit

Permalink
User-agent redesign - add additional information to user-agent (#188)
Browse files Browse the repository at this point in the history
* Added additional information to user-agent string

* Update CHANGELOG

---------

Co-authored-by: William Armiros <[email protected]>
  • Loading branch information
carolabadeer and willarmiros authored Feb 2, 2023
1 parent 51df4f0 commit acaf06e
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 3 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
All notable changes to this project will be documented in this file.

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

## 3.3.5 (2022-09-22)
Expand Down
18 changes: 15 additions & 3 deletions pkg/conn/xray_client.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,20 +11,25 @@ package conn

import (
"os"
"runtime"
"strconv"
"strings"
"time"

"github.com/aws/aws-xray-daemon/pkg/cfg"

"github.com/aws/aws-sdk-go/aws"
"github.com/aws/aws-sdk-go/aws/awserr"
"github.com/aws/aws-sdk-go/aws/request"
"github.com/aws/aws-sdk-go/aws/session"
"github.com/aws/aws-sdk-go/service/xray"
"github.com/aws/aws-xray-daemon/pkg/cfg"
log "github.com/cihub/seelog"
)

// Constant prefixes used to identify information in user-agent
const agentPrefix = "xray-agent/xray-daemon/"
const execEnvPrefix = " exec-env/"
const osPrefix = " OS/"

// XRay defines X-Ray api call structure.
type XRay interface {
PutTraceSegments(input *xray.PutTraceSegmentsInput) (*xray.PutTraceSegmentsOutput, error)
Expand All @@ -51,9 +56,16 @@ func NewXRay(awsConfig *aws.Config, s *session.Session) XRay {
x := xray.New(s, awsConfig)
log.Debugf("Using Endpoint: %s", x.Endpoint)

execEnv := os.Getenv("AWS_EXECUTION_ENV")
if execEnv == "" {
execEnv = "UNKNOWN"
}

osInformation := runtime.GOOS + "-" + runtime.GOARCH

x.Handlers.Build.PushBackNamed(request.NamedHandler{
Name: "tracing.XRayVersionUserAgentHandler",
Fn: request.MakeAddToUserAgentHandler("xray", cfg.Version, os.Getenv("AWS_EXECUTION_ENV")),
Fn: request.MakeAddToUserAgentFreeFormHandler(agentPrefix + cfg.Version + execEnvPrefix + execEnv + osPrefix + osInformation),
})

x.Handlers.Sign.PushFrontNamed(request.NamedHandler{
Expand Down

0 comments on commit acaf06e

Please sign in to comment.