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

Function TestSpanPoolRelease

tempodb/encoding/vparquet5/block_traceql_pool_test.go:13–70  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

11)
12
13func TestSpanPoolRelease(t *testing.T) {
14 // Get a span from the pool and populate it
15 span1 := getSpan()
16 span1.id = []byte("test-id")
17 span1.startTimeUnixNanos = 12345
18 span1.durationNanos = 67890
19 span1.nestedSetParent = 1
20 span1.nestedSetLeft = 2
21 span1.nestedSetRight = 3
22 span1.cbSpansetFinal = true
23 span1.cbSpanset = getSpanset()
24 span1.spanAttrs = append(span1.spanAttrs, attrVal{
25 a: traceql.NewAttribute("span-key"),
26 s: traceql.NewStaticString("span-value"),
27 })
28 span1.resourceAttrs = append(span1.resourceAttrs, attrVal{
29 a: traceql.NewAttribute("resource-key"),
30 s: traceql.NewStaticString("resource-value"),
31 })
32 span1.traceAttrs = append(span1.traceAttrs, attrVal{
33 a: traceql.NewAttribute("trace-key"),
34 s: traceql.NewStaticString("trace-value"),
35 })
36 span1.eventAttrs = append(span1.eventAttrs, attrVal{
37 a: traceql.NewAttribute("event-key"),
38 s: traceql.NewStaticString("event-value"),
39 })
40 span1.linkAttrs = append(span1.linkAttrs, attrVal{
41 a: traceql.NewAttribute("link-key"),
42 s: traceql.NewStaticString("link-value"),
43 })
44 span1.instrumentationAttrs = append(span1.instrumentationAttrs, attrVal{
45 a: traceql.NewAttribute("instrumentation-key"),
46 s: traceql.NewStaticString("instrumentation-value"),
47 })
48 span1.rowNum = parquetquery.RowNumber{1, 100}
49
50 putSpan(span1)
51
52 span2 := getSpan()
53
54 // Verify the reused span is properly cleared
55 assert.Nil(t, span2.id, "id should be cleared")
56 assert.Zero(t, span2.startTimeUnixNanos, "startTimeUnixNanos should be cleared")
57 assert.Zero(t, span2.durationNanos, "durationNanos should be cleared")
58 assert.Zero(t, span2.nestedSetParent, "nestedSetParent should be cleared")
59 assert.Zero(t, span2.nestedSetLeft, "nestedSetLeft should be cleared")
60 assert.Zero(t, span2.nestedSetRight, "nestedSetRight should be cleared")
61 assert.False(t, span2.cbSpansetFinal, "cbSpansetFinal should be cleared")
62 assert.Nil(t, span2.cbSpanset, "cbSpanset should be cleared")
63 assert.Len(t, span2.spanAttrs, 0, "spanAttrs should be cleared")
64 assert.Len(t, span2.resourceAttrs, 0, "resourceAttrs should be cleared")
65 assert.Len(t, span2.traceAttrs, 0, "traceAttrs should be cleared")
66 assert.Len(t, span2.eventAttrs, 0, "eventAttrs should be cleared")
67 assert.Len(t, span2.linkAttrs, 0, "linkAttrs should be cleared")
68 assert.Len(t, span2.instrumentationAttrs, 0, "instrumentationAttrs should be cleared")
69 assert.Equal(t, parquetquery.EmptyRowNumber(), span2.rowNum, "rowNum should be cleared")
70}

Callers

nothing calls this directly

Calls 8

NewAttributeFunction · 0.92
NewStaticStringFunction · 0.92
EmptyRowNumberFunction · 0.92
getSpanFunction · 0.70
getSpansetFunction · 0.70
putSpanFunction · 0.70
LenMethod · 0.65
EqualMethod · 0.45

Tested by

no test coverage detected