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
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -170,6 +170,12 @@ protected BrokerResponse handleRequest(long requestId, String query, @Nullable S

DispatchableSubPlan dispatchableSubPlan = queryPlanResult.getQueryPlan();
Set<String> tableNames = queryPlanResult.getTableNames();

_brokerMetrics.addMeteredGlobalValue(BrokerMeter.MULTI_STAGE_QUERIES_EXECUTED, 1);
for (String tableName : tableNames) {
_brokerMetrics.addMeteredTableValue(tableName, BrokerMeter.MULTI_STAGE_QUERIES_BY_TABLE, 1);
}

requestContext.setTableNames(List.copyOf(tableNames));

// Compilation Time. This includes the time taken for parsing, compiling, create stage plans and assigning workers.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,11 @@ public enum BrokerMeter implements AbstractMetrics.Meter {
UNCAUGHT_POST_EXCEPTIONS("exceptions", true),
HEALTHCHECK_BAD_CALLS("healthcheck", true),
HEALTHCHECK_OK_CALLS("healthcheck", true),
/**
* Number of queries executed.
* <p>
* At this moment this counter does not include queries executed in multi-stage mode.
*/
QUERIES("queries", false),

// These metrics track the exceptions caught during query execution in broker side.
Expand Down Expand Up @@ -85,7 +90,7 @@ public enum BrokerMeter implements AbstractMetrics.Meter {
REQUEST_DROPPED_DUE_TO_ACCESS_ERROR("requestsDropped", false),

GROUP_BY_SIZE("queries", false),
TOTAL_SERVER_RESPONSE_SIZE("queries", false),
TOTAL_SERVER_RESPONSE_SIZE("bytes", false),

QUERY_QUOTA_EXCEEDED("exceptions", false),

Expand All @@ -102,7 +107,23 @@ public enum BrokerMeter implements AbstractMetrics.Meter {
NETTY_CONNECTION_BYTES_RECEIVED("nettyConnection", true),

PROACTIVE_CLUSTER_CHANGE_CHECK("proactiveClusterChangeCheck", true),
DIRECT_MEMORY_OOM("directMemoryOOMCount", true);
DIRECT_MEMORY_OOM("directMemoryOOMCount", true),


/**
* Number of multi-stage queries that have been started.
* <p>
* 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...

/**
* Number of multi-stage queries that have been started touched a given table.
* <p>
* In case the query touch multiple tables (ie using joins)1, this metric will be incremented for each table, so the
* sum of this metric across all tables should be greater or equal than {@link #MULTI_STAGE_QUERIES_EXECUTED}.
*/
MULTI_STAGE_QUERIES_BY_TABLE("queries", false);

private final String _brokerMeterName;
private final String _unit;
Expand Down
Loading