Repository navigation
lib/traceql: accept quantiles like .9 in quantile_over_time - #328
Vandit1604 wants to merge 1 commit into
Conversation
There was a problem hiding this comment.
2 issues found across 4 files
Prompt for AI agents (unresolved issues)
Check if these issues are valid — if so, understand the root cause of each and fix them. When an issue isn't valid or won't be fixed in this PR, reply in its thread with the reason and then resolve the thread. If appropriate, use sub-agents to investigate and fix each issue separately.
<file name="lib/traceql/pipe_metrics.go">
<violation number="1" location="lib/traceql/pipe_metrics.go:164">
P2: This check runs after float64 rounding, so `1.00000000000000001` becomes `1` and is accepted despite being outside the allowed range. Validate the original decimal before rounding so out-of-range inputs return a TraceQL error.</violation>
<violation number="2" location="lib/traceql/pipe_metrics.go:171">
P2: This fixed-point normalization lets valid very small quantiles through, but their expanded decimal exceeds the downstream LogsQL numeric-length limit and makes the translated query fail. Keep the generated quantile within the downstream parser’s supported representation, or reject/report this range during TraceQL parsing instead of deferring the failure to LogsQL.</violation>
</file>
Reply with feedback, questions, or to request a fix.
Re-trigger cubic
| if err != nil { | ||
| return nil, fmt.Errorf("cannot parse quantile %q in quantile_over_time: %w", quantile, err) | ||
| } | ||
| if math.IsNaN(phi) || phi < 0 || phi > 1 { |
There was a problem hiding this comment.
P2: This check runs after float64 rounding, so 1.00000000000000001 becomes 1 and is accepted despite being outside the allowed range. Validate the original decimal before rounding so out-of-range inputs return a TraceQL error.
Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. When an issue isn't valid or won't be fixed in this PR, reply in its thread with the reason and then resolve the thread. At lib/traceql/pipe_metrics.go, line 164:
<comment>This check runs after float64 rounding, so `1.00000000000000001` becomes `1` and is accepted despite being outside the allowed range. Validate the original decimal before rounding so out-of-range inputs return a TraceQL error.</comment>
<file context>
@@ -156,7 +157,18 @@ func parsePipeQuantileOverTime(lex *lexer) (pipe, error) {
+ if err != nil {
+ return nil, fmt.Errorf("cannot parse quantile %q in quantile_over_time: %w", quantile, err)
+ }
+ if math.IsNaN(phi) || phi < 0 || phi > 1 {
+ return nil, fmt.Errorf("quantile in quantile_over_time must be in the range [0..1]; got %q", quantile)
+ }
</file context>
| // Drop the sign of -0. | ||
| phi = 0 | ||
| } | ||
| quantiles = append(quantiles, strconv.FormatFloat(phi, 'f', -1, 64)) |
There was a problem hiding this comment.
P2: This fixed-point normalization lets valid very small quantiles through, but their expanded decimal exceeds the downstream LogsQL numeric-length limit and makes the translated query fail. Keep the generated quantile within the downstream parser’s supported representation, or reject/report this range during TraceQL parsing instead of deferring the failure to LogsQL.
Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. When an issue isn't valid or won't be fixed in this PR, reply in its thread with the reason and then resolve the thread. At lib/traceql/pipe_metrics.go, line 171:
<comment>This fixed-point normalization lets valid very small quantiles through, but their expanded decimal exceeds the downstream LogsQL numeric-length limit and makes the translated query fail. Keep the generated quantile within the downstream parser’s supported representation, or reject/report this range during TraceQL parsing instead of deferring the failure to LogsQL.</comment>
<file context>
@@ -156,7 +157,18 @@ func parsePipeQuantileOverTime(lex *lexer) (pipe, error) {
+ // Drop the sign of -0.
+ phi = 0
+ }
+ quantiles = append(quantiles, strconv.FormatFloat(phi, 'f', -1, 64))
if !lex.isKeyword(",") {
break
</file context>
40b9006 to
3c91bda
Compare
There was a problem hiding this comment.
1 issue found across 2 files (changes from recent commits).
Prompt for AI agents (unresolved issues)
Check if these issues are valid — if so, understand the root cause of each and fix them. When an issue isn't valid or won't be fixed in this PR, reply in its thread with the reason and then resolve the thread. If appropriate, use sub-agents to investigate and fix each issue separately.
<file name="lib/traceql/pipe_metrics.go">
<violation number="1" location="lib/traceql/pipe_metrics.go:162">
P3: `ParseFloat` returns `ErrRange` for valid numeric input such as `1e999`, so this reports it as “expecting a number.” Treat overflow as an out-of-range quantile before handling syntax errors.</violation>
</file>
Reply with feedback, questions, or to request a fix.
Re-trigger cubic
| quantiles = append(quantiles, quantile) | ||
| phi, err := strconv.ParseFloat(quantile, 64) | ||
| if err != nil { | ||
| return nil, fmt.Errorf("expecting a number for quantile in quantile_over_time; got %q", quantile) |
There was a problem hiding this comment.
P3: ParseFloat returns ErrRange for valid numeric input such as 1e999, so this reports it as “expecting a number.” Treat overflow as an out-of-range quantile before handling syntax errors.
Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. When an issue isn't valid or won't be fixed in this PR, reply in its thread with the reason and then resolve the thread. At lib/traceql/pipe_metrics.go, line 162:
<comment>`ParseFloat` returns `ErrRange` for valid numeric input such as `1e999`, so this reports it as “expecting a number.” Treat overflow as an out-of-range quantile before handling syntax errors.</comment>
<file context>
@@ -159,7 +159,7 @@ func parsePipeQuantileOverTime(lex *lexer) (pipe, error) {
phi, err := strconv.ParseFloat(quantile, 64)
if err != nil {
- return nil, fmt.Errorf("cannot parse quantile %q in quantile_over_time: %w", quantile, err)
+ return nil, fmt.Errorf("expecting a number for quantile in quantile_over_time; got %q", quantile)
}
if math.IsNaN(phi) || phi < 0 || phi > 1 {
</file context>
| return nil, fmt.Errorf("expecting a number for quantile in quantile_over_time; got %q", quantile) | |
| if err != nil { | |
| if math.IsInf(phi, 0) { | |
| return nil, fmt.Errorf("quantile in quantile_over_time must be in the range [0..1]; got %q", quantile) | |
| } | |
| return nil, fmt.Errorf("expecting a number for quantile in quantile_over_time; got %q", quantile) | |
| } |
3c91bda to
d5f16f4
Compare
Quantiles without a leading zero, like
.9, now work inquantile_over_time, the same as in Tempo.0.90and0.9now give the sameplabel. A value outside [0..1] fails with a TraceQL error instead of a LogsQL one.Fixes #327