Record Class Target

java.lang.Object
java.lang.Record
com.tnsai.quality.slo.Target
Record Components:
targetPercent - 0–100; the goal value
cmp - comparison direction; Target.Comparison.GE for availability / latency-percentile, Target.Comparison.LE for error-rate
latencyThresholdMs - required when paired with SLOType.LATENCY; the threshold the percentile must beat

public record Target(double targetPercent, Target.Comparison cmp, Optional<Double> latencyThresholdMs) extends Record
Numeric target an SLO must hold (issue #92). For an availability SLO this is the success-fraction floor (e.g. 99.9, GE); for a latency SLO it's the percentage of attempts under latencyThresholdMs (e.g. 95, GE meaning "p95 must be at or under threshold"); for error-rate it's the ceiling (e.g. 0.1, LE meaning "errors at most 0.1%").
Since:
0.5.0 (issue #92)
  • Nested Class Summary

    Nested Classes
    Modifier and Type
    Class
    Description
    static enum 
    Direction of comparison between observed value and target.
  • Constructor Summary

    Constructors
    Constructor
    Description
    Target(double targetPercent, Target.Comparison cmp, Optional<Double> latencyThresholdMs)
    Creates an instance of a Target record class.
  • Method Summary

    Modifier and Type
    Method
    Description
    cmp()
    Returns the value of the cmp record component.
    final boolean
    Indicates whether some other object is "equal to" this one.
    final int
    Returns a hash code value for this object.
    static Target
    latency(double targetPercent, double thresholdMs)
    Convenience for latency targets — percentile floor + ms ceiling.
    Returns the value of the latencyThresholdMs record component.
    static Target
    of(double targetPercent, Target.Comparison cmp)
    Convenience for availability / error-rate targets without a latency threshold.
    boolean
    satisfied(double observedPercent)
    Test whether observed satisfies the target under this target's comparison direction.
    double
    Returns the value of the targetPercent record component.
    final String
    Returns a string representation of this record class.

    Methods inherited from class java.lang.Object

    getClass, notify, notifyAll, wait, wait, wait
  • Constructor Details

    • Target

      public Target(double targetPercent, Target.Comparison cmp, Optional<Double> latencyThresholdMs)
      Creates an instance of a Target record class.
      Parameters:
      targetPercent - the value for the targetPercent record component
      cmp - the value for the cmp record component
      latencyThresholdMs - the value for the latencyThresholdMs record component
  • Method Details

    • of

      public static Target of(double targetPercent, Target.Comparison cmp)
      Convenience for availability / error-rate targets without a latency threshold.
    • latency

      public static Target latency(double targetPercent, double thresholdMs)
      Convenience for latency targets — percentile floor + ms ceiling.
    • satisfied

      public boolean satisfied(double observedPercent)
      Test whether observed satisfies the target under this target's comparison direction.
    • toString

      public final String toString()
      Returns a string representation of this record class. The representation contains the name of the class, followed by the name and value of each of the record components.
      Specified by:
      toString in class Record
      Returns:
      a string representation of this object
    • hashCode

      public final int hashCode()
      Returns a hash code value for this object. The value is derived from the hash code of each of the record components.
      Specified by:
      hashCode in class Record
      Returns:
      a hash code value for this object
    • equals

      public final boolean equals(Object o)
      Indicates whether some other object is "equal to" this one. The objects are equal if the other object is of the same class and if all the record components are equal. Reference components are compared with Objects::equals(Object,Object); primitive components are compared with '=='.
      Specified by:
      equals in class Record
      Parameters:
      o - the object with which to compare
      Returns:
      true if this object is the same as the o argument; false otherwise.
    • targetPercent

      public double targetPercent()
      Returns the value of the targetPercent record component.
      Returns:
      the value of the targetPercent record component
    • cmp

      public Target.Comparison cmp()
      Returns the value of the cmp record component.
      Returns:
      the value of the cmp record component
    • latencyThresholdMs

      public Optional<Double> latencyThresholdMs()
      Returns the value of the latencyThresholdMs record component.
      Returns:
      the value of the latencyThresholdMs record component