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

Function TestAvgOverTimeWithNoMatch

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

Source from the content-addressed store, hash-verified

1650}
1651
1652func TestAvgOverTimeWithNoMatch(t *testing.T) {
1653 req := &tempopb.QueryRangeRequest{
1654 Start: 1,
1655 End: uint64(3 * time.Second),
1656 Step: uint64(1 * time.Second),
1657 Query: "{ } | avg_over_time(span.buu)",
1658 }
1659
1660 // A variety of spans across times, durations, and series. All durations are powers of 2 for simplicity
1661 in := []Span{
1662 newMockSpan(nil).WithStartTime(uint64(1*time.Second)).WithSpanString("foo", "bar").WithSpanInt("http.status_code", 200).WithDuration(128),
1663 newMockSpan(nil).WithStartTime(uint64(1*time.Second)).WithSpanString("foo", "bar").WithSpanInt("http.status_code", 404).WithDuration(256),
1664 newMockSpan(nil).WithStartTime(uint64(1*time.Second)).WithSpanString("foo", "bar").WithSpanInt("http.status_code", 200).WithDuration(512),
1665
1666 newMockSpan(nil).WithStartTime(uint64(2*time.Second)).WithSpanString("foo", "bar").WithSpanInt("http.status_code", 200).WithDuration(256),
1667 newMockSpan(nil).WithStartTime(uint64(2*time.Second)).WithSpanString("foo", "bar").WithSpanInt("http.status_code", 200).WithDuration(64),
1668 newMockSpan(nil).WithStartTime(uint64(2*time.Second)).WithSpanString("foo", "bar").WithSpanInt("http.status_code", 200).WithDuration(256),
1669 newMockSpan(nil).WithStartTime(uint64(2*time.Second)).WithSpanString("foo", "bar").WithSpanInt("http.status_code", 200).WithDuration(8),
1670
1671 newMockSpan(nil).WithStartTime(uint64(3*time.Second)).WithSpanString("foo", "baz").WithSpanInt("http.status_code", 201).WithDuration(512),
1672 newMockSpan(nil).WithStartTime(uint64(3*time.Second)).WithSpanString("foo", "baz").WithSpanInt("http.status_code", 401).WithDuration(1024),
1673 newMockSpan(nil).WithStartTime(uint64(3*time.Second)).WithSpanString("foo", "baz").WithSpanInt("http.status_code", 500).WithDuration(512),
1674 }
1675
1676 result, seriesCount, err := runTraceQLMetric(req, in)
1677 require.NoError(t, err)
1678 require.Equal(t, len(result), seriesCount)
1679
1680 // Test that empty timeseries are not included
1681 ts := result.ToProto(req)
1682
1683 assert.True(t, len(ts) == 0)
1684}
1685
1686func TestObserveSeriesAverageOverTimeForSpanAttribute(t *testing.T) {
1687 req := &tempopb.QueryRangeRequest{

Callers

nothing calls this directly

Calls 8

newMockSpanFunction · 0.85
runTraceQLMetricFunction · 0.85
WithDurationMethod · 0.80
WithSpanIntMethod · 0.80
WithSpanStringMethod · 0.80
WithStartTimeMethod · 0.80
ToProtoMethod · 0.80
EqualMethod · 0.45

Tested by

no test coverage detected