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

fix(profiles): Rate limit profiles when transaction was sampled #4195

Merged
merged 7 commits into from
Dec 6, 2024

Conversation

jjbayer
Copy link
Member

@jjbayer jjbayer commented Oct 30, 2024

fixes: #4280

@jjbayer jjbayer self-assigned this Nov 8, 2024
@jjbayer jjbayer removed their assignment Nov 22, 2024
@jjbayer jjbayer force-pushed the fix/profiles-rate-limit-wo-txn branch from f296745 to ff52ec6 Compare December 3, 2024 15:18
if profile_limits.is_empty() && summary.event_category.is_none() {
profile_limits = self
.check
.apply(scoping.item(DataCategory::Transaction), 0)?;
Copy link
Member Author

Choose a reason for hiding this comment

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

We don't need to check for TransactionIndexed here, because indexed transactions will trigger the if let Some(category) = summary.event_category { branch above.

Copy link
Member

Choose a reason for hiding this comment

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

I think you're correct that we don't have to check indexed here, but for the wrong reason.

It won't trigger the branch, because here we never have an event_category. But we don't have to check the indexed payload because I assume we don't want to enforce the indexed profile quota on profiles.

But this really is awkward and tricky, because ideally we should persist the information that we dropped indexed transactions on the profile (so it is treated like dynamic sampling), because then the profiling consumers later know that there won't be any transactions for the profiles (like it would be the case if the transaction is dynamically sampled).

As a side note, god damn I hate this function.

Copy link
Member Author

Choose a reason for hiding this comment

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

It won't trigger the branch, because here we never have an event_category.

Let's break it down:

  1. If the dynamic sampling decision was "keep" and there is a limit on either transaction or transaction_indexed, the profile is already dropped here.
  2. If the dynamic sampling decision was "drop" and there is a limit on transaction, the new code drops the profile.
  3. If the dynamic sampling decision was "drop" and there is a limit on transaction_indexed, we are in undefined territory. I want to err on the side of not enforcing transaction_indexed on profiles, but it is awkward like you said, because in the "keep" case we would drop the profile.

As a side note, god damn I hate this function.

Yes.

@jjbayer jjbayer marked this pull request as ready for review December 3, 2024 15:54
@jjbayer jjbayer requested a review from a team as a code owner December 3, 2024 15:54
Copy link
Member

@Dav1dde Dav1dde left a comment

Choose a reason for hiding this comment

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

Bonus: Add an integration test with for indexed/non-indexed transaction quota and sending a standalone profile.

if profile_limits.is_empty() && summary.event_category.is_none() {
profile_limits = self
.check
.apply(scoping.item(DataCategory::Transaction), 0)?;
Copy link
Member

Choose a reason for hiding this comment

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

I think you're correct that we don't have to check indexed here, but for the wrong reason.

It won't trigger the branch, because here we never have an event_category. But we don't have to check the indexed payload because I assume we don't want to enforce the indexed profile quota on profiles.

But this really is awkward and tricky, because ideally we should persist the information that we dropped indexed transactions on the profile (so it is treated like dynamic sampling), because then the profiling consumers later know that there won't be any transactions for the profiles (like it would be the case if the transaction is dynamically sampled).

As a side note, god damn I hate this function.

@jjbayer jjbayer merged commit f9a903a into master Dec 6, 2024
23 checks passed
@jjbayer jjbayer deleted the fix/profiles-rate-limit-wo-txn branch December 6, 2024 07:41
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.

Rate limit profiles when transaction was sampled
2 participants