Class SmtpMetrics

java.lang.Object
com.mimecast.robin.smtp.metrics.SmtpMetrics

public final class SmtpMetrics extends Object
SMTP-related Micrometer metrics.

Provides counters for tracking email receipt operations including successful runs and exceptions.

  • Field Details

    • log

      private static final org.apache.logging.log4j.Logger log
    • emailReceiptStartCounter

      private static volatile io.micrometer.core.instrument.Counter emailReceiptStartCounter
    • emailReceiptSuccessCounter

      private static volatile io.micrometer.core.instrument.Counter emailReceiptSuccessCounter
    • emailReceiptLimitCounter

      private static volatile io.micrometer.core.instrument.Counter emailReceiptLimitCounter
    • emailRblRejectionCounter

      private static volatile io.micrometer.core.instrument.Counter emailRblRejectionCounter
    • emailVirusRejectionCounter

      private static volatile io.micrometer.core.instrument.Counter emailVirusRejectionCounter
    • emailSpamRejectionCounter

      private static volatile io.micrometer.core.instrument.Counter emailSpamRejectionCounter
    • dosRateLimitRejectionCounter

      private static volatile io.micrometer.core.instrument.Counter dosRateLimitRejectionCounter
    • dosConnectionLimitRejectionCounter

      private static volatile io.micrometer.core.instrument.Counter dosConnectionLimitRejectionCounter
    • dosTarpitCounter

      private static volatile io.micrometer.core.instrument.Counter dosTarpitCounter
    • dosSlowTransferRejectionCounter

      private static volatile io.micrometer.core.instrument.Counter dosSlowTransferRejectionCounter
    • dosCommandFloodRejectionCounter

      private static volatile io.micrometer.core.instrument.Counter dosCommandFloodRejectionCounter
    • whitelistBypassCounter

      private static volatile io.micrometer.core.instrument.Counter whitelistBypassCounter
    • adaptiveRateLimitAppliedCounter

      private static volatile io.micrometer.core.instrument.Counter adaptiveRateLimitAppliedCounter
    • geoIpBlockRejectionCounter

      private static volatile io.micrometer.core.instrument.Counter geoIpBlockRejectionCounter
    • geoIpLimitAppliedCounter

      private static volatile io.micrometer.core.instrument.Counter geoIpLimitAppliedCounter
    • distributedStoreErrorCounter

      private static volatile io.micrometer.core.instrument.Counter distributedStoreErrorCounter
  • Constructor Details

    • SmtpMetrics

      private SmtpMetrics()
      Private constructor for utility class.
  • Method Details

    • initialize

      public static void initialize()
      Initialize all metrics with zero values.

      This should be called during application startup to ensure metrics appear in endpoints even before any SMTP traffic is processed.

    • incrementEmailReceiptStart

      public static void incrementEmailReceiptStart()
      Increment the email receipt start counter.

      Called when an email receipt connection is established and processing begins.

    • incrementEmailReceiptSuccess

      public static void incrementEmailReceiptSuccess()
      Increment the email receipt success counter.

      Called when an email receipt completes successfully.

    • incrementEmailReceiptLimit

      public static void incrementEmailReceiptLimit()
      Increment the email receipt limit counter.

      Called when an email receipt is terminated due to reaching error or transaction limits.

    • incrementEmailRblRejection

      public static void incrementEmailRblRejection()
      Increment the email RBL rejection counter.

      Called when an email connection is rejected due to RBL listing.

    • incrementEmailVirusRejection

      public static void incrementEmailVirusRejection()
      Increment the email virus rejection counter.

      Called when an email is rejected due to virus detection.

    • incrementEmailSpamRejection

      public static void incrementEmailSpamRejection()
      Increment the email spam rejection counter.

      Called when an email is rejected due to spam or phishing detection.

    • incrementDosRateLimitRejection

      public static void incrementDosRateLimitRejection()
      Increment the DoS rate limit rejection counter.

      Called when a connection is rejected due to rate limiting.

    • incrementDosConnectionLimitRejection

      public static void incrementDosConnectionLimitRejection()
      Increment the DoS connection limit rejection counter.

      Called when a connection is rejected due to connection limits.

    • incrementDosTarpit

      public static void incrementDosTarpit()
      Increment the DoS tarpit counter.

      Called when a connection is tarpitted due to suspicious behavior.

    • incrementDosSlowTransferRejection

      public static void incrementDosSlowTransferRejection()
      Increment the DoS slow transfer rejection counter.

      Called when a connection is rejected due to slow data transfer (slowloris attack).

    • incrementDosCommandFloodRejection

      public static void incrementDosCommandFloodRejection()
      Increment the DoS command flood rejection counter.

      Called when a connection is rejected due to command flooding.

    • incrementWhitelistBypass

      public static void incrementWhitelistBypass()
      Increment the whitelist bypass counter.

      Called when a connection is accepted from a whitelisted IP, bypassing DoS limits and RBL checks.

    • incrementAdaptiveRateLimitApplied

      public static void incrementAdaptiveRateLimitApplied()
      Increment the adaptive rate limit applied counter.

      Called when adaptive rate limiting reduces connection limits due to high server load.

    • incrementGeoIpBlockRejection

      public static void incrementGeoIpBlockRejection()
      Increment the GeoIP block rejection counter.

      Called when a connection is rejected due to GeoIP country block policy.

    • incrementGeoIpLimitApplied

      public static void incrementGeoIpLimitApplied()
      Increment the GeoIP limit applied counter.

      Called when a connection from a GeoIP-limited country has reduced limits applied.

    • incrementDistributedStoreError

      public static void incrementDistributedStoreError()
      Increment the distributed store error counter.

      Called when a Redis operation in RedisConnectionStore fails.

    • incrementEmailReceiptException

      public static void incrementEmailReceiptException(String exceptionType)
      Increment the email receipt exception counter.

      Called when an email receipt encounters an exception.

      Parameters:
      exceptionType - The simple name of the exception class.
    • incrementCounter

      private static void incrementCounter(Supplier<io.micrometer.core.instrument.Counter> counterSupplier, String counterName)
      Generic helper to increment a counter with lazy initialization.

      Handles double-checked locking for thread-safe lazy initialization and exception handling.

      Parameters:
      counterSupplier - Supplier that returns the counter field
      counterName - Name of the counter for logging purposes
    • initializeCounters

      private static void initializeCounters()
      Initialize the metric counters.

      This is called lazily on first use to ensure registries are available.

    • resetCounters

      static void resetCounters()
      Reset the counters (for testing purposes).