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

Function TestMetaConditionsWithout

pkg/traceql/storage_test.go:50–98  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

48}
49
50func TestMetaConditionsWithout(t *testing.T) {
51 tcs := []struct {
52 query string
53 expect []Condition
54 }{
55 {
56 // No meta fields present in query, all are selected.
57 query: "{ status=error}",
58 expect: SearchMetaConditions(),
59 },
60 {
61 // Service name, span name are able to be reused
62 query: "{ rootServiceName = `foo` && rootName = `bar`}",
63 expect: []Condition{
64 {Attribute: NewIntrinsic(IntrinsicTraceDuration), Op: OpNone},
65 {Attribute: NewIntrinsic(IntrinsicTraceID), Op: OpNone},
66 {Attribute: NewIntrinsic(IntrinsicTraceStartTime), Op: OpNone},
67 {Attribute: NewIntrinsic(IntrinsicSpanID), Op: OpNone},
68 {Attribute: NewIntrinsic(IntrinsicSpanStartTime), Op: OpNone},
69 {Attribute: NewIntrinsic(IntrinsicDuration), Op: OpNone},
70 {Attribute: NewIntrinsic(IntrinsicServiceStats), Op: OpNone},
71 },
72 },
73 {
74 // Duration is the only one able to be reused because it has no filtering
75 query: "{ rootServiceName = `foo` && rootName = `bar`} | avg(duration) > 1s",
76 expect: []Condition{
77 {Attribute: NewIntrinsic(IntrinsicTraceRootService), Op: OpNone},
78 {Attribute: NewIntrinsic(IntrinsicTraceRootSpan), Op: OpNone},
79 {Attribute: NewIntrinsic(IntrinsicTraceDuration), Op: OpNone},
80 {Attribute: NewIntrinsic(IntrinsicTraceID), Op: OpNone},
81 {Attribute: NewIntrinsic(IntrinsicTraceStartTime), Op: OpNone},
82 {Attribute: NewIntrinsic(IntrinsicSpanID), Op: OpNone},
83 {Attribute: NewIntrinsic(IntrinsicSpanStartTime), Op: OpNone},
84 {Attribute: NewIntrinsic(IntrinsicServiceStats), Op: OpNone},
85 },
86 },
87 {
88 // None are reused because the values are filtered and allConditions=false
89 query: "{ rootServiceName = `foo` || rootName = `bar`}",
90 expect: SearchMetaConditions(),
91 },
92 }
93
94 for _, tc := range tcs {
95 req, _ := ExtractFetchSpansRequest(tc.query)
96 require.Equal(t, tc.expect, SearchMetaConditionsWithout(req.Conditions, req.AllConditions))
97 }
98}

Callers

nothing calls this directly

Calls 5

SearchMetaConditionsFunction · 0.85
NewIntrinsicFunction · 0.85
ExtractFetchSpansRequestFunction · 0.85
EqualMethod · 0.45

Tested by

no test coverage detected