From 2f896c98ff81179aaea4f25a6908697df9de1e1c Mon Sep 17 00:00:00 2001 From: Levi Harrison Date: Sun, 26 Sep 2021 15:45:25 -0400 Subject: [PATCH] Address review comments Signed-off-by: Levi Harrison --- docs/querying/operators.md | 2 +- web/ui/module/codemirror-promql/src/grammar/promql.grammar | 1 - .../codemirror-promql/src/grammar/test/expression.txt | 7 +++++++ web/ui/module/codemirror-promql/src/grammar/tokens.js | 2 ++ 4 files changed, 10 insertions(+), 2 deletions(-) diff --git a/docs/querying/operators.md b/docs/querying/operators.md index 1f6455b7a..88781adc2 100644 --- a/docs/querying/operators.md +++ b/docs/querying/operators.md @@ -44,7 +44,7 @@ the result. The following trigonometric binary operators, which work in radians, exist in Prometheus: -* `atan2` (https://pkg.go.dev/math#Atan2, _This is experimental_) +* `atan2` (based on https://pkg.go.dev/math#Atan2, _This is experimental_) Trigonometric operators allow trigonometric functions to be executed on two vectors using vector matching, which isn't available with normal functions. They act in the same manner diff --git a/web/ui/module/codemirror-promql/src/grammar/promql.grammar b/web/ui/module/codemirror-promql/src/grammar/promql.grammar index a086003ce..642d25f10 100644 --- a/web/ui/module/codemirror-promql/src/grammar/promql.grammar +++ b/web/ui/module/codemirror-promql/src/grammar/promql.grammar @@ -17,7 +17,6 @@ @precedence { pow @right, mul @left - atan2 @left, add @left, eql @left, and @left, diff --git a/web/ui/module/codemirror-promql/src/grammar/test/expression.txt b/web/ui/module/codemirror-promql/src/grammar/test/expression.txt index 3e9883155..a4dfcd9ce 100644 --- a/web/ui/module/codemirror-promql/src/grammar/test/expression.txt +++ b/web/ui/module/codemirror-promql/src/grammar/test/expression.txt @@ -840,3 +840,10 @@ sum:my_metric_name:rate5m ==> MetricName(MetricIdentifier(Identifier)) + +# Testing Atan2 inherited precedence level + +1 + foo atan2 bar + +==> +PromQL(Expr(BinaryExpr(Expr(NumberLiteral),Add,BinModifiers,Expr(BinaryExpr(Expr(VectorSelector(MetricIdentifier(Identifier))),Atan2,BinModifiers,Expr(VectorSelector(MetricIdentifier(Identifier)))))))) \ No newline at end of file diff --git a/web/ui/module/codemirror-promql/src/grammar/tokens.js b/web/ui/module/codemirror-promql/src/grammar/tokens.js index c3353485f..9c9c509e5 100644 --- a/web/ui/module/codemirror-promql/src/grammar/tokens.js +++ b/web/ui/module/codemirror-promql/src/grammar/tokens.js @@ -14,6 +14,7 @@ import { And, Avg, + Atan2, Bool, Bottomk, By, @@ -58,6 +59,7 @@ export const specializeIdentifier = (value, stack) => { const contextualKeywordTokens = { avg: Avg, + atan2: Atan2, bottomk: Bottomk, count: Count, count_values: CountValues,