MCPcopy
hub / github.com/grafana/tempo / TestCountOverTimeInstantNs

Function TestCountOverTimeInstantNs

pkg/traceql/engine_metrics_test.go:960–1005  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

958}
959
960func 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
1007func TestAvgOverTimeInstantNs(t *testing.T) {
1008 // not rounded values to simulate real world data

Callers

nothing calls this directly

Calls 8

SetInstantMethod · 0.95
newMockSpanFunction · 0.85
NewStaticStringFunction · 0.85
runTraceQLMetricFunction · 0.85
requireEqualSeriesSetsFunction · 0.85
WithDurationMethod · 0.80
WithStartTimeMethod · 0.80
EqualMethod · 0.45

Tested by

no test coverage detected