Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Preserving trace id in Lambda -> SQS -> Lambda flow #59

Open
triha74 opened this issue Nov 15, 2021 · 0 comments
Open

Preserving trace id in Lambda -> SQS -> Lambda flow #59

triha74 opened this issue Nov 15, 2021 · 0 comments
Labels
Pending/Triage Pending triage Proposed Community submited

Comments

@triha74
Copy link

triha74 commented Nov 15, 2021

Runtime:
All of them

Is your feature request related to a problem? Please describe
SQS Supports XRay but since Lambda execution is done as batch the lambda function consuming the queue starts a new trace. To work around this the consuming lambda needs to over write the traceid with the AWSTraceHeader value.

`func handler(ctx context.Context, event events.SQSEvent) {

if trcHdrStr, ok := event.Records[0].Attributes["AWSTraceHeader"]; ok {
	traceHeader := header.FromString(trcHdrStr)

	var seg *xray.Segment
	ctx, seg = xray.BeginSegment(ctx, "YOUR-SEGMENT-NAME")
	seg.TraceID = traceHeader.TraceID
	seg.ParentID = traceHeader.ParentID
	seg.Sampled = traceHeader.SamplingDecision == header.Sampled

	defer seg.Close(nil)
}

}`

This is described at length here https://medium.com/@filiplubniewski/distributed-tracing-in-serverless-with-x-ray-lambda-sqs-and-golang-f38616cbd79b

Describe the solution you'd like
This would be perfect to have as an annotation

Describe alternatives you've considered
Its obivously an annotation ;)

If you provide guidance, is this something you'd like to contribute?

Additional context

@triha74 triha74 added Pending/Triage Pending triage Proposed Community submited labels Nov 15, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Pending/Triage Pending triage Proposed Community submited
Projects
None yet
Development

No branches or pull requests

1 participant