Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix TraceQL results caching bug for floats ending in .0 #4539

Merged
merged 1 commit into from
Jan 16, 2025

Conversation

carles-grafana
Copy link
Contributor

@carles-grafana carles-grafana commented Jan 13, 2025

What this PR does:

Which issue(s) this PR fixes:
Fixes #4528

Checklist

  • Tests updated
  • Documentation added
  • CHANGELOG.md updated - the order of entries should be [CHANGE], [FEATURE], [ENHANCEMENT], [BUGFIX]

@@ -352,7 +352,7 @@ func TestQuantileOverTime(t *testing.T) {
// Output series with quantiles per foo
// Prom labels are sorted alphabetically, traceql labels maintain original order.
out := SeriesSet{
`{p="0", span.foo="bar"}`: TimeSeries{
`{p="0.0", span.foo="bar"}`: TimeSeries{
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

not sure if this is wanted @mdisibio

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah interesting side effect. It's ok. The actual label value is the same NewStaticFloat(0)

Copy link
Contributor

@mdisibio mdisibio left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's add a few more test cases to be 100% of all effects, and then lgtm.

@@ -352,7 +352,7 @@ func TestQuantileOverTime(t *testing.T) {
// Output series with quantiles per foo
// Prom labels are sorted alphabetically, traceql labels maintain original order.
out := SeriesSet{
`{p="0", span.foo="bar"}`: TimeSeries{
`{p="0.0", span.foo="bar"}`: TimeSeries{
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah interesting side effect. It's ok. The actual label value is the same NewStaticFloat(0)

{arg: 10.0, want: "10"},
{arg: -1.0, want: "-1.0"},
{arg: 0.0, want: "0.0"},
{arg: 10.0, want: "10.0"},
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you add a few more cases: not ending in .0, and something with the e scientific notation?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry my comment wasn't clear. The cases I meant were a value like 12.34 to test the ., and something huge that outputs the e to test that case. 12.34 is halfway covered by the second case, but let's get clear cases where input == output. The 0 case isn't needed cause that's testing the int path which is already covered.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've added the 2 test cases and another one I think wasn't covered

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

12.34e+2 Nice catch 👍

@carles-grafana carles-grafana force-pushed the fix-traceql-float-caching branch 2 times, most recently from 26ff094 to 4bf18b9 Compare January 16, 2025 13:31
@carles-grafana carles-grafana force-pushed the fix-traceql-float-caching branch from 4bf18b9 to 9def255 Compare January 16, 2025 15:12
@mdisibio mdisibio merged commit bf361e1 into grafana:main Jan 16, 2025
16 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

TraceQL results caching bug for floats ending in .0
2 participants