Class Threshold

java.lang.Object
org.acemq.workloads.rules.Threshold

public final class Threshold extends Object
A rule written as a threshold on one number in the report — the shape of the admin library's alerts, so a rule reads the same whether it watches a broker or judges a run.

 Rule backlog = Threshold.named("backlog-stays-small")
         .on("queueDepthAtEnd").above(1_000)
         .severity(Severity.FAILED)
         .because("a queue that ends deep was filling, whatever the rates say");

 Rule tail = Threshold.named("tail")
         .on("endToEnd.p999").above(Duration.ofMillis(200))
         .because("one message in a thousand is a user every few seconds");
 

The same rule in a workload file:


 rules:
   - name: backlog-stays-small
     metric: queueDepthAtEnd
     above: 1000
     severity: failed
     because: a queue that ends deep was filling, whatever the rates say
 

A metric the run did not produce — a latency with no consumers, a depth that could not be read — never fires: there is nothing to compare. Latency metrics are compared in nanoseconds and take a Duration; errorRate is a fraction from 0 to 1.

  • Method Details

    • named

      public static Threshold named(String name)
      Parameters:
      name - what the finding is called in the report
      Returns:
      a threshold to configure
    • metricNames

      public static List<String> metricNames()
      Returns:
      every metric a threshold can be put on, in a stable order
    • isLatency

      public static boolean isLatency(String metric)
      Parameters:
      metric - one of metricNames()
      Returns:
      whether it is a latency, compared as a duration
    • on

      public Threshold on(String metric)
      Parameters:
      metric - one of metricNames()
      Returns:
      this
    • above

      public Threshold above(double limit)
      Parameters:
      limit - fires when the metric is above this
      Returns:
      this
    • below

      public Threshold below(double limit)
      Parameters:
      limit - fires when the metric is below this
      Returns:
      this
    • above

      public Threshold above(Duration limit)
      Parameters:
      limit - for a latency metric: fires when it is above this
      Returns:
      this
    • below

      public Threshold below(Duration limit)
      Parameters:
      limit - for a latency metric: fires when it is below this
      Returns:
      this
    • severity

      public Threshold severity(Severity severity)
      Parameters:
      severity - how bad it is when it fires; FAILED unless told otherwise
      Returns:
      this
    • because

      public Rule because(String reason)
      Parameters:
      reason - what crossing the threshold means, printed as the finding's implication
      Returns:
      the rule