Existing sampling decision ignored when creating new segments with no http.Request
(SQS -> ECS tracing)
#350
Labels
http.Request
(SQS -> ECS tracing)
#350
To implement tracing on an ECS worker processing SQS messages, we use the
NewSegmentFromHeader
function:aws-xray-sdk-go/xray/segment.go
Line 315 in 3b7709c
Since there's no
http.Request
available in a SQS processing context, anil
is passed instead. This causes the existing sampling decision to be ignored and a new one requested instead:aws-xray-sdk-go/xray/segment.go
Lines 101 to 103 in 3b7709c
This results in some segments missing and possibly in depleting the sampling reservoir, which could be used by other traces.
Looking through the docs and code there doesn't seem to be any alternative way of creating a segment from an existing tracing header. A workaround we've come up with is to pass an empty request (
&http.Request{URL: &url.URL{}}
) to theNewSegmentFromHeader
function.This could preferably be solved on the SDK level, though. A relatively simple solution would seem to be to remove the
r == nil
condition from:aws-xray-sdk-go/xray/segment.go
Line 101 in 3b7709c
and instead fill the
sampling.Request
with HTTP request related data in bothif
branches only when it's available. After all, the HTTP request is only used when requesting the sampling decision.Any insight into the issue and proposed fix would be much appreciated.
Possibly related issue: #234
The text was updated successfully, but these errors were encountered: