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

Function TestMetricsAggregate_extractConditions

pkg/traceql/ast_conditions_test.go:314–348  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

312}
313
314func TestMetricsAggregate_extractConditions(t *testing.T) {
315 tests := map[string]struct {
316 first []Condition
317 second []Condition
318 all bool
319 }{
320 `{} | rate() by (name)`: {
321 // Empty spanset implies start time
322 []Condition{newCondition(IntrinsicSpanStartTimeAttribute, OpNone)},
323 []Condition{newCondition(IntrinsicNameAttribute, OpNone)},
324 true,
325 },
326 `{name="foo"} | rate() by (name)`: {
327 // by() clause doesn't overwrite existing condition
328 []Condition{newCondition(IntrinsicNameAttribute, OpEqual, NewStaticString("foo"))},
329 nil,
330 true,
331 },
332 }
333 for q, tt := range tests {
334 t.Run(q, func(t *testing.T) {
335 expr, err := Parse(q)
336 require.NoError(t, err)
337
338 req := &FetchSpansRequest{
339 AllConditions: true,
340 }
341 expr.extractConditions(req)
342
343 require.Equal(t, tt.first, req.Conditions)
344 require.Equal(t, tt.second, req.SecondPassConditions)
345 require.Equal(t, tt.all, req.AllConditions, "FetchSpansRequest.AllConditions")
346 })
347 }
348}
349
350func TestBinaryOperation_extractConditions(t *testing.T) {
351 tests := []struct {

Callers

nothing calls this directly

Calls 6

newConditionFunction · 0.85
NewStaticStringFunction · 0.85
ParseFunction · 0.85
extractConditionsMethod · 0.65
RunMethod · 0.45
EqualMethod · 0.45

Tested by

no test coverage detected