Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unable to Disable Logging by Setting samplingRate to Zero #1336

Closed
gunzip opened this issue May 29, 2024 · 3 comments · Fixed by #1337
Closed

Unable to Disable Logging by Setting samplingRate to Zero #1336

gunzip opened this issue May 29, 2024 · 3 comments · Fixed by #1337

Comments

@gunzip
Copy link

gunzip commented May 29, 2024

In certain scenarios, it is useful to completely suppress logging by setting the samplingRate to zero. However, the current code prevents this by taking the default value when samplingRate is set to zero, as shown in the following segment:

https://github.com/microsoft/ApplicationInsights-node.js/blob/main/src/shared/configuration/config.ts#L112

To address this, we need to modify the code to allow samplingRate to be set to zero without reverting to the default value. This change will provide greater flexibility in controlling logging behavior.

@JacksonWeber
Copy link
Contributor

@gunzip I agree that this should be possible. Looks like the current implementation contains an oversight regarding 0 being falsy. I'll update this and link the PR to this issue.

@JacksonWeber
Copy link
Contributor

@gunzip Working on getting a fix in at the moment. I am curious though what scenario you rely on this 0 sampling rate for. Is this for testing scenarios? Or some other use case?

@gunzip
Copy link
Author

gunzip commented Jun 6, 2024

Yes, exactly. I'm doing some tests to compute AI overhead at different levels of sampling. Moreover it's useful when you have a setup for staging slots, ie. using some sticky setting.

Consider also that the current README states:

Setting samplingPercentage to 100 (the default) means all data will be sent, and 0 means nothing will be sent.

When in reality you currently obtain a defaut to 100% sampling, which of course increase costs.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants