diff --git a/instrumentation/awsv2/awsv2.go b/instrumentation/awsv2/awsv2.go index 9584361d..3af9a39a 100644 --- a/instrumentation/awsv2/awsv2.go +++ b/instrumentation/awsv2/awsv2.go @@ -67,6 +67,9 @@ func deserializeMiddleware(stack *middleware.Stack) error { return out, metadata, err } + // Lock subseg before updating + subseg.Lock() + subseg.GetHTTP().GetResponse().ContentLength = int(resp.ContentLength) requestID, ok := v2Middleware.GetRequestIDMetadata(metadata) @@ -77,6 +80,8 @@ func deserializeMiddleware(stack *middleware.Stack) error { subseg.GetAWS()[xray.ExtendedRequestIDKey] = extendedRequestID } + subseg.Unlock() + xray.HttpCaptureResponse(subseg, resp.StatusCode) return out, metadata, err }),