Skip to content

fix(eap): Map virtual context columns properly for topn queries #90343

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

Merged

Conversation

shruthilayaj
Copy link
Member

Chart is empty for device.class top n queries.
This is because virtual context columns are currently not supported on timeseries.
So we need to map it back to original column and values and back for topn

example

@github-actions github-actions bot added the Scope: Backend Automatically applied to PRs that change backend components label Apr 24, 2025
@@ -2568,6 +2568,32 @@ def test_device_class_filter_unknown(self):
assert data[0]["device.class"] == "Unknown"
assert meta["dataset"] == self.dataset

def test_device_class_column(self):
Copy link
Member Author

Choose a reason for hiding this comment

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

extra test to make sure i didn't break events/

@shruthilayaj shruthilayaj marked this pull request as ready for review April 24, 2025 21:44
@shruthilayaj shruthilayaj requested a review from a team as a code owner April 24, 2025 21:44
Copy link

codecov bot commented Apr 25, 2025

Codecov Report

Attention: Patch coverage is 98.27586% with 1 line in your changes missing coverage. Please review.

✅ All tests successful. No failed tests found.

Files with missing lines Patch % Lines
src/sentry/search/eap/resolver.py 87.50% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master   #90343      +/-   ##
==========================================
+ Coverage   87.81%   87.82%   +0.01%     
==========================================
  Files       10275    10258      -17     
  Lines      579435   579206     -229     
  Branches    22645    22618      -27     
==========================================
- Hits       508831   508712     -119     
+ Misses      70176    70050     -126     
- Partials      428      444      +16     

) -> tuple[ResolvedAttribute, str | int | list[str]]:
"""
Time series request do not support virtual column contexts, so we have to remap the value back to the original column.
(see https://github.com/getsentry/eap-planning/issues/236)
Copy link
Member

Choose a reason for hiding this comment

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

Not sure what the usual stance is on linking to private github issues in code.

Copy link
Member Author

Choose a reason for hiding this comment

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

Comment on lines +211 to +219
# Virtual context columns (VCCs) are currently only supported in TraceItemTable.
# For TopN queries, we want table and timeseries data to match.
# Here, we want to run the table request the the VCCs. SnubaParams has
# a property `is_timeseries_request` which resolves to true if granularity_secs is set.
# `is_timeseries_request` is used to evaluate if VCCs should be used.
# Unset granularity_secs, so this gets treated as a table request with
# the correct VCC.
table_query_params = params.copy()
table_query_params.granularity_secs = None
Copy link
Member

Choose a reason for hiding this comment

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

If this becomes a common pattern, we should look into a helper function on params that copies it and updates some fields.

Copy link
Member

Choose a reason for hiding this comment

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

Also, does this change the behaviour of the resolver? Is that why you need to have a different resolver for the table and timeseries?

Copy link
Member Author

Choose a reason for hiding this comment

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

yes - i tried to capture this in the comment:
SnubaParams has a property is_timeseries_request which resolves to true if granularity_secs is set and is_timeseries_request is used to evaluate if VCCs should be used. We want to keep this behaviour - otherwise VCCs aren't used and top events conditions end up being wrong.

@shruthilayaj shruthilayaj merged commit 270022c into master Apr 25, 2025
63 checks passed
@shruthilayaj shruthilayaj deleted the shruthi/fix/map-virtual-columns-properly-for-top-n-queries branch April 25, 2025 15:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Scope: Backend Automatically applied to PRs that change backend components
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants