the-algorithm/product-mixer/core/src/main/scala/com/twitter/product_mixer/core/functional_component/common/alert/predicate/TriggerIfLatencyAbove.scala
twitter-team ef4c5eb65e Twitter Recommendation Algorithm
Please note we have force-pushed a new initial commit in order to remove some publicly-available Twitter user information. Note that this process may be required in the future.
2023-03-31 17:36:31 -05:00

23 lines
803 B
Scala

package com.twitter.product_mixer.core.functional_component.common.alert.predicate
import com.twitter.util.Duration
/**
* A [[Predicate]] that triggers if the metric this is used with rises above the
* [[latencyThreshold]] for [[datapointsPastThreshold]] per [[duration]]
*
* @note [[latencyThreshold]] must be > 0
*/
case class TriggerIfLatencyAbove(
latencyThreshold: Duration,
override val datapointsPastThreshold: Int = 10,
override val duration: Int = 15,
override val metricGranularity: MetricGranularity = Minutes)
extends Predicate {
override val threshold: Double = latencyThreshold.inMillis
override val operator: Operator = `>`
require(
latencyThreshold > Duration.Zero,
s"TriggerIfLatencyAbove thresholds must be greater than 0 but got $latencyThreshold")
}