AWS XRay 0 traces retrieved but can be found by traceid

0

I'm not sure if it's a bug or I set things up wrongly.

The issue is tha no traces is retrieved via the batch get traces api but I can check trace details with trace ID from the CloudWatch console. Traces are showing up from the new transaction search service in cloudwatch as well. But 0 traces scanned via the old Xray console.

I have verified in CloudTrail logs that PutTraceSegments are successful and spans are being delivered to aws/spans cloudwatch group.

The api gateway request returns the header x-amzn-trace-id: Root=1-REDACTED;Sampled=1;Lineage=1:4063a7f1:0, so the request is being sampled.

What is missing here?

1 Answer
0
Accepted Answer
  1. You're Using the New Distributed Tracing Model (CloudWatch Spans)
  • Traces are being delivered to the /aws/spans log group. This is the new format used by CloudWatch Observability (CWOT).
  • The PutTraceSegments API calls you're seeing in CloudTrail confirm delivery to this newer backend.
  • However, the X-Ray SDK/API (e.g., BatchGetTraces, GetTraceSummaries) is still tied to the legacy X-Ray service and data store, not /aws/spans.

  1. BatchGetTraces Will Return Nothing

If your application or Lambda is instrumented with OpenTelemetry or CloudWatch native tracing, and spans are sent to /aws/spans, they will not be queryable via X-Ray's BatchGetTraces or shown in the legacy X-Ray console.

Only traces stored in the legacy X-Ray segment store (i.e., via PutTraceSegments in the X-Ray API, not CloudWatch Logs) will be retrievable via those APIs.


  1. How to Query Traces Now
  • Use the CloudWatch console → Application Signals or Service Map → Traces tab
  • Or query spans from the /aws/spans log group using CloudWatch Logs Insights

You can query spans like this:

fields @timestamp, traceId, serviceName, name
| sort @timestamp desc
| limit 20

  1. Recommendation

If you want BatchGetTraces to work, you must configure your application to send traces to X-Ray, not CloudWatch. That typically involves using:

  • The X-Ray SDK (not OpenTelemetry SDK)
  • X-Ray daemon or embedded collector
  • PutTraceSegments to X-Ray, not CloudWatch Logs

But if you're already using the new CloudWatch tracing model, it’s better to move entirely to CloudWatch ServiceLens and OpenTelemetry and stop expecting X-Ray API compatibility.

profile picture
answered 12 days ago
profile pictureAWS
EXPERT
reviewed 9 days ago

You are not logged in. Log in to post an answer.

A good answer clearly answers the question and provides constructive feedback and encourages professional growth in the question asker.

Guidelines for Answering Questions