Package com.tnsai.quality.slo
Record Class Target
java.lang.Object
java.lang.Record
com.tnsai.quality.slo.Target
- Record Components:
targetPercent- 0–100; the goal valuecmp- comparison direction;Target.Comparison.GEfor availability / latency-percentile,Target.Comparison.LEfor error-ratelatencyThresholdMs- required when paired withSLOType.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 ClassesModifier and TypeClassDescriptionstatic enumDirection of comparison between observed value and target. -
Constructor Summary
ConstructorsConstructorDescriptionTarget(double targetPercent, Target.Comparison cmp, Optional<Double> latencyThresholdMs) Creates an instance of aTargetrecord class. -
Method Summary
Modifier and TypeMethodDescriptioncmp()Returns the value of thecmprecord component.final booleanIndicates whether some other object is "equal to" this one.final inthashCode()Returns a hash code value for this object.static Targetlatency(double targetPercent, double thresholdMs) Convenience for latency targets — percentile floor + ms ceiling.Returns the value of thelatencyThresholdMsrecord component.static Targetof(double targetPercent, Target.Comparison cmp) Convenience for availability / error-rate targets without a latency threshold.booleansatisfied(double observedPercent) Test whetherobservedsatisfies the target under this target's comparison direction.doubleReturns the value of thetargetPercentrecord component.final StringtoString()Returns a string representation of this record class.
-
Constructor Details
-
Target
Creates an instance of aTargetrecord class.- Parameters:
targetPercent- the value for thetargetPercentrecord componentcmp- the value for thecmprecord componentlatencyThresholdMs- the value for thelatencyThresholdMsrecord component
-
-
Method Details
-
of
Convenience for availability / error-rate targets without a latency threshold. -
latency
Convenience for latency targets — percentile floor + ms ceiling. -
satisfied
public boolean satisfied(double observedPercent) Test whetherobservedsatisfies the target under this target's comparison direction. -
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. -
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. -
equals
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 withObjects::equals(Object,Object); primitive components are compared with '=='. -
targetPercent
public double targetPercent()Returns the value of thetargetPercentrecord component.- Returns:
- the value of the
targetPercentrecord component
-
cmp
Returns the value of thecmprecord component.- Returns:
- the value of the
cmprecord component
-
latencyThresholdMs
Returns the value of thelatencyThresholdMsrecord component.- Returns:
- the value of the
latencyThresholdMsrecord component
-