Package io.opentelemetry.sdk.internal
Class RateLimiter
- java.lang.Object
-
- io.opentelemetry.sdk.internal.RateLimiter
-
public class RateLimiter extends java.lang.ObjectThis class was taken from Jaeger java client. https://github.com/jaegertracing/jaeger-client-java/blob/master/jaeger-core/src/main/java/io/jaegertracing/internal/samplers/RateLimitingSampler.javaVariables have been renamed for clarity.
This class is internal and is hence not for public use. Its APIs are unstable and can change at any time.
-
-
Field Summary
Fields Modifier and Type Field Description private Clockclockprivate doublecreditsPerNanosecondprivate java.util.concurrent.atomic.AtomicLongcurrentBalanceprivate longmaxBalance
-
Constructor Summary
Constructors Constructor Description RateLimiter(double creditsPerSecond, double maxBalance, Clock clock)Create a new RateLimiter with the provided parameters.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description booleantrySpend(double itemCost)Check to see if the provided cost can be spent within the current limits.
-
-
-
Field Detail
-
clock
private final Clock clock
-
creditsPerNanosecond
private final double creditsPerNanosecond
-
maxBalance
private final long maxBalance
-
currentBalance
private final java.util.concurrent.atomic.AtomicLong currentBalance
-
-
Constructor Detail
-
RateLimiter
public RateLimiter(double creditsPerSecond, double maxBalance, Clock clock)Create a new RateLimiter with the provided parameters.- Parameters:
creditsPerSecond- How many credits to accrue per second.maxBalance- The maximum balance that the limiter can hold, which corresponds to the rate that is being limited to.clock- An implementation of theClockinterface.
-
-