I am using the aws_xray_sdk
library to capture trace IDs, which I then save in a database.
Here's the implementation that works well:
from aws_xray_sdk.core import lambda_launcher,
lambda_context = lambda_launcher.check_in_lambda()
trace_id = lambda_context.get_trace_entity().trace_id if lambda_context else None
I have no other functionality related to aws-xray-sdk, besides this implementation.
I'm able to successfully capture trace IDs and store them in the database. However, there's an issue where a few trace IDs saved in the database cannot be found in the AWS X-Ray console.
I expect that the trace IDs I capture using the aws_xray_sdk
library's lambda_launcher
method should be visible in the AWS X-Ray console. Although I can successfully capture and save these trace IDs in a database, I've noticed that a few trace IDs stored in the database cannot be located in the X-Ray console. I'm interested in learning if other developers have faced a similar situation and if there's any insight into why this might be happening. Additionally, I'm uncertain whether I need to configure the xray_recorder
explicitly for proper trace visibility in the AWS X-Ray console, as I'm already able to capture trace IDs and store them in the database with the implementation I already have.
I did not find a solution for this. But, I did however find a way to still find the trace-id by filtering through the logs insights panel in the Cloudwatch console.
fields @timestamp, @message, @logStream, @log| filter @message like "<trace-id>"| sort @timestamp asc
Please note that this query is meant to filter the logs based on the trace ID you are searching for.