mirror of
https://github.com/honeymoose/OpenSearch.git
synced 2025-03-09 14:34:43 +00:00
This commit is contained in:
parent
07ef8ccff4
commit
3ffd34617f
@ -22,6 +22,8 @@ package org.elasticsearch.ingest;
|
||||
import org.elasticsearch.common.metrics.CounterMetric;
|
||||
import org.elasticsearch.common.metrics.MeanMetric;
|
||||
|
||||
import java.util.concurrent.atomic.AtomicLong;
|
||||
|
||||
/**
|
||||
* <p>Metrics to measure ingest actions.
|
||||
* <p>This counts measure documents and timings for a given scope.
|
||||
@ -39,7 +41,7 @@ class IngestMetric {
|
||||
* The current count of things being measure. Should most likely ever be 0 or 1.
|
||||
* Useful when aggregating multiple metrics to see how many things are in flight.
|
||||
*/
|
||||
private final CounterMetric ingestCurrent = new CounterMetric();
|
||||
private final AtomicLong ingestCurrent = new AtomicLong();
|
||||
/**
|
||||
* The ever increasing count of things being measured
|
||||
*/
|
||||
@ -53,7 +55,7 @@ class IngestMetric {
|
||||
* Call this prior to the ingest action.
|
||||
*/
|
||||
void preIngest() {
|
||||
ingestCurrent.inc();
|
||||
ingestCurrent.incrementAndGet();
|
||||
}
|
||||
|
||||
/**
|
||||
@ -61,7 +63,7 @@ class IngestMetric {
|
||||
* @param ingestTimeInMillis The time it took to perform the action.
|
||||
*/
|
||||
void postIngest(long ingestTimeInMillis) {
|
||||
ingestCurrent.dec();
|
||||
ingestCurrent.decrementAndGet();
|
||||
ingestTime.inc(ingestTimeInMillis);
|
||||
ingestCount.inc();
|
||||
}
|
||||
@ -90,6 +92,6 @@ class IngestMetric {
|
||||
* Creates a serializable representation for these metrics.
|
||||
*/
|
||||
IngestStats.Stats createStats() {
|
||||
return new IngestStats.Stats(ingestCount.count(), ingestTime.sum(), ingestCurrent.count(), ingestFailed.count());
|
||||
return new IngestStats.Stats(ingestCount.count(), ingestTime.sum(), ingestCurrent.get(), ingestFailed.count());
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user