Search code examples
amazon-web-servicesaws-xray

assign x-amzn-trace-id to downstream process


I am trying to x-ray trace a process through a multitude of services.

I have a lambda that is already traced by x-ray, that submits to kinesis, and eventually is processed by a Scala ECS consumer. How do I link the lambda to the consumer?

Is this handled automagically, or do I need to grab and insert the x-amzn-trace-id value?

Thanks


Solution

  • Yes, the idea is right.

    1. get the current Lambda trace context from Lambda function, add it to Kinesis data.
    2. extract that trace context from ECS cunsumer side, and use it as the parent of consumer segment.

    One possible technical trouble is, if consumer processes a batch of trace contexts in one operation, you might not be able to set parent for consumer segment because a segment can only have one parent. X-Ray needs to support links feature to support this fan-in scenario.

    FYI links: https://github.com/open-telemetry/opentelemetry-specification/blob/main/specification/overview.md#links-between-spans