Package io.opentelemetry.sdk.internal
Class ThrottlingLogger
- java.lang.Object
-
- io.opentelemetry.sdk.internal.ThrottlingLogger
-
public class ThrottlingLogger extends java.lang.Object
Will limit the number of log messages emitted, so as not to spam when problems are happening.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 java.util.logging.Logger
delegate
private RateLimiter
fastRateLimiter
private static double
RATE_LIMIT
private static java.util.concurrent.TimeUnit
rateTimeUnit
private java.util.concurrent.atomic.AtomicBoolean
throttled
private static double
THROTTLED_RATE_LIMIT
private RateLimiter
throttledRateLimiter
-
Constructor Summary
Constructors Constructor Description ThrottlingLogger(java.util.logging.Logger delegate)
Create a new logger which will enforce a max number of messages per minute.ThrottlingLogger(java.util.logging.Logger delegate, Clock clock)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description private void
doLog(java.util.logging.Level level, java.lang.String message, java.lang.Throwable throwable)
boolean
isLoggable(java.util.logging.Level level)
Returns whether the current wrapped logger is set to log at the given level.void
log(java.util.logging.Level level, java.lang.String message)
Log a message at the given level.void
log(java.util.logging.Level level, java.lang.String message, java.lang.Throwable throwable)
Log a message at the given level with a throwable.
-
-
-
Field Detail
-
RATE_LIMIT
private static final double RATE_LIMIT
- See Also:
- Constant Field Values
-
THROTTLED_RATE_LIMIT
private static final double THROTTLED_RATE_LIMIT
- See Also:
- Constant Field Values
-
rateTimeUnit
private static final java.util.concurrent.TimeUnit rateTimeUnit
-
delegate
private final java.util.logging.Logger delegate
-
throttled
private final java.util.concurrent.atomic.AtomicBoolean throttled
-
fastRateLimiter
private final RateLimiter fastRateLimiter
-
throttledRateLimiter
private final RateLimiter throttledRateLimiter
-
-
Constructor Detail
-
ThrottlingLogger
public ThrottlingLogger(java.util.logging.Logger delegate)
Create a new logger which will enforce a max number of messages per minute.
-
ThrottlingLogger
ThrottlingLogger(java.util.logging.Logger delegate, Clock clock)
-
-
Method Detail
-
log
public void log(java.util.logging.Level level, java.lang.String message)
Log a message at the given level.
-
log
public void log(java.util.logging.Level level, java.lang.String message, @Nullable java.lang.Throwable throwable)
Log a message at the given level with a throwable.
-
doLog
private void doLog(java.util.logging.Level level, java.lang.String message, @Nullable java.lang.Throwable throwable)
-
isLoggable
public boolean isLoggable(java.util.logging.Level level)
Returns whether the current wrapped logger is set to log at the given level.- Returns:
- true if the logger set to log at the requested level.
-
-