fix(heatmaps): very small y-axis values turning into engineering notation and throwing errors#116421
Conversation
…tion and throwing errors
| HEATMAP_DATASETS = {TraceMetrics} | ||
|
|
||
|
|
||
| def _format_long_float(value: float) -> str: |
There was a problem hiding this comment.
nit: probably doesn't need to be a private function like this, I'd probably just make it a class method on the Endpoint Class
| # Python's default float-to-string uses scientific notation for very small | ||
| # values (e.g. 8.527e-06), which the search query parser does not support. | ||
| # Fixed-point with 20 decimal places produces a plain decimal string the parser can handle. |
There was a problem hiding this comment.
| # Python's default float-to-string uses scientific notation for very small | |
| # values (e.g. 8.527e-06), which the search query parser does not support. | |
| # Fixed-point with 20 decimal places produces a plain decimal string the parser can handle. | |
| """ | |
| Python's default float-to-string uses scientific notation for very small | |
| values (e.g. 8.527e-06), which the search query parser does not support. | |
| Fixed-point with 20 decimal places produces a plain decimal string the parser can handle. | |
| """ |
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes and found 1 potential issue.
❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.
Reviewed by Cursor Bugbot for commit f72abe6. Configure here.
| Fixed-point with 20 decimal places produces a plain decimal string the parser can handle. | ||
| """ | ||
| if "e" in str(value) or "E" in str(value): | ||
| return f"{value:.20f}".rstrip("0").rstrip(".") |
There was a problem hiding this comment.
Precision loss silently rounds sub-1e-20 values to zero
Low Severity
_format_long_float uses :.20f formatting, which only provides 20 decimal places. For values smaller than ~5×10⁻²¹, the formatted result rounds to all zeros (0.00000000000000000000), and after rstrip("0").rstrip(".") the function silently returns '0' instead of the actual value. This would produce incorrect bucket boundaries in the query without any error signal.
Reviewed by Cursor Bugbot for commit f72abe6. Configure here.
There was a problem hiding this comment.
welp echarts won't process decimals over 20 places anyways so


I was having an issue with the heat maps endpoint for certain metrics. Seems like some of these metrics have very small numbers for their bounds and python was converting them to engineering notation (ex. 1.24e-4) when string formatting the query. We want to keep the decimal notation because that's what the queries will correctly take in and parse out.

Example:
anyways to fix it i've created a function to pre-format these strings so that they don't convert to eng notation.