(t *testing.T)
| 800 | } |
| 801 | |
| 802 | func TestQuantileOverTime(t *testing.T) { |
| 803 | req := &tempopb.QueryRangeRequest{ |
| 804 | Start: 1, |
| 805 | End: uint64(3 * time.Second), |
| 806 | Step: uint64(1 * time.Second), |
| 807 | Query: "{ } | quantile_over_time(duration, 0, 0.5, 1) by (span.foo)", |
| 808 | } |
| 809 | // intervals: (0;1], (1;2], (2;3] |
| 810 | |
| 811 | var ( |
| 812 | _128ns = 0.000000128 |
| 813 | _256ns = 0.000000256 |
| 814 | _512ns = 0.000000512 |
| 815 | ) |
| 816 | |
| 817 | // A variety of spans across times, durations, and series. All durations are powers of 2 for simplicity |
| 818 | in := []Span{ |
| 819 | // 1st interval: (0;1] |
| 820 | newMockSpan(nil).WithStartTime(uint64(1*time.Second)).WithSpanString("foo", "bar").WithDuration(128), |
| 821 | newMockSpan(nil).WithStartTime(uint64(1*time.Second)).WithSpanString("foo", "bar").WithDuration(256), |
| 822 | newMockSpan(nil).WithStartTime(uint64(1*time.Second)).WithSpanString("foo", "bar").WithDuration(512), |
| 823 | |
| 824 | // 2nd interval: (1;2] |
| 825 | newMockSpan(nil).WithStartTime(uint64(2*time.Second)).WithSpanString("foo", "bar").WithDuration(256), |
| 826 | newMockSpan(nil).WithStartTime(uint64(2*time.Second)).WithSpanString("foo", "bar").WithDuration(256), |
| 827 | newMockSpan(nil).WithStartTime(uint64(2*time.Second)).WithSpanString("foo", "bar").WithDuration(256), |
| 828 | newMockSpan(nil).WithStartTime(uint64(2*time.Second)).WithSpanString("foo", "bar").WithDuration(256), |
| 829 | |
| 830 | // 3rd interval: (2;3] |
| 831 | newMockSpan(nil).WithStartTime(uint64(3*time.Second)).WithSpanString("foo", "baz").WithDuration(512), |
| 832 | newMockSpan(nil).WithStartTime(uint64(3*time.Second)).WithSpanString("foo", "baz").WithDuration(512), |
| 833 | newMockSpan(nil).WithStartTime(uint64(3*time.Second)).WithSpanString("foo", "baz").WithDuration(512), |
| 834 | } |
| 835 | |
| 836 | // Output series with quantiles per foo |
| 837 | // Prom labels are sorted alphabetically, traceql labels maintain original order. |
| 838 | out := []TimeSeries{ |
| 839 | { |
| 840 | Labels: []Label{ |
| 841 | {Name: "span.foo", Value: NewStaticString("bar")}, |
| 842 | {Name: "p", Value: NewStaticFloat(0)}, |
| 843 | }, |
| 844 | Values: []float64{ |
| 845 | _128ns, |
| 846 | percentileHelper(0, _256ns, _256ns, _256ns, _256ns), |
| 847 | 0, |
| 848 | }, |
| 849 | }, |
| 850 | { |
| 851 | Labels: []Label{ |
| 852 | {Name: "span.foo", Value: NewStaticString("bar")}, |
| 853 | {Name: "p", Value: NewStaticFloat(0.5)}, |
| 854 | }, |
| 855 | Values: []float64{ |
| 856 | _256ns, |
| 857 | percentileHelper(0.5, _256ns, _256ns, _256ns, _256ns), |
| 858 | 0, |
| 859 | }, |
nothing calls this directly
no test coverage detected