Description
PromQL trigonometric functions (e.g. atanh, acos, asin) currently throw an ArithmeticException when given out-of-range inputs. For example, atanh(2) throws rather than returning NaN.
In PromQL, these functions are expected to return NaN for out-of-range inputs instead of raising errors. This difference affects compatibility with Prometheus behavior.
Current behavior
atanh(2) → ArithmeticException: Atanh input out of range
Expected PromQL behavior
Affected functions
atanh (input outside [-1, 1])
acos (input outside [-1, 1])
asin (input outside [-1, 1])
- Potentially other trigonometric functions with domain restrictions
Proposal
Either create PromQL-specific variants of these functions that return NaN, or add a wrapping mechanism that catches ArithmeticException and returns NaN when invoked from a PromQL context.
Context
Discussed in #142213 (comment)