23
23
*/
24
24
public final class SearchQueryCounters {
25
25
private static final String LEVEL_TAG = "level" ;
26
- private static final String TYPE_TAG = "type" ;
26
+ private static final String QUERY_TYPE_TAG = "type" ;
27
27
private static final String UNIT = "1" ;
28
+ private static final String UNIT_MILLIS = "ms" ;
29
+ private static final String UNIT_CPU_CYCLES = "ns" ;
30
+ private static final String UNIT_BYTES = "bytes" ;
31
+
28
32
private final MetricsRegistry metricsRegistry ;
29
33
/**
30
34
* Aggregation counter
@@ -83,17 +87,17 @@ public SearchQueryCounters(MetricsRegistry metricsRegistry) {
83
87
this .queryTypeLatencyHistogram = metricsRegistry .createHistogram (
84
88
"search.query.type.latency.histogram" ,
85
89
"Histogram for the latency per query type" ,
86
- UNIT
90
+ UNIT_MILLIS
87
91
);
88
92
this .queryTypeCpuHistogram = metricsRegistry .createHistogram (
89
93
"search.query.type.cpu.histogram" ,
90
94
"Histogram for the cpu per query type" ,
91
- UNIT
95
+ UNIT_CPU_CYCLES
92
96
);
93
97
this .queryTypeMemoryHistogram = metricsRegistry .createHistogram (
94
98
"search.query.type.memory.histogram" ,
95
99
"Histogram for the memory per query type" ,
96
- UNIT
100
+ UNIT_BYTES
97
101
);
98
102
this .queryHandlers = new HashMap <>();
99
103
}
@@ -109,7 +113,7 @@ public void incrementCounter(QueryBuilder queryBuilder, int level, Map<MetricTyp
109
113
110
114
Counter counter = nameToQueryTypeCounters .computeIfAbsent (uniqueQueryCounterName , k -> createQueryCounter (k ));
111
115
counter .add (1 , Tags .create ().addTag (LEVEL_TAG , level ));
112
- incrementAllHistograms (Tags .create ().addTag (LEVEL_TAG , level ).addTag (TYPE_TAG , uniqueQueryCounterName ), measurements );
116
+ incrementAllHistograms (Tags .create ().addTag (LEVEL_TAG , level ).addTag (QUERY_TYPE_TAG , uniqueQueryCounterName ), measurements );
113
117
}
114
118
115
119
/**
0 commit comments