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

feat(apis): Pass query source to snuba - phase 2 #73497

Merged
merged 3 commits into from
Aug 1, 2024

Conversation

sentaur-athena
Copy link
Member

Continuing #73176 to pass query source to snuba for more debuggability.

OrganizationSpansSamplesEndpoint
OrganizationsEventsMetaEndpoint
OrganizationsEventsStatsEndpoint

@sentaur-athena sentaur-athena requested review from volokluev, Zylphrex and a team June 28, 2024 09:51
@sentaur-athena sentaur-athena requested review from a team as code owners June 28, 2024 09:51
@github-actions github-actions bot added the Scope: Backend Automatically applied to PRs that change backend components label Jun 28, 2024
Copy link

codecov bot commented Jun 28, 2024

Codecov Report

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

Project coverage is 78.19%. Comparing base (f2ed2e3) to head (2d98c28).
Report is 14 commits behind head on master.

Files Patch % Lines
src/sentry/snuba/spans_metrics.py 83.33% 1 Missing ⚠️
Additional details and impacted files
@@           Coverage Diff           @@
##           master   #73497   +/-   ##
=======================================
  Coverage   78.19%   78.19%           
=======================================
  Files        6790     6790           
  Lines      302551   302602   +51     
  Branches    52057    52062    +5     
=======================================
+ Hits       236585   236627   +42     
- Misses      59581    59588    +7     
- Partials     6385     6387    +2     
Files Coverage Δ
...c/sentry/api/endpoints/organization_events_meta.py 73.58% <100.00%> (+0.76%) ⬆️
.../sentry/api/endpoints/organization_events_stats.py 90.00% <100.00%> (+0.41%) ⬆️
src/sentry/integrations/slack/unfurl/discover.py 81.33% <100.00%> (+0.25%) ⬆️
src/sentry/search/events/builder/base.py 91.80% <100.00%> (+0.01%) ⬆️
src/sentry/search/events/builder/metrics.py 88.62% <100.00%> (ø)
src/sentry/snuba/discover.py 76.06% <100.00%> (+0.04%) ⬆️
src/sentry/snuba/errors.py 74.19% <100.00%> (+0.28%) ⬆️
src/sentry/snuba/functions.py 82.85% <100.00%> (+0.24%) ⬆️
src/sentry/snuba/issue_platform.py 62.74% <100.00%> (+0.74%) ⬆️
src/sentry/snuba/metrics_enhanced_performance.py 72.52% <100.00%> (+0.30%) ⬆️
... and 7 more

... and 10 files with indirect coverage changes

Copy link
Member

@Zylphrex Zylphrex left a comment

Choose a reason for hiding this comment

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

Mostly looks good to me, though it would be ideal if the logic to detect if the query source can be collected in 1 place instead of having some endpoints override it with some custom logic.

Comment on lines +44 to +47
# TODO: @athena - add query_source when all datasets support it
# query_source=(
# QuerySource.FRONTEND if is_frontend_request(request) else QuerySource.API
# ),
Copy link
Member

Choose a reason for hiding this comment

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

Did you mean to leave this commented out?

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, not all datasets currently expect query_source as a param and they're not typed to safely take care of that. So I'll uncomment it after my last PR.

Comment on lines +218 to +223
if referrer in SENTRY_BACKEND_REFERRERS:
query_source = QuerySource.SENTRY_BACKEND
Copy link
Member

Choose a reason for hiding this comment

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

Can this logic be moved into is_frontend_request? Also, is there no other way to verify that the request came from the backend by inspecting the request like the authentication method?

Copy link
Member Author

Choose a reason for hiding this comment

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

is_frontend_request is using authentication but really no matter how we implement it a customer's direct api call can look like a frontend request so this is just a good estimate.

I don't think it's a good idea to move this to is_frontend_request because that's really independent of Snuba. Let me create a method in Endpoint or a util 🤔

@getsantry
Copy link
Contributor

getsantry bot commented Jul 27, 2024

This pull request has gone three weeks without activity. In another week, I will close it.

But! If you comment or otherwise update it, I will reset the clock, and if you add the label WIP, I will leave it alone unless WIP is removed ... forever!


"A weed is but an unloved flower." ― Ella Wheeler Wilcox 🥀

@getsantry getsantry bot added the Stale label Jul 27, 2024
@sentaur-athena sentaur-athena merged commit 8732d8c into master Aug 1, 2024
50 checks passed
@sentaur-athena sentaur-athena deleted the athena/snuba-query-source branch August 1, 2024 15:57
sentaur-athena added a commit that referenced this pull request Aug 15, 2024
Continuing #73497 to pass query
source to snuba for more debuggability.

OrganizationEventsTraceBaseEndpoint
OrganizationsEventsNewTrendsStatsEndpoint
OrganizationsEventsEndpoint
@github-actions github-actions bot locked and limited conversation to collaborators Aug 17, 2024
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 Stale
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants