TessaIO commented on code in PR #17360: URL: https://github.com/apache/druid/pull/17360#discussion_r2042649936
########## server/src/main/java/org/apache/druid/server/metrics/GroupByStatsMonitor.java: ########## @@ -0,0 +1,77 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package org.apache.druid.server.metrics; + +import com.google.inject.Inject; +import org.apache.druid.collections.BlockingPool; +import org.apache.druid.guice.annotations.Merging; +import org.apache.druid.java.util.emitter.service.ServiceEmitter; +import org.apache.druid.java.util.emitter.service.ServiceMetricEvent; +import org.apache.druid.java.util.metrics.AbstractMonitor; +import org.apache.druid.query.groupby.GroupByStatsProvider; + +import java.nio.ByteBuffer; + +public class GroupByStatsMonitor extends AbstractMonitor +{ + private final GroupByStatsProvider groupByStatsProvider; + private final BlockingPool<ByteBuffer> mergeBufferPool; + + @Inject + public GroupByStatsMonitor( + GroupByStatsProvider groupByStatsProvider, + @Merging BlockingPool<ByteBuffer> mergeBufferPool + ) + { + this.groupByStatsProvider = groupByStatsProvider; + this.mergeBufferPool = mergeBufferPool; + } + + @Override + public boolean doMonitor(ServiceEmitter emitter) + { + final ServiceMetricEvent.Builder builder = new ServiceMetricEvent.Builder(); + + emitter.emit(builder.setMetric("mergeBuffer/pendingRequests", mergeBufferPool.getPendingRequests())); + + emitter.emit(builder.setMetric("mergeBuffer/used", mergeBufferPool.getUsedResourcesCount())); Review Comment: @LakshSingla @findingrish Is there a reason why this metric isn’t included in the per-query stats? I think it would be helpful to report it for each query individually. Right now, the emission of this metric depends on the emission interval. For example, if the interval is 1 minute and a query runs in the middle of that cycle—using and then freeing the merge buffers before the minute ends—we won’t see that the buffers were ever used. So, we could miss important usage information simply because the timing doesn’t align with the metric emission. Please let me know if I’ve misunderstood how this works. -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected] --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
