Closed
Description
Use case
I'd like a attribute in my logs to indicate whether or not a request has been sampled. Something like this:
{
"level": "ERROR",
"msg": "something went wrong",
"trace_id": "1-6419d889-20172e50462fac2c7c481454",
"trace_sampled": true
}
I can populate the trace_id
using Tracer#getRootXrayTraceId
, but there's no way to find out if the trace is sampled.
Solution/User Experience
A new isTraceSampled
method on the Tracer
class.
log({
level: "ERROR",
msg: "something went wrong",
trace_id: tracer.getRootXrayTraceId(),
trace_sampled: tracer.isTraceSampled(),
})
Alternative solutions
Implement my own isTraceSampled
function which parses the _X_AMZN_TRACE_ID
header value.
Acknowledgment
- This feature request meets Lambda Powertools Tenets
- Should this be considered in other Lambda Powertools languages? i.e. Python, Java, and .NET
Future readers
Please react with 👍 and your use case to help us understand customer demand.