diff --git a/go.mod b/go.mod index 1865a89..6898006 100644 --- a/go.mod +++ b/go.mod @@ -1 +1,5 @@ module github.com/newrelic/newrelic-telemetry-sdk-go + +go 1.14 + +require github.com/google/uuid v1.1.1 diff --git a/go.sum b/go.sum new file mode 100644 index 0000000..b864886 --- /dev/null +++ b/go.sum @@ -0,0 +1,2 @@ +github.com/google/uuid v1.1.1 h1:Gkbcsh/GbpXz7lPftLA3P6TYMwjCLYm83jiFQZF/3gY= +github.com/google/uuid v1.1.1/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= diff --git a/telemetry/request.go b/telemetry/request.go index ff262ff..9b785ed 100644 --- a/telemetry/request.go +++ b/telemetry/request.go @@ -8,6 +8,8 @@ import ( "fmt" "net/http" + "github.com/google/uuid" + "github.com/newrelic/newrelic-telemetry-sdk-go/internal" ) @@ -54,6 +56,11 @@ func newRequestsInternal(batch requestsBuilder, apiKey string, url string, userA if nil != err { return nil, fmt.Errorf("error creating request: %v", err) } + + reqId, err := uuid.NewRandom() + if err == nil { + req.Header.Add("x-request-id", reqId.String()) + } req.Header.Add("Content-Type", "application/json") req.Header.Add("Api-Key", apiKey) req.Header.Add("Content-Encoding", "gzip")