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 serverStats to BrokerQueryEventListener #14807

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

cypherean
Copy link
Contributor

@cypherean cypherean commented Jan 14, 2025

Adds server stats to BrokerQueryEventListener, which are published on query completion.

Tested locally:

image

@@ -145,6 +146,21 @@ public String getServerStats() {
return stringBuilder.toString();
}

@Override
public Map<String, Map<String, Integer>> getServerStatsMap() {
Copy link
Contributor

Choose a reason for hiding this comment

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

can you add UTs for this?

public Map<String, Map<String, Integer>> getServerStatsMap() {
return _responseMap.entrySet().stream()
.collect(Collectors.toMap(
entry -> entry.getKey().getShortName(),
Copy link
Contributor

Choose a reason for hiding this comment

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

The key here is the host right? is there a way to make it more explicit? Maybe instead of using Map<String, Map<String, Integer>> we can use Map<String, ServerStatsInfo> something and use POJO to easily extract the metric values.

@codecov-commenter
Copy link

codecov-commenter commented Jan 14, 2025

Codecov Report

Attention: Patch coverage is 45.16129% with 17 lines in your changes missing coverage. Please review.

Project coverage is 63.82%. Comparing base (59551e4) to head (037b726).
Report is 1581 commits behind head on master.

Files with missing lines Patch % Lines
...pache/pinot/core/transport/AsyncQueryResponse.java 0.00% 9 Missing ⚠️
.../apache/pinot/spi/trace/DefaultRequestContext.java 0.00% 4 Missing ⚠️
...sthandler/BaseSingleStageBrokerRequestHandler.java 40.00% 2 Missing and 1 partial ⚠️
...thandler/SingleConnectionBrokerRequestHandler.java 0.00% 1 Missing ⚠️
Additional details and impacted files
@@             Coverage Diff              @@
##             master   #14807      +/-   ##
============================================
+ Coverage     61.75%   63.82%   +2.06%     
- Complexity      207     1604    +1397     
============================================
  Files          2436     2708     +272     
  Lines        133233   151128   +17895     
  Branches      20636    23322    +2686     
============================================
+ Hits          82274    96452   +14178     
- Misses        44911    47454    +2543     
- Partials       6048     7222    +1174     
Flag Coverage Δ
custom-integration1 ?
integration ?
integration1 ?
integration2 ?
java-11 63.76% <45.16%> (+2.05%) ⬆️
java-21 63.69% <45.16%> (+2.07%) ⬆️
skip-bytebuffers-false 63.81% <45.16%> (+2.06%) ⬆️
skip-bytebuffers-true 63.64% <45.16%> (+35.91%) ⬆️
temurin 63.82% <45.16%> (+2.06%) ⬆️
unittests 63.82% <45.16%> (+2.07%) ⬆️
unittests1 56.37% <48.00%> (+9.48%) ⬆️
unittests2 34.09% <6.45%> (+6.36%) ⬆️

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.

@cypherean cypherean force-pushed the shreyaa/serverstats branch from 1eadda0 to 037b726 Compare January 14, 2025 14:28
package org.apache.pinot.spi.trace;

public class ServerStatsInfo {
private final long _submitRequestTimeMs;
Copy link
Contributor

Choose a reason for hiding this comment

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

format (2 spaces)


@Override
public void setServerStatsMap(Map<String, ServerStatsInfo> serverStatsMap) {
_serverStatsMap.putAll(serverStatsMap);
Copy link
Contributor

Choose a reason for hiding this comment

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

this is counter-intuitive. Instead of set you can do addToServerStatsMap?

* specific language governing permissions and limitations
* under the License.
*/
package org.apache.pinot.spi.trace;
Copy link
Contributor

Choose a reason for hiding this comment

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

If we are putting this in the SPI we have to take care of a few things.

  1. A Public ctor with AllArgs is not going to be tenable, since in the future we may want to add more properties to this. Suggest using NoArgs ctor with setters that return this, or builder pattern. We can also check what convention Pinot uses right now.
  2. We should define precisely each of the fields here. You can add a javadoc for each field member var.
  3. Could we get rid of redundancies like ServerStats in SingleConnectionBrokerRequestHandler? If this is in the SPI would make sense to make this the broadly used class for handling this info.

_deserializationTimeMs = deserializationTimeMs;
}

public long getSubmitRequestTimeMs() {
Copy link
Contributor

@ankitsultana ankitsultana Jan 14, 2025

Choose a reason for hiding this comment

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

MSE also tracks a bunch of server/stage level stats albeit in a different form. I think we should extend this so it can accept Multistage Query stats too. (I meant that we incorporate it somehow.. not necessarily through the same POJO)

cc: @gortiz who worked on adding MultiStageQueryStats.

Copy link
Contributor

Choose a reason for hiding this comment

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

That would be great, but unless I'm wrong, all these trace options only support SSE. It is unclear to me how this is being used, and AFAIK StarTree doesn't use this API. RequestContext itself seems to be SSE focused given it assumes a single table is involved in the query.

@gortiz
Copy link
Contributor

gortiz commented Jan 15, 2025

I don't have enough context. What is BrokerQueryEventListener used for?

@siddharthteotia
Copy link
Contributor

We use this within LinkedIn. Essentially our internal piece of code (which links with OSS libraries) publishes metrics to a kafka topic (at a query level with sampling).

We get the stats for the completed request from RequestContext and then emit into the topic AFAIK.

Before we introduce ServerStatsInfo, can we please take a look at existing classes ServerRoutingStatsEntry and ServerRoutingStatsManager and try to remove duplicate code / make things more consistent.

Also, I am not sure why does this need to go into SPI

@cypherean
Copy link
Contributor Author

@siddharthteotia this was added in pinot-spi so that it can be re-used in processing events from event listener. ServerRoutingStatsEntry and ServerRoutingStatsManager track running server level stats but what we need are server stats for a query.

@ankitsultana
Copy link
Contributor

I think it might make sense for us to share a short proposal. @cypherean and I will get back soon.

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.

6 participants