22
22
import org .elasticsearch .common .metrics .CounterMetric ;
23
23
import org .elasticsearch .common .metrics .MeanMetric ;
24
24
25
+ import java .util .concurrent .atomic .AtomicLong ;
26
+
25
27
/**
26
28
* <p>Metrics to measure ingest actions.
27
29
* <p>This counts measure documents and timings for a given scope.
@@ -39,7 +41,7 @@ class IngestMetric {
39
41
* The current count of things being measure. Should most likely ever be 0 or 1.
40
42
* Useful when aggregating multiple metrics to see how many things are in flight.
41
43
*/
42
- private final CounterMetric ingestCurrent = new CounterMetric ();
44
+ private final AtomicLong ingestCurrent = new AtomicLong ();
43
45
/**
44
46
* The ever increasing count of things being measured
45
47
*/
@@ -53,15 +55,15 @@ class IngestMetric {
53
55
* Call this prior to the ingest action.
54
56
*/
55
57
void preIngest () {
56
- ingestCurrent .inc ();
58
+ ingestCurrent .incrementAndGet ();
57
59
}
58
60
59
61
/**
60
62
* Call this after the performing the ingest action, even if the action failed.
61
63
* @param ingestTimeInMillis The time it took to perform the action.
62
64
*/
63
65
void postIngest (long ingestTimeInMillis ) {
64
- ingestCurrent .dec ();
66
+ ingestCurrent .decrementAndGet ();
65
67
ingestTime .inc (ingestTimeInMillis );
66
68
ingestCount .inc ();
67
69
}
@@ -90,6 +92,6 @@ void add(IngestMetric metrics) {
90
92
* Creates a serializable representation for these metrics.
91
93
*/
92
94
IngestStats .Stats createStats () {
93
- return new IngestStats .Stats (ingestCount .count (), ingestTime .sum (), ingestCurrent .count (), ingestFailed .count ());
95
+ return new IngestStats .Stats (ingestCount .count (), ingestTime .sum (), ingestCurrent .get (), ingestFailed .count ());
94
96
}
95
97
}
0 commit comments