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

Allow configuring sample rates via environment variables #1098

Open
1 task done
Santiagopenenory opened this issue Dec 5, 2024 · 0 comments
Open
1 task done

Allow configuring sample rates via environment variables #1098

Santiagopenenory opened this issue Dec 5, 2024 · 0 comments
Labels
enhancement New feature or request

Comments

@Santiagopenenory
Copy link

Welcome!

  • Yes, I have searched for similar requests on GitHub and found none.

What type of feature?

Integration

What is the motivation for the request?

This feature request aims to make the sample rates (tracesSampleRate and profilesSampleRate) for Sentry configurable through environment variables. This allows users to adjust the sample rates depending on their environment (e.g., development, production) without changing the code.
Currently, the sample rates are set to fixed values (1.0), which limits the flexibility to adjust these values per environment. Allowing them to be configured through environment variables would give developers better control over the Sentry configuration based on their deployment settings.

Usage Examples

In development, you might want a higher sample rate (e.g., 1.0), while in production, a lower sample rate (e.g., 0.1) may be appropriate.

How should the feature be developed?

  • Add new environment variables SENTRY_TRACES_SAMPLE_RATE and SENTRY_PROFILES_SAMPLE_RATE in the .env file.
  • Use parseFloat() to retrieve these values and set default values in case they are not defined.
  • Update the Sentry initialization to use these environment variables for sample rates.

Example code:

Sentry.init({
  dsn: dsn,
  environment: process.env.NODE_ENV || 'development',
  tracesSampleRate: parseFloat(process.env.SENTRY_TRACES_SAMPLE_RATE || '1.0'),
  profilesSampleRate: parseFloat(process.env.SENTRY_PROFILES_SAMPLE_RATE || '1.0'),
});

Additional Notes

By implementing this feature, developers can easily manage Sentry configuration based on the environment, offering better flexibility and control over performance monitoring.

@Santiagopenenory Santiagopenenory added the enhancement New feature or request label Dec 5, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant