forked from apache/druid
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add metrics for Query Count statistics (apache#3470)
* Add metrics for Query Count statistics This PR adds a new metrics monitor “QueryCountStatsMonitor” which emits three new metrics - 1) query/success/count - number of successful queries 2) query/failed/count - number of failed queries 3) query/interrupted/count - number of interrupted/timedout queries fix bindings * make fields final * fix imports * AsyncQueryForwardingServlet implement QueryStatsProvider * remove unused import
- Loading branch information
1 parent
8eee259
commit 35160e5
Showing
12 changed files
with
180 additions
and
47 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
62 changes: 62 additions & 0 deletions
62
server/src/main/java/io/druid/server/metrics/QueryCountStatsMonitor.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
/* | ||
* Licensed to Metamarkets Group Inc. (Metamarkets) under one | ||
* or more contributor license agreements. See the NOTICE file | ||
* distributed with this work for additional information | ||
* regarding copyright ownership. Metamarkets 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 io.druid.server.metrics; | ||
|
||
import com.google.common.collect.ImmutableMap; | ||
import com.google.inject.Inject; | ||
import com.metamx.emitter.service.ServiceEmitter; | ||
import com.metamx.emitter.service.ServiceMetricEvent; | ||
import com.metamx.metrics.AbstractMonitor; | ||
import com.metamx.metrics.KeyedDiff; | ||
|
||
import java.util.Map; | ||
|
||
public class QueryCountStatsMonitor extends AbstractMonitor | ||
{ | ||
private final KeyedDiff keyedDiff = new KeyedDiff(); | ||
private final QueryCountStatsProvider statsProvider; | ||
|
||
@Inject | ||
public QueryCountStatsMonitor( | ||
QueryCountStatsProvider statsProvider | ||
) | ||
{ | ||
this.statsProvider = statsProvider; | ||
} | ||
|
||
@Override | ||
public boolean doMonitor(ServiceEmitter emitter) | ||
{ | ||
final ServiceMetricEvent.Builder builder = new ServiceMetricEvent.Builder(); | ||
Map<String, Long> diff = keyedDiff.to( | ||
"queryCountStats", | ||
ImmutableMap.of("query/success/count", statsProvider.getSuccessfulQueryCount(), | ||
"query/failed/count", statsProvider.getFailedQueryCount(), | ||
"query/interrupted/count", statsProvider.getInterruptedQueryCount() | ||
) | ||
); | ||
if (diff != null) { | ||
for (Map.Entry<String, Long> diffEntry : diff.entrySet()) { | ||
emitter.emit(builder.build(diffEntry.getKey(), diffEntry.getValue())); | ||
} | ||
} | ||
return true; | ||
} | ||
|
||
} |
28 changes: 28 additions & 0 deletions
28
server/src/main/java/io/druid/server/metrics/QueryCountStatsProvider.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
/* | ||
* Licensed to Metamarkets Group Inc. (Metamarkets) under one | ||
* or more contributor license agreements. See the NOTICE file | ||
* distributed with this work for additional information | ||
* regarding copyright ownership. Metamarkets 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 io.druid.server.metrics; | ||
|
||
public interface QueryCountStatsProvider | ||
{ | ||
public long getSuccessfulQueryCount(); | ||
|
||
public long getFailedQueryCount(); | ||
|
||
public long getInterruptedQueryCount(); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.