Skip to content

Conversation

@yuvmen
Copy link
Member

@yuvmen yuvmen commented Jun 3, 2025

Added the ability to receive a client sampling rate on error events through the contexts field. This gets parsed and placed on the event as ["data"]["sample_rate"] as part of processing before saving the event. Only enabled for specific projects, defined via a new option.

Added the ability to receive a client sampling rate on error events through the `contexts` field. This gets parsed
and placed on the event as ["data"]["sample_rate"] as part of processing before saving the event.
Only enabled for specific projects, defined via a new option.
@yuvmen yuvmen requested a review from MichaelSun48 June 3, 2025 00:14
@yuvmen yuvmen requested a review from a team as a code owner June 3, 2025 00:14
@github-actions github-actions bot added the Scope: Backend Automatically applied to PRs that change backend components label Jun 3, 2025
@codecov
Copy link

codecov bot commented Jun 3, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Additional details and impacted files
@@             Coverage Diff             @@
##           master   #92703       +/-   ##
===========================================
+ Coverage   53.21%   87.90%   +34.68%     
===========================================
  Files       10244    10252        +8     
  Lines      587669   588316      +647     
  Branches    22831    22831               
===========================================
+ Hits       312753   517146   +204393     
+ Misses     274470    70724   -203746     
  Partials      446      446               

.get("error_sampling", {})
.get("client_sample_rate")
)
# Only set sample_rate if it's a valid number between 0 and 1
Copy link
Member

Choose a reason for hiding this comment

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

do we want to log or metric if its not valid?

Copy link
Member Author

Choose a reason for hiding this comment

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

yea that makes sense, I think ill add a metric been waiting for a chance to add one :)

def _derive_client_error_sampling_rate(jobs: Sequence[Job], projects: ProjectsMapping) -> None:
for job in jobs:
project = projects[job["project_id"]]
if project.id in options.get("issues.client_error_sampling.project_allowlist"):
Copy link
Member

Choose a reason for hiding this comment

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

Would you rather use a project feature flag?

Copy link
Member Author

Choose a reason for hiding this comment

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

discussed this with Matt, he actually suggested using an option because I dont need the granularity of a feature flag, its going to be for a specific single project.

Copy link
Member Author

Choose a reason for hiding this comment

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

I wonder about this since both of you seem to agree, what would the benefits be here of using a feature flag instead?

Copy link
Member

Choose a reason for hiding this comment

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

Feature flag allows you to pick projects, organizations, EA, etc

An option is a system-wide variable. You would have to opt in specific deployments (e.g. s4s), but I assume that the project only exists in one of our deployments.

Copy link
Member Author

Choose a reason for hiding this comment

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

yea we would basically start with creating a project in s4s to test it out and enabling only that, then enabling it only for the specific project we want to enable for the one customer (its only their backend project that is going to do error sampling). So yea I am not going to need the flexibility, I am ok with it being specific to regions... I think ill just go with it and change if I find a good reason

@yuvmen yuvmen merged commit f2ca7d6 into master Jun 4, 2025
61 checks passed
@yuvmen yuvmen deleted the yuvmen/handle-error-sample-rate-on-errors branch June 4, 2025 16:17
andrewshie-sentry pushed a commit that referenced this pull request Jun 4, 2025
Added the ability to receive a client sampling rate on error events through the `contexts` field. This gets parsed and
 placed on the event as `["data"]["sample_rate"]` as part of processing before saving the event. 
Only enabled for specific projects, defined via a new option.
@github-actions github-actions bot locked and limited conversation to collaborators Jun 20, 2025
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

Scope: Backend Automatically applied to PRs that change backend components

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants