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

Add some multi-stage metrics #12982

Merged
merged 4 commits into from
Apr 25, 2024

Conversation

gortiz
Copy link
Contributor

@gortiz gortiz commented Apr 22, 2024

This PR adds two new metrics:

  • MULTI_STAGE_QUERIES_EXECUTED, the total number of multi-stage queries executed.
  • MULTI_STAGE_QUERIES_BY_TABLE, how many multi-stage queries have been executed per table.

Given a single multi-stage query may touch more than one table, sum(MULTI_STAGE_QUERIES_BY_TABLE) >= MULTI_STAGE_QUERIES_EXECUTED.

Originally this commit included the following changes, but I decided to rollback them to reduce the discussion and merge it sooner.

Including:

  • Report BROKER_RESPONSES_WITH_NUM_GROUPS_LIMIT_REACHED
  • Report QUERY_TOTAL_TIME_MS
  • Report QUERY_QUOTA_EXCEEDED
  • Report REQUEST_DROPPED_DUE_TO_ACCESS_ERROR
  • Report QUERIES
  • Report REQUEST_SIZE
  • Add and report new MULTI_STAGE_QUERIES_BY_TABLE

Some javadocs have been added to notice that some of these metrics can now be counted now more than once (ie BROKER_RESPONSES_WITH_NUM_GROUPS_LIMIT_REACHED is added for each table touched in the query in case of joins)

This PR also changes a log. Specifically, the sentence that logs that a query has started is changed from debug to info. It is very useful to have a log when the query starts and one when it ends (the later already existed). This is specially useful to detect queries that for whatever reason do not end (like producing a large GC that ends up killing the broker).

Including:
- Report BROKER_RESPONSES_WITH_NUM_GROUPS_LIMIT_REACHED
- Report QUERY_TOTAL_TIME_MS
- Report QUERY_QUOTA_EXCEEDED
- Report REQUEST_DROPPED_DUE_TO_ACCESS_ERROR
- Report QUERIES
- Report REQUEST_SIZE
- Add and report new MULTI_STAGE_QUERIES_BY_TABLE

Some javadocs have been added to notice that some of these metrics can now be counted now more than once (ie BROKER_RESPONSES_WITH_NUM_GROUPS_LIMIT_REACHED is added for each table touched in the query in case of joins)
Comment on lines 283 to 285
for (String tableName : tableNames) {
_brokerMetrics.addMeteredTableValue(tableName, BrokerMeter.BROKER_RESPONSES_WITH_NUM_GROUPS_LIMIT_REACHED, 1);
}
Copy link
Contributor

Choose a reason for hiding this comment

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

We were planning to do something similar before and had some reservations around this. More info on this thread -- #11023 (comment)
cc @ankitsultana

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I think it is better to have false positives (aka report the problem at least once) than false negatives (aka report it at most once), but given there is no consensus, I'm going to remove it.

@codecov-commenter
Copy link

codecov-commenter commented Apr 22, 2024

Codecov Report

Attention: Patch coverage is 33.33333% with 4 lines in your changes are missing coverage. Please review.

Project coverage is 62.16%. Comparing base (59551e4) to head (9de14ba).
Report is 364 commits behind head on master.

Files Patch % Lines
...requesthandler/MultiStageBrokerRequestHandler.java 0.00% 4 Missing ⚠️
Additional details and impacted files
@@             Coverage Diff              @@
##             master   #12982      +/-   ##
============================================
+ Coverage     61.75%   62.16%   +0.41%     
+ Complexity      207      198       -9     
============================================
  Files          2436     2502      +66     
  Lines        133233   136592    +3359     
  Branches      20636    21146     +510     
============================================
+ Hits          82274    84911    +2637     
- Misses        44911    45409     +498     
- Partials       6048     6272     +224     
Flag Coverage Δ
custom-integration1 <0.01% <0.00%> (-0.01%) ⬇️
integration <0.01% <0.00%> (-0.01%) ⬇️
integration1 <0.01% <0.00%> (-0.01%) ⬇️
integration2 0.00% <0.00%> (ø)
java-11 62.13% <33.33%> (+0.42%) ⬆️
java-21 62.05% <33.33%> (+0.42%) ⬆️
skip-bytebuffers-false 62.14% <33.33%> (+0.40%) ⬆️
skip-bytebuffers-true 62.01% <33.33%> (+34.29%) ⬆️
temurin 62.16% <33.33%> (+0.41%) ⬆️
unittests 62.15% <33.33%> (+0.41%) ⬆️
unittests1 46.71% <100.00%> (-0.18%) ⬇️
unittests2 27.94% <0.00%> (+0.21%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@gortiz
Copy link
Contributor Author

gortiz commented Apr 22, 2024

I've simplified the PR and modified the title and description of the PR.

@Jackie-Jiang Jackie-Jiang added metrics observability multi-stage Related to the multi-stage query engine labels Apr 22, 2024
* Unlike {@link #MULTI_STAGE_QUERIES_BY_TABLE}, this metric is global and not attached to a particular table.
* That means it can be used to know how many multi-stage queries have been started in total.
*/
MULTI_STAGE_QUERIES_EXECUTED("queries", true),
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggest renaming them to MULTI_STAGE_QUERIES_GLOBAL and MULTI_STAGE_QUERIES

Copy link
Contributor

Choose a reason for hiding this comment

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

Also way may put them next to QUERIES

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Also way may put them next to QUERIES

In general I try to avoid to change the order of literals to make sure backward compatibility is not broken, but I think in this case it is fine to do it.

Changing it...

@Jackie-Jiang Jackie-Jiang merged commit 2fb30c0 into apache:master Apr 25, 2024
20 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
metrics multi-stage Related to the multi-stage query engine observability
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants