-
Notifications
You must be signed in to change notification settings - Fork 4
Support upsampled error count with performance optimizations #3
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
base: master
Are you sure you want to change the base?
Conversation
…(#94376) Part of the Error Upsampling project: https://www.notion.so/sentry/Tech-Spec-Error-Up-Sampling-1e58b10e4b5d80af855cf3b992f75894?source=copy_link Events-stats API will now check if all projects in the query are allowlisted for upsampling, and convert the count query to a sum over `sample_weight` in Snuba, this is done by defining a new SnQL function `upsampled_count()`. I noticed there are also eps() and epm() functions in use in this endpoint. I considered (and even worked on) also supporting swapping eps() and epm() which for correctness should probably also not count naively and use `sample_weight`, but this caused some complications and since they are only in use by specific dashboard widgets and not available in discover I decided to defer changing them until we realize it is needed.
- Add 60-second cache for upsampling eligibility checks to improve performance - Separate upsampling eligibility check from query transformation for better optimization - Remove unnecessary null checks in upsampled_count() function per schema requirements - Add cache invalidation utilities for configuration management This improves performance during high-traffic periods by avoiding repeated expensive allowlist lookups while maintaining data consistency.
PR Compliance Guide 🔍Below is a summary of compliance checks for this PR:
Compliance status legend🟢 - Fully Compliant🟡 - Partial Compliant 🔴 - Not Compliant ⚪ - Requires Further Human Verification 🏷️ - Compliance label |
||||||||||||||||||||||||
PR Code Suggestions ✨Explore these optional code suggestions:
|
|||||||||||
User description
PR #3
PR Type
Enhancement, Tests
Description
Implement error upsampling support in events-stats API with
upsampled_count()functionAdd 60-second caching for upsampling eligibility checks to optimize performance
Transform
count()aggregations to usesum(sample_weight)for allowlisted projectsAdd comprehensive test coverage for upsampling logic and edge cases
Extract sample_rate from error_sampling context in event factory
Diagram Walkthrough
File Walkthrough
organization_events_stats.py
Integrate upsampling eligibility checks and column transformationsrc/sentry/api/endpoints/organization_events_stats.py
query transformation
optimization
standard timeseries queries
final_columns) to all query execution pathserror_upsampling.py
Create error upsampling helper with caching and transformationssrc/sentry/api/helpers/error_upsampling.py
support
is_errors_query_for_error_upsampled_projects()with60-second cache for allowlist eligibility
_are_all_projects_error_upsampled()to validate all projects arein allowlist
transform_query_columns_for_error_upsampling()to convertcount()toupsampled_count()_should_apply_sample_weight_transform()to determine datasetapplicability
invalidate_upsampling_cache()utility for configurationmanagement
discover.py
Add upsampled_count SnQL function for error aggregationsrc/sentry/search/events/datasets/discover.py
upsampled_countSnQL function to function converter mappingtoInt64(sum(sample_weight))for upsamplederror counting
numberfor the new functionfactories.py
Extract sample_rate from error_sampling context in eventssrc/sentry/testutils/factories.py
MutableMappingto imports from collections.abc_set_sample_rate_from_error_sampling()helper function toextract client_sample_rate from error_sampling context
store_event()to populatesample_ratefield fromerror_sampling context data
test_error_upsampling.py
Add unit tests for error upsampling helper functionstests/sentry/api/helpers/test_error_upsampling.py
_are_all_projects_error_upsampled()with various allowlistscenarios
transform_query_columns_for_error_upsampling()with caseinsensitivity and whitespace handling
_is_error_focused_query()for error vs transaction detection_should_apply_sample_weight_transform()across different datasetstest_organization_events_stats.py
Add integration tests for error upsampling in events-statstests/snuba/api/endpoints/test_organization_events_stats.py
OrganizationEventsStatsErrorUpsamplingTesttest class withintegration tests
counts
pyproject.toml
Update mypy configuration for new modulespyproject.toml
sentry.api.helpers.error_upsamplingto mypy ignore listtests.sentry.api.helpers.test_error_upsamplingto mypy ignore listsentry-repo
Update subproject commit referencesentry-repo