(t *testing.T)
| 1005 | } |
| 1006 | |
| 1007 | func TestAvgOverTimeInstantNs(t *testing.T) { |
| 1008 | // not rounded values to simulate real world data |
| 1009 | start := 1*time.Second - 9*time.Nanosecond |
| 1010 | end := 3*time.Second + 9*time.Nanosecond |
| 1011 | step := end - start // for instant queries step == end-start |
| 1012 | req := &tempopb.QueryRangeRequest{ |
| 1013 | Start: uint64(start), |
| 1014 | End: uint64(end), |
| 1015 | Step: uint64(step), |
| 1016 | Query: "{ } | avg_over_time(span:duration)", |
| 1017 | } |
| 1018 | req.SetInstant(true) |
| 1019 | |
| 1020 | in := []Span{ |
| 1021 | // outside of the range but within the range for ms. Should be ignored. |
| 1022 | newMockSpan(nil).WithStartTime(uint64(start - 20*time.Nanosecond)).WithDuration(uint64(1 * time.Second)), |
| 1023 | newMockSpan(nil).WithStartTime(uint64(start - time.Nanosecond)).WithDuration(uint64(2 * time.Second)), |
| 1024 | |
| 1025 | // within the range |
| 1026 | newMockSpan(nil).WithStartTime(uint64(start)).WithDuration(uint64(3 * time.Second)), |
| 1027 | newMockSpan(nil).WithStartTime(uint64(start + time.Nanosecond)).WithDuration(uint64(4 * time.Second)), |
| 1028 | |
| 1029 | // within the range |
| 1030 | newMockSpan(nil).WithStartTime(uint64(end - time.Nanosecond)).WithDuration(uint64(5 * time.Second)), |
| 1031 | newMockSpan(nil).WithStartTime(uint64(end)).WithDuration(uint64(6 * time.Second)), |
| 1032 | |
| 1033 | // outside of the range but within the range for ms. Should be ignored. |
| 1034 | newMockSpan(nil).WithStartTime(uint64(end + time.Nanosecond)).WithDuration(uint64(7 * time.Second)), |
| 1035 | newMockSpan(nil).WithStartTime(uint64(end + 20*time.Nanosecond)).WithDuration(uint64(8 * time.Second)), |
| 1036 | } |
| 1037 | |
| 1038 | out := []TimeSeries{ |
| 1039 | { |
| 1040 | Labels: []Label{ |
| 1041 | {Name: "__name__", Value: NewStaticString("avg_over_time")}, |
| 1042 | }, |
| 1043 | Values: []float64{(3 + 4 + 5 + 6) / 4.}, |
| 1044 | Exemplars: make([]Exemplar, 0), |
| 1045 | }, |
| 1046 | } |
| 1047 | |
| 1048 | result, seriesCount, err := runTraceQLMetric(req, in) |
| 1049 | require.NoError(t, err) |
| 1050 | require.Equal(t, len(result), seriesCount) |
| 1051 | requireEqualSeriesSets(t, out, result) |
| 1052 | } |
| 1053 | |
| 1054 | // TestCountOverTimeInstantNsWithCutoff simulates merge behavior in L2 and L3. |
| 1055 | func TestCountOverTimeInstantNsWithCutoff(t *testing.T) { |
nothing calls this directly
no test coverage detected