Description
Description of the feature request
Problem statement
Amplify CLI offers a workflow that allows developers to invoke locally a Lambda function during development, this is done by running a command like amplify mock function <function_name> --event <path_to_event_json>
- source.
When not running inside the actual AWS Lambda execution environment the Tracer
should be disabled by default. This is needed because we cannot know if the X-Ray daemon is running, and in case it's not indeed running the aws-xray-sdk
for Node.js will throw an error.
We support this behaviour already for local invocations made with SAM CLI, as discussed here, but we don't support this with Amplify CLI.
Ideally, Tracer should be able to detect it's being invoked inside an Amplify-mocked environment and disable itself.
Summary of the feature
During initialisation of the Tracer
instance, check for the presence of an Amplify CLI-specific environment variable (like this one) and if present, disable tracing for said instance.
Code examples
This is the logic that checks for the presence of a SAM CLI-specific environment variable and disables the Tracer if present. The new feature should follow the same exact logic but for Amplify CLI.
Benefits for you and the wider AWS community
Being able to locally mock functions using Amplify CLI and without any code change.
Describe alternatives you've considered
Manually disabling Tracer via environment variable and/or not using Amplify CLI to mock functions that use the tracer.
Additional context
N/A
Related issues, RFCs
N/A