Feature request: enable tracing only when running on AWS Lambda #147
Labels
completed
This item is complete and has been merged/shipped
feature-request
This item refers to a feature request for an existing or new utility
tracer
This item relates to the Tracer Utility
Milestone
Description of the feature request
Customers have raised a pain point around the
Tracer
utility throwing errors when when not running inside the Lambda execution environment. While both theTracer
and the underlyingaws-x-ray
packages provide ways to both change missing context strategy and disable tracing altogether, it would make sense to haveTracer
to be enabled by default only when running inside a Lambda function and disabled elsewhere instead of the current behaviour that sees the utility always being enabled by default unless explicitly disabled.Problem statement
Tracer
throws an error when trying to interact with a segment outside of a context and/or without the existence of a root segment (akafacade
). Customers have to explicitly disable theTracer
utility when running outside of Lambda (i.e. testing, CI, etc.) which can be cumbersome.Summary of the feature
tracing disabled
, change totracing enabled
).Tracer
is being initialised in a Lambda function or not which would check the existence of one betweenAWS_LAMBDA_FUNCTION_NAME
orAWS_EXECUTION_ENV
environment variables that are present by default in Lambda.Tracer.tracingDisabled
toTracer.tracingEnabled
.Tracer.tracingDisabled
to account for change.Code examples
POWERTOOLS_TRACE_DISABLED
, would change toPOWERTOOLS_TRACE_ENABLED
.const tracer: Tracer = new Tracer({ disabled: true });
, it would change toconst tracer: Tracer = new Tracer({ enabled: true });
Benefits for you and the wider AWS community
Better Developer Experience, less boilerplate code (-1 extra line) needed to instrument tests.
Describe alternatives you've considered
Clearer documentation around how to either disable tracing and/or changing X-Ray underlying SDK behaviour to ignore missing segments/context.
Additional context
Related issues, RFCs
#515
#572
The text was updated successfully, but these errors were encountered: