(t *testing.T)
| 958 | } |
| 959 | |
| 960 | func TestCountOverTimeInstantNs(t *testing.T) { |
| 961 | // not rounded values to simulate real world data |
| 962 | start := 1*time.Second - 9*time.Nanosecond |
| 963 | end := 3*time.Second + 9*time.Nanosecond |
| 964 | step := end - start // for instant queries step == end-start |
| 965 | req := &tempopb.QueryRangeRequest{ |
| 966 | Start: uint64(start), |
| 967 | End: uint64(end), |
| 968 | Step: uint64(step), |
| 969 | Query: "{ } | count_over_time()", |
| 970 | } |
| 971 | req.SetInstant(true) |
| 972 | |
| 973 | in := []Span{ |
| 974 | // outside of the range but within the range for ms. Should be ignored. |
| 975 | newMockSpan(nil).WithStartTime(uint64(start - 20*time.Nanosecond)).WithDuration(1), |
| 976 | newMockSpan(nil).WithStartTime(uint64(start - time.Nanosecond)).WithDuration(1), |
| 977 | |
| 978 | // within the range |
| 979 | newMockSpan(nil).WithStartTime(uint64(start)).WithDuration(1), |
| 980 | newMockSpan(nil).WithStartTime(uint64(start + time.Nanosecond)).WithDuration(1), |
| 981 | |
| 982 | // within the range |
| 983 | newMockSpan(nil).WithStartTime(uint64(end - time.Nanosecond)).WithDuration(1), |
| 984 | newMockSpan(nil).WithStartTime(uint64(end)).WithDuration(10), |
| 985 | |
| 986 | // outside of the range but within the range for ms. Should be ignored. |
| 987 | newMockSpan(nil).WithStartTime(uint64(end + time.Nanosecond)).WithDuration(1), |
| 988 | newMockSpan(nil).WithStartTime(uint64(end + 20*time.Nanosecond)).WithDuration(1), |
| 989 | } |
| 990 | |
| 991 | out := []TimeSeries{ |
| 992 | { |
| 993 | Labels: []Label{ |
| 994 | {Name: "__name__", Value: NewStaticString("count_over_time")}, |
| 995 | }, |
| 996 | Values: []float64{4}, |
| 997 | Exemplars: make([]Exemplar, 0), |
| 998 | }, |
| 999 | } |
| 1000 | |
| 1001 | result, seriesCount, err := runTraceQLMetric(req, in) |
| 1002 | require.NoError(t, err) |
| 1003 | require.Equal(t, len(result), seriesCount) |
| 1004 | requireEqualSeriesSets(t, out, result) |
| 1005 | } |
| 1006 | |
| 1007 | func TestAvgOverTimeInstantNs(t *testing.T) { |
| 1008 | // not rounded values to simulate real world data |
nothing calls this directly
no test coverage detected