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

Function TestIntrinsics

pkg/traceql/parse_test.go:1157–1284  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

1155}
1156
1157func TestIntrinsics(t *testing.T) {
1158 tests := []struct {
1159 in string
1160 expected Intrinsic
1161 }{
1162 {in: "duration", expected: IntrinsicDuration},
1163 {in: "name", expected: IntrinsicName},
1164 {in: "status", expected: IntrinsicStatus},
1165 {in: "statusMessage", expected: IntrinsicStatusMessage},
1166 {in: "kind", expected: IntrinsicKind},
1167 {in: "parent", expected: IntrinsicParent},
1168 {in: "traceDuration", expected: IntrinsicTraceDuration},
1169 {in: "rootServiceName", expected: IntrinsicTraceRootService},
1170 {in: "rootName", expected: IntrinsicTraceRootSpan},
1171 {in: "nestedSetLeft", expected: IntrinsicNestedSetLeft},
1172 {in: "nestedSetRight", expected: IntrinsicNestedSetRight},
1173 {in: "nestedSetParent", expected: IntrinsicNestedSetParent},
1174 }
1175
1176 for _, tc := range tests {
1177 t.Run(tc.in, func(t *testing.T) {
1178 // as intrinsic e.g. duration
1179 s := "{ " + tc.in + " }"
1180 actual, err := Parse(s)
1181
1182 require.NoError(t, err)
1183 require.Equal(t, newRootExpr(newPipeline(
1184 newSpansetFilter(Attribute{
1185 Scope: AttributeScopeNone,
1186 Parent: false,
1187 Name: tc.in,
1188 Intrinsic: tc.expected,
1189 }))), actual)
1190
1191 // as attribute e.g .duration
1192 s = "{ ." + tc.in + "}"
1193 actual, err = Parse(s)
1194
1195 require.NoError(t, err)
1196 require.Equal(t, newRootExpr(newPipeline(
1197 newSpansetFilter(Attribute{
1198 Scope: AttributeScopeNone,
1199 Parent: false,
1200 Name: tc.in,
1201 Intrinsic: IntrinsicNone,
1202 }))), actual)
1203
1204 // as span scoped attribute e.g span.duration
1205 s = "{ span." + tc.in + "}"
1206 actual, err = Parse(s)
1207
1208 require.NoError(t, err)
1209 require.Equal(t, newRootExpr(newPipeline(
1210 newSpansetFilter(Attribute{
1211 Scope: AttributeScopeSpan,
1212 Parent: false,
1213 Name: tc.in,
1214 Intrinsic: IntrinsicNone,

Callers

nothing calls this directly

Calls 6

ParseFunction · 0.85
newRootExprFunction · 0.85
newPipelineFunction · 0.85
newSpansetFilterFunction · 0.85
RunMethod · 0.45
EqualMethod · 0.45

Tested by

no test coverage detected