The latency gate comparesDocumentation Index
Fetch the complete documentation index at: https://docs.pecta.ai/llms.txt
Use this file to discover all available pages before exploring further.
ctx.latency_ms against a threshold you set and fails the evaluation if the value is too high. Use it when your application has strict response-time contracts — for example, an RTB bidder that must respond in under 100 ms, or a customer-facing chat assistant where slow responses degrade user experience.
If ctx.latency_ms is not provided in the evaluation context, the gate returns skipped: true and is treated as passing. This lets you enable the gate globally and skip it on evaluations where upstream timing is not yet instrumented.
Usage
What a failure looks like
When the gate fails, its entry inresult.gates looks like this:
latency_ms in the gate result is the time the gate itself took to run (always sub-millisecond), not the upstream response time.
What a skip looks like
Whenlatency_ms is absent from the evaluation context:
Configuration
The maximum allowed latency in milliseconds. Must be a positive finite number. The gate throws at construction time if you pass
0, a negative value, Infinity, or NaN.Override the gate name recorded in results. Defaults to
"latency". Useful when you register multiple latency gates with different thresholds and need to tell them apart in result.gates.Multiple thresholds
You can register more than one latency gate with different names and thresholds to create warning and hard-fail bands:Gate names must be unique within an engine. If you add two gates with the same name,
createEngine throws immediately.