(t *testing.T)
| 1830 | } |
| 1831 | |
| 1832 | func TestMaxOverTimeForDuration(t *testing.T) { |
| 1833 | req := &tempopb.QueryRangeRequest{ |
| 1834 | Start: 1, |
| 1835 | End: uint64(3 * time.Second), |
| 1836 | Step: uint64(1 * time.Second), |
| 1837 | Query: "{ } | max_over_time(duration) by (span.foo)", |
| 1838 | } |
| 1839 | |
| 1840 | // A variety of spans across times, durations, and series. All durations are powers of 2 for simplicity |
| 1841 | in := []Span{ |
| 1842 | newMockSpan(nil).WithStartTime(uint64(1*time.Second)).WithSpanString("foo", "bar").WithDuration(128), |
| 1843 | newMockSpan(nil).WithStartTime(uint64(1*time.Second)).WithSpanString("foo", "bar").WithDuration(256), |
| 1844 | newMockSpan(nil).WithStartTime(uint64(1*time.Second)).WithSpanString("foo", "bar").WithDuration(512), |
| 1845 | |
| 1846 | newMockSpan(nil).WithStartTime(uint64(2*time.Second)).WithSpanString("foo", "bar").WithDuration(256), |
| 1847 | newMockSpan(nil).WithStartTime(uint64(2*time.Second)).WithSpanString("foo", "bar").WithDuration(64), |
| 1848 | newMockSpan(nil).WithStartTime(uint64(2*time.Second)).WithSpanString("foo", "bar").WithDuration(256), |
| 1849 | newMockSpan(nil).WithStartTime(uint64(2*time.Second)).WithSpanString("foo", "bar").WithDuration(8), |
| 1850 | |
| 1851 | newMockSpan(nil).WithStartTime(uint64(3*time.Second)).WithSpanString("foo", "baz").WithDuration(512), |
| 1852 | newMockSpan(nil).WithStartTime(uint64(3*time.Second)).WithSpanString("foo", "baz").WithDuration(1024), |
| 1853 | newMockSpan(nil).WithStartTime(uint64(3*time.Second)).WithSpanString("foo", "baz").WithDuration(512), |
| 1854 | } |
| 1855 | |
| 1856 | result, seriesCount, err := runTraceQLMetric(req, in) |
| 1857 | require.NoError(t, err) |
| 1858 | require.Equal(t, len(result), seriesCount) |
| 1859 | |
| 1860 | fooBaz := result[LabelsFromArgs("span.foo", "baz").MapKey()] |
| 1861 | fooBar := result[LabelsFromArgs("span.foo", "bar").MapKey()] |
| 1862 | |
| 1863 | // We cannot compare with require.Equal because NaN != NaN |
| 1864 | // foo.baz = (NaN, NaN, 0.000000512) |
| 1865 | assert.True(t, math.IsNaN(fooBaz.Values[0])) |
| 1866 | assert.True(t, math.IsNaN(fooBaz.Values[1])) |
| 1867 | assert.Equal(t, 1024/float64(time.Second), fooBaz.Values[2]) |
| 1868 | |
| 1869 | // foo.bar = (0.000000128, 0.000000128, NaN) |
| 1870 | assert.Equal(t, 512/float64(time.Second), fooBar.Values[0]) |
| 1871 | assert.Equal(t, 256/float64(time.Second), fooBar.Values[1]) |
| 1872 | assert.True(t, math.IsNaN(fooBar.Values[2])) |
| 1873 | } |
| 1874 | |
| 1875 | func TestMaxOverTimeWithNoMatch(t *testing.T) { |
| 1876 | req := &tempopb.QueryRangeRequest{ |
nothing calls this directly
no test coverage detected