File tree Expand file tree Collapse file tree 4 files changed +14
-2
lines changed
Expand file tree Collapse file tree 4 files changed +14
-2
lines changed Original file line number Diff line number Diff line change 55package nrawssdk
66
77import (
8+ "net/http"
9+
810 "github.com/aws/aws-sdk-go/aws/request"
911 "github.com/newrelic/go-agent/v3/internal"
1012 "github.com/newrelic/go-agent/v3/internal/awssupport"
@@ -25,7 +27,13 @@ func startSegment(req *request.Request) {
2527
2628func endSegment (req * request.Request ) {
2729 ctx := req .HTTPRequest .Context ()
28- awssupport .EndSegment (ctx , req .HTTPResponse .Header )
30+
31+ hdr := http.Header {}
32+ if req .HTTPRequest != nil {
33+ hdr = req .HTTPRequest .Header
34+ }
35+
36+ awssupport .EndSegment (ctx , hdr )
2937}
3038
3139// InstrumentHandlers will add instrumentation to the given *request.Handlers.
Original file line number Diff line number Diff line change @@ -620,6 +620,8 @@ func TestGetRequestID(t *testing.T) {
620620 primary : []string {"hello" },
621621 secondary : []string {"world" },
622622 }, expected : "hello" },
623+
624+ {hdr : http.Header {}, expected : "" },
623625 }
624626
625627 // Make sure our assumptions still hold against aws-sdk-go
Original file line number Diff line number Diff line change @@ -70,7 +70,7 @@ func StartSegment(input StartSegmentInputs) *http.Request {
7070
7171 var segment endable
7272 // Service name capitalization is different for v1 and v2.
73- if input .ServiceName == "dynamodb" || input .ServiceName == "DynamoDB" {
73+ if input .ServiceName == "dynamodb" || input .ServiceName == "DynamoDB" || input . ServiceName == "dax" {
7474 segment = & newrelic.DatastoreSegment {
7575 Product : newrelic .DatastoreDynamoDB ,
7676 Collection : getTableName (input .Params ),
Original file line number Diff line number Diff line change @@ -73,6 +73,8 @@ func TestGetRequestID(t *testing.T) {
7373 primary : []string {"hello" },
7474 secondary : []string {"world" },
7575 }, expected : "hello" },
76+
77+ {hdr : http.Header {}, expected : "" },
7678 }
7779
7880 for i , test := range testcases {
You can’t perform that action at this time.
0 commit comments