Skip to content

Add sentry sample rate #10283

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

Open
wants to merge 4 commits into
base: main
Choose a base branch
from

Conversation

Vinnie-Singleton-NN
Copy link

@Vinnie-Singleton-NN Vinnie-Singleton-NN commented Apr 24, 2025

Add SENTRY_API_SAMPLE_RATE configuration option for Sentry SDK

Relevant issues

Pre-Submission checklist

Please complete all items before asking a LiteLLM maintainer to review your PR

  • I have Added testing in the tests/litellm/ directory, Adding at least 1 test is a hard requirement - see details
  • My PR passes all unit tests on (make test-unit)[https://docs.litellm.ai/docs/extras/contributing_code]
  • My PR's scope is as isolated as possible, it only solves 1 specific problem

Type

🆕 New Feature

Changes

This PR adds support for configuring the Sentry SDK sample rate in LiteLLM through the SENTRY_API_SAMPLE_RATE environment variable. The sample rate controls what percentage of errors are sent to Sentry, allowing users to limit the volume of error reports while still getting valuable insights.

Implementation details:

  • Added configuration of sample_rate parameter when initializing Sentry SDK
  • Set default sample rate to 1.0 (100% of errors) if not specified
  • Allow customization through the SENTRY_API_SAMPLE_RATE environment variable
  • Added unit tests to verify the functionality

According to Sentry's documentation, the sample rate is a static rate between 0 and 1 that applies equally to all errors:

  • A value of 1.0 sends 100% of errors to Sentry (default)
  • A value of 0.5 sends 50% of errors
  • A value of 0.1 sends 10% of errors

This is particularly useful for high-volume applications where sending every error to Sentry might not be necessary or could become cost-prohibitive.

Copy link

vercel bot commented Apr 24, 2025

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
litellm ✅ Ready (Inspect) Visit Preview 💬 Add feedback Apr 29, 2025 6:32pm

@CLAassistant
Copy link

CLA assistant check
Thank you for your submission! We really appreciate it. Like many open source projects, we ask that you sign our Contributor License Agreement before we can accept your contribution.


Vinnie seems not to be a GitHub user. You need a GitHub account to be able to sign the CLA. If you have already a GitHub account, please add the email address used for this commit to your account.
You have signed the CLA already but the status is still pending? Let us recheck it.

Copy link
Contributor

@ishaan-jaff ishaan-jaff left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Vinnie-Singleton-NN
Copy link
Author

@ishaan-jaff I have updated both of those files per your instructions. I also included information on the already existing trace rate which was not in those docs originally.

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

Successfully merging this pull request may close these issues.

3 participants