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

Function TestPipelineEvaluate

pkg/traceql/ast_test.go:730–778  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

728}
729
730func TestPipelineEvaluate(t *testing.T) {
731 testCases := []struct {
732 query string
733 input []*Spanset
734 output []*Spanset
735 }{
736 {
737 "{ true } | { true } | { true }",
738 []*Spanset{
739 {Spans: []Span{&mockSpan{}}},
740 },
741 []*Spanset{
742 {Spans: []Span{&mockSpan{}}},
743 },
744 },
745 {
746 "{ true } | { false } | { true }",
747 []*Spanset{
748 {Spans: []Span{&mockSpan{}}},
749 },
750 []*Spanset{},
751 },
752 {
753 "{ .foo1 = `a` } | { .foo2 = `b` }",
754 []*Spanset{
755 {Spans: []Span{
756 // First span should be dropped here
757 &mockSpan{attributes: map[Attribute]Static{NewAttribute("foo1"): NewStaticString("a")}},
758 &mockSpan{attributes: map[Attribute]Static{NewAttribute("foo1"): NewStaticString("a"), NewAttribute("foo2"): NewStaticString("b")}},
759 }},
760 },
761 []*Spanset{
762 {Spans: []Span{
763 &mockSpan{attributes: map[Attribute]Static{NewAttribute("foo1"): NewStaticString("a"), NewAttribute("foo2"): NewStaticString("b")}},
764 }},
765 },
766 },
767 }
768 for _, tc := range testCases {
769 t.Run(tc.query, func(t *testing.T) {
770 ast, err := Parse(tc.query)
771 require.NoError(t, err)
772
773 actual, err := ast.Pipeline.evaluate(tc.input)
774 require.NoError(t, err)
775 require.Equal(t, tc.output, actual)
776 })
777 }
778}
779
780func TestSpansetFilterEvaluate(t *testing.T) {
781 testCases := []struct {

Callers

nothing calls this directly

Calls 6

NewAttributeFunction · 0.85
NewStaticStringFunction · 0.85
ParseFunction · 0.85
evaluateMethod · 0.65
RunMethod · 0.45
EqualMethod · 0.45

Tested by

no test coverage detected