Skip to content

Feature request: Add isTraceSampled method to Tracer #1378

Closed
@icholy

Description

@icholy

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

Future readers

Please react with 👍 and your use case to help us understand customer demand.

Metadata

Metadata

Assignees

Labels

completedThis item is complete and has been merged/shippedfeature-requestThis item refers to a feature request for an existing or new utilitytracerThis item relates to the Tracer Utility

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions