Class ExponentialHistogramMerger
java.lang.Object
org.elasticsearch.exponentialhistogram.ExponentialHistogramMerger
- All Implemented Interfaces:
Closeable,AutoCloseable,org.apache.lucene.util.Accountable,Releasable
public class ExponentialHistogramMerger
extends Object
implements org.apache.lucene.util.Accountable, Releasable
Allows accumulating multiple
ExponentialHistogram into a single one
while keeping the bucket count in the result below a given limit.-
Nested Class Summary
Nested Classes -
Field Summary
FieldsFields inherited from interface org.apache.lucene.util.Accountable
NULL_ACCOUNTABLE -
Method Summary
Modifier and TypeMethodDescriptionvoidadd(ExponentialHistogram toAdd) Merges the given histogram into the current result.voidclose()static ExponentialHistogramMergercreate(int bucketLimit, ExponentialHistogramCircuitBreaker circuitBreaker) Creates a new instance with the specified bucket limit.static ExponentialHistogramMergercreate(ExponentialHistogramCircuitBreaker circuitBreaker) Creates a new instance with the OpenTelemetry SDK default bucket limit ofDEFAULT_MAX_HISTOGRAM_BUCKETS.createFactory(int bucketLimit, ExponentialHistogramCircuitBreaker circuitBreaker) Creates a new factory with the specified bucket limit.createFactory(ExponentialHistogramCircuitBreaker circuitBreaker) Creates a new factory with the OpenTelemetry SDK default bucket limit ofDEFAULT_MAX_HISTOGRAM_BUCKETS.static ExponentialHistogramMergercreateWithMaxScale(int bucketLimit, int maxScale, ExponentialHistogramCircuitBreaker circuitBreaker) get()Gets the current merged histogram without clearing this merger.Returns the merged histogram and clears this merger.longMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface org.apache.lucene.util.Accountable
getChildResources
-
Field Details
-
DEFAULT_MAX_HISTOGRAM_BUCKETS
public static final int DEFAULT_MAX_HISTOGRAM_BUCKETS- See Also:
-
-
Method Details
-
createFactory
public static ExponentialHistogramMerger.Factory createFactory(ExponentialHistogramCircuitBreaker circuitBreaker) Creates a new factory with the OpenTelemetry SDK default bucket limit ofDEFAULT_MAX_HISTOGRAM_BUCKETS.- Parameters:
circuitBreaker- the circuit breaker to use to limit memory allocations
-
createFactory
public static ExponentialHistogramMerger.Factory createFactory(int bucketLimit, ExponentialHistogramCircuitBreaker circuitBreaker) Creates a new factory with the specified bucket limit.- Parameters:
bucketLimit- the maximum number of buckets the result histogram is allowed to have, must be at least 4circuitBreaker- the circuit breaker to use to limit memory allocations
-
create
Creates a new instance with the OpenTelemetry SDK default bucket limit ofDEFAULT_MAX_HISTOGRAM_BUCKETS.- Parameters:
circuitBreaker- the circuit breaker to use to limit memory allocations
-
create
public static ExponentialHistogramMerger create(int bucketLimit, ExponentialHistogramCircuitBreaker circuitBreaker) Creates a new instance with the specified bucket limit.- Parameters:
bucketLimit- the maximum number of buckets the result histogram is allowed to have, must be at least 4circuitBreaker- the circuit breaker to use to limit memory allocations
-
createWithMaxScale
public static ExponentialHistogramMerger createWithMaxScale(int bucketLimit, int maxScale, ExponentialHistogramCircuitBreaker circuitBreaker) -
close
public void close()- Specified by:
closein interfaceAutoCloseable- Specified by:
closein interfaceCloseable- Specified by:
closein interfaceReleasable
-
ramBytesUsed
public long ramBytesUsed()- Specified by:
ramBytesUsedin interfaceorg.apache.lucene.util.Accountable
-
getAndClear
Returns the merged histogram and clears this merger. The caller takes ownership of the returned histogram and must ensure thatclose()is called.- Returns:
- the merged histogram
-
get
Gets the current merged histogram without clearing this merger. Note that the ownership of the returned histogram remains with this merger, so the caller must not close it. The returned histogram is only valid until the next call toadd(ExponentialHistogram), or until the merger is closed.- Returns:
- the current merged histogram
-
add
Merges the given histogram into the current result.- Parameters:
toAdd- the histogram to merge
-