aws / aws-xray-sdk-node

The official AWS X-Ray SDK for Node.js.
Apache License 2.0
272 stars 155 forks source link

Possibility to turn off X Ray #231

Open ivanmartos opened 4 years ago

ivanmartos commented 4 years ago

In Python XRay sdk it is possible to turn off XRay via environment variable AWS_XRAY_SDK_ENABLED (https://docs.aws.amazon.com/xray/latest/devguide/xray-sdk-python-configuration.html)

Would it be possible to add this feature also to node SDK? Thanks

awssandra commented 4 years ago

Hi ivanmartos,

We're been slowly filling in the gaps of feature parity between our SDKs. This is absolutely a great little feature we should implement on the Node SDK. We'll be happy to add this on our TODO list and prioritize it accordingly, but feel free to open a PR.

revmischa commented 4 years ago

I'm using serverless-offline to test my app locally and having xray blow it up is very inconvenient.

.../backend/node_modules/serverloffline: Failure: Missing AWS Lambda trace data for X-Ray. Expected _X_AMZN_TRACE_ID to be set.
[start:backend] ess-offline/dist/lambda/handler-runner/in-process-runner/InProcessRunner.js:199:24)
[start:backend]     at LambdaFunction.runHandler (/Users/cyber/dev/jb/jkv2-demo/ts-sls/packages/backend/node_modules/serverless-offline/dist/lambda/LambdaFunction.js:325:20)
[start:backend]     at hapiHandler (/Users/cyber/dev/jb/jkv2-demo/ts-sls/packages/backend/node_modules/serverless-offline/dist/events/http/HttpServer.js:521:18)
awssandra commented 4 years ago

@revmischa yes we've had several issues for various serverless packages in this regard.

You should be able to use the "AWS_XRAY_CONTEXT_MISSING" environment variable set to "LOG_ERROR" to merely log these missing context issues. https://github.com/aws/aws-xray-sdk-node/tree/master/packages/core#environment-variables

BlissfulDarkness commented 3 years ago

Considering that serverless seems like a core use case for XRay and that this request has been open for over a year, is there an expected ETA to support disabling the XRay SDK entirely for NodeJS? Logging errors is rather a nuisance when it's not actually an error for our application that it cannot send traces, which we don't care about when a dev is doing local testing unrelated to XRay.

mannharleen commented 3 years ago

Still unresolved in 2021?

srprash commented 3 years ago

Hi @mannharleen Apologies for the delay. We still have it on our backlog and would like to prioritize it as soon as possible. We will update this issue with any progress. Stay tuned. Thanks!

bordeux commented 3 years ago

Any updates on this ticket? It will be cool to turn off xray during unit testing. Right now it is not possible and i need to make wrapper for xray library to handle this .

willarmiros commented 3 years ago

Hi @bordeux,

We still have not been able to prioritize this feature unfortunately, but are always open to PRs.

Alternatively, we have released the AWS Distro for OpenTelemetry JavaScript as a generally available tracing instrumentation SDK with first class support for X-Ray. That SDK is highly configurable and can be put into a no-op mode where it does not emit trace data and consumes minimal system resources.

deanq commented 2 years ago

Still an issue in 2022? In Python, we're able to do this with env var AWS_XRAY_SDK_ENABLED=false

revmischa commented 2 years ago

Still an issue in 2022? In Python, we're able to do this with env var AWS_XRAY_SDK_ENABLED=false

I use this which takes care of it automatically https://awslabs.github.io/aws-lambda-powertools-typescript/latest/core/tracer/

rogerwelin commented 1 year ago

any progress? it's really poor developer experience not being able to turn it off during integration and unit tests

deanq commented 1 year ago

2023! @willarmiros ?

ryan-ju commented 8 months ago

2024?

matthewvcarey1 commented 2 weeks ago

This is a bit silly, the code tested is meant to be the same as the actual code used. And we cannot test it if it won't run.

deanq commented 2 weeks ago

We're moving to OpenTelemetry. That's one way to turn off X-Ray. I suggest everyone move to that future.