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

Function TestTempoDBQueryRange

tempodb/tempodb_metrics_test.go:1048–1258  ·  tempodb/tempodb_metrics_test.go::TestTempoDBQueryRange

TestTempoDBQueryRange tests the metrics query functionality of TempoDB by verifying various types of time-series queries on trace data. The test: 1. Sets up a test environment 2. Generates test data: - 100 test spans distributed across 1-100 seconds - Each span's duration equals its start time (e.

(t *testing.T)

Source from the content-addressed store, hash-verified

1046// - Level 2: Results after first aggregation simulating multiple sources
1047// - Level 3: Final aggregation results
1048func TestTempoDBQueryRange(t *testing.T) {
1049 var (
1050 ctx = t.Context()
1051 tempDir = t.TempDir()
1052 blockVersion = vparquet5.VersionString
1053 e = traceql.NewEngine()
1054 )
1055
1056 dc := backend.DedicatedColumns{
1057 {Scope: "resource", Name: "res-dedicated.01", Type: "string"},
1058 {Scope: "resource", Name: "res-dedicated.02", Type: "string"},
1059 {Scope: "span", Name: "span-dedicated.01", Type: "string"},
1060 {Scope: "span", Name: "span-dedicated.02", Type: "string"},
1061 }
1062 r, w, c, err := New(&Config{
1063 Backend: backend.Local,
1064 Local: &local.Config{
1065 Path: path.Join(tempDir, "traces"),
1066 },
1067 Block: &common.BlockConfig{
1068 BloomFP: .01,
1069 BloomShardSizeBytes: 100_000,
1070 Version: blockVersion,
1071 RowGroupSizeBytes: 10000,
1072 DedicatedColumns: dc,
1073 },
1074 WAL: &wal.Config{
1075 Filepath: path.Join(tempDir, "wal"),
1076 IngestionSlack: time.Since(time.Time{}),
1077 },
1078 Search: &SearchConfig{
1079 ChunkSizeBytes: 1_000_000,
1080 ReadBufferCount: 8, ReadBufferSizeBytes: 4 * 1024 * 1024,
1081 },
1082 BlocklistPoll: 0,
1083 }, nil, log.NewNopLogger())
1084 require.NoError(t, err)
1085
1086 err = c.EnableCompaction(ctx, &CompactorConfig{
1087 MaxCompactionRange: time.Hour,
1088 BlockRetention: 0,
1089 CompactedBlockRetention: 0,
1090 }, &mockSharder{}, &mockOverrides{})
1091 require.NoError(t, err)
1092
1093 r.EnablePolling(ctx, &mockJobSharder{}, false)
1094
1095 // Write to wal
1096 wal := w.WAL()
1097
1098 meta := &backend.BlockMeta{BlockID: backend.NewUUID(), TenantID: testTenantID, DedicatedColumns: dc}
1099 head, err := wal.NewBlock(meta, model.CurrentEncoding)
1100 require.NoError(t, err)
1101 dec := model.MustNewSegmentDecoder(model.CurrentEncoding)
1102
1103 totalSpans := 100
1104 for i := 1; i <= totalSpans; i++ {
1105 tid := test.ValidTraceID(nil)

Callers

nothing calls this directly

Calls 15

NewEngineFunction · 0.92
NewUUIDFunction · 0.92
MustNewSegmentDecoderFunction · 0.92
ValidTraceIDFunction · 0.92
MakeSpanFunction · 0.92
MakeKeyValueStringPtrFunction · 0.92
DefaultSearchOptionsFunction · 0.92
WithSpanOnlyFetchFunction · 0.92
sortTimeSeriesFunction · 0.85
requestWithDefaultRangeFunction · 0.85
filterTimeSeriesByLabelFunction · 0.85

Tested by

no test coverage detected