Class ThrottlingLogger

java.lang.Object
io.opentelemetry.sdk.internal.ThrottlingLogger

public class ThrottlingLogger extends 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 Details

    • RATE_LIMIT

      private static final double RATE_LIMIT
      See Also:
    • THROTTLED_RATE_LIMIT

      private static final double THROTTLED_RATE_LIMIT
      See Also:
    • rateTimeUnit

      private static final TimeUnit rateTimeUnit
    • delegate

      private final Logger delegate
    • throttled

      private final AtomicBoolean throttled
    • fastRateLimiter

      private final RateLimiter fastRateLimiter
    • throttledRateLimiter

      private final RateLimiter throttledRateLimiter
  • Constructor Details

    • ThrottlingLogger

      public ThrottlingLogger(Logger delegate)
      Create a new logger which will enforce a max number of messages per minute.
    • ThrottlingLogger

      ThrottlingLogger(Logger delegate, Clock clock)
  • Method Details

    • log

      public void log(Level level, String message)
      Log a message at the given level.
    • log

      public void log(Level level, String message, @Nullable Throwable throwable)
      Log a message at the given level with a throwable.
    • doLog

      private void doLog(Level level, String message, @Nullable Throwable throwable)
    • isLoggable

      public boolean isLoggable(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.