@@ -590,46 +590,79 @@ func (s *objectiveServer) List(ctx context.Context, req *connect.Request[objecti
590
590
591
591
// If specific grouping was selected we need to merge the label matchers for the queries.
592
592
if len (groupingMatchers ) > 0 {
593
- if oi .Indicator .Ratio != nil {
593
+ switch oi .IndicatorType () {
594
+ case slo .Ratio :
595
+ groupingMatchersErrors := make (map [string ]* labels.Matcher , len (groupingMatchers ))
596
+ groupingMatchersTotal := make (map [string ]* labels.Matcher , len (groupingMatchers ))
597
+ for _ , matcher := range groupingMatchers {
598
+ // We need to copy the matchers to avoid modifying the original later on.
599
+ groupingMatchersErrors [matcher .Name ] = & labels.Matcher {Type : matcher .Type , Name : matcher .Name , Value : matcher .Value }
600
+ groupingMatchersTotal [matcher .Name ] = & labels.Matcher {Type : matcher .Type , Name : matcher .Name , Value : matcher .Value }
601
+ }
602
+
594
603
for _ , m := range oi .Indicator .Ratio .Errors .LabelMatchers {
595
604
if rm , replace := groupingMatchers [m .Name ]; replace {
596
605
m .Type = rm .Type
597
606
m .Value = rm .Value
607
+ delete (groupingMatchersErrors , m .Name )
598
608
}
599
609
}
600
610
for _ , m := range oi .Indicator .Ratio .Total .LabelMatchers {
601
611
if rm , replace := groupingMatchers [m .Name ]; replace {
602
612
m .Type = rm .Type
603
613
m .Value = rm .Value
614
+ delete (groupingMatchersTotal , m .Name )
604
615
}
605
616
}
606
- }
607
- if oi .Indicator .Latency != nil {
617
+
618
+ // Now add the remaining matchers we didn't find before.
619
+ for _ , m := range groupingMatchersErrors {
620
+ oi .Indicator .Ratio .Errors .LabelMatchers = append (oi .Indicator .Ratio .Errors .LabelMatchers , m )
621
+ }
622
+ for _ , m := range groupingMatchersTotal {
623
+ oi .Indicator .Ratio .Total .LabelMatchers = append (oi .Indicator .Ratio .Total .LabelMatchers , m )
624
+ }
625
+ case slo .Latency :
626
+ groupingMatchersSuccess := make (map [string ]* labels.Matcher , len (groupingMatchers ))
627
+ groupingMatchersTotal := make (map [string ]* labels.Matcher , len (groupingMatchers ))
628
+ for _ , matcher := range groupingMatchers {
629
+ // We need to copy the matchers to avoid modifying the original later on.
630
+ groupingMatchersSuccess [matcher .Name ] = & labels.Matcher {Type : matcher .Type , Name : matcher .Name , Value : matcher .Value }
631
+ groupingMatchersTotal [matcher .Name ] = & labels.Matcher {Type : matcher .Type , Name : matcher .Name , Value : matcher .Value }
632
+ }
633
+
608
634
for _ , m := range oi .Indicator .Latency .Success .LabelMatchers {
609
635
if rm , replace := groupingMatchers [m .Name ]; replace {
610
636
m .Type = rm .Type
611
637
m .Value = rm .Value
638
+ delete (groupingMatchersSuccess , m .Name )
612
639
}
613
640
}
614
641
for _ , m := range oi .Indicator .Latency .Total .LabelMatchers {
615
642
if rm , replace := groupingMatchers [m .Name ]; replace {
616
643
m .Type = rm .Type
617
644
m .Value = rm .Value
645
+ delete (groupingMatchersTotal , m .Name )
618
646
}
619
647
}
620
- }
621
- if oi .Indicator .BoolGauge != nil {
648
+
649
+ // Now add the remaining matchers we didn't find before.
650
+ for _ , m := range groupingMatchersSuccess {
651
+ oi .Indicator .Latency .Success .LabelMatchers = append (oi .Indicator .Latency .Success .LabelMatchers , m )
652
+ }
653
+ for _ , m := range groupingMatchersTotal {
654
+ oi .Indicator .Latency .Total .LabelMatchers = append (oi .Indicator .Latency .Total .LabelMatchers , m )
655
+ }
656
+ case slo .BoolGauge :
622
657
for _ , m := range oi .Indicator .BoolGauge .LabelMatchers {
623
658
if rm , replace := groupingMatchers [m .Name ]; replace {
624
659
m .Type = rm .Type
625
660
m .Value = rm .Value
626
661
delete (groupingMatchers , m .Name )
627
662
}
628
663
}
629
- if len (groupingMatchers ) > 0 {
630
- for _ , m := range groupingMatchers {
631
- oi .Indicator .BoolGauge .LabelMatchers = append (oi .Indicator .BoolGauge .LabelMatchers , m )
632
- }
664
+ for _ , m := range groupingMatchers {
665
+ oi .Indicator .BoolGauge .LabelMatchers = append (oi .Indicator .BoolGauge .LabelMatchers , m )
633
666
}
634
667
}
635
668
}
0 commit comments