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(prod-queries): Implement backend for prod queries #4398

Merged
merged 15 commits into from
Jun 29, 2023

Conversation

davidtsuk
Copy link
Contributor

@davidtsuk davidtsuk commented Jun 22, 2023

Frontend Changes
I revamped the UI a bit to take in SnQL queries with a dataset and show the most recent result. I plan to add support for result history in the future, but right now I'm just keeping it simple.

Backend Changes
I refactored the audit log decorator a bit so that I can use it for prod queries. I also added an api endpoint for snql queries. In terms of validation, I first validate the query by using a dry run and then validate the projects in the query.

Testing
I added several tests for the api to ensure that it works correctly and handles errors.

@codecov
Copy link

codecov bot commented Jun 22, 2023

Codecov Report

Patch coverage: 71.36% and project coverage change: -0.10 ⚠️

Comparison is base (d5c494a) 90.34% compared to head (83faab2) 90.25%.

❗ Current head 83faab2 differs from pull request most recent head 4a785de. Consider uploading reports for the commit 4a785de to get more accurate results

Additional details and impacted files
@@            Coverage Diff             @@
##           master    #4398      +/-   ##
==========================================
- Coverage   90.34%   90.25%   -0.10%     
==========================================
  Files         803      805       +2     
  Lines       39512    39699     +187     
  Branches      245      255      +10     
==========================================
+ Hits        35698    35831     +133     
- Misses       3782     3834      +52     
- Partials       32       34       +2     
Impacted Files Coverage Δ
snuba/admin/static/api_client.tsx 2.03% <0.00%> (-0.11%) ⬇️
snuba/consumers/consumer_builder.py 65.11% <ø> (ø)
snuba/admin/static/production_queries/index.tsx 8.00% <6.38%> (-52.00%) ⬇️
snuba/consumers/strategy_factory.py 82.14% <50.00%> (-0.32%) ⬇️
snuba/state/explain_meta.py 81.08% <81.08%> (ø)
snuba/admin/production_queries/prod_queries.py 94.11% <94.11%> (ø)
snuba/admin/audit_log/query.py 100.00% <100.00%> (ø)
...admin/cardinality_analyzer/cardinality_analyzer.py 68.18% <100.00%> (ø)
snuba/admin/clickhouse/querylog.py 100.00% <100.00%> (ø)
snuba/admin/static/production_queries/styles.tsx 100.00% <100.00%> (ø)
... and 11 more

... and 4 files with indirect coverage changes

☔ View full report in Codecov by Sentry.
📢 Do you have feedback about the report comment? Let us know in this issue.

@davidtsuk davidtsuk marked this pull request as ready for review June 27, 2023 19:54
@davidtsuk davidtsuk requested a review from a team as a code owner June 27, 2023 19:54
return Promise.resolve(res.json());
} else {
return res.json().then((err) => {
let errMsg = err?.error.message || "Could not convert SnQL";
Copy link
Member

Choose a reason for hiding this comment

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

"Could not convert SnQL" is probably not the right error message.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

lol good catch

@davidtsuk davidtsuk merged commit d909998 into master Jun 29, 2023
21 checks passed
@davidtsuk davidtsuk deleted the david/feat/prod-query-api branch June 29, 2023 19:10
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.

2 participants