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

Method labelsFor

pkg/traceql/engine_metrics.go:860–878  ·  view source on GitHub ↗

labelsFor gives the final labels for the series. Slower and not on the hot path. This is tweaked to match what prometheus does where possible with an exception. In the case of all values missing. (1) Standard case: a label is created for each group-by value in the series: Ex: rate() by (x,y) can y

(vals S)

Source from the content-addressed store, hash-verified

858// Ex: rate() by (x,y,z) and all nil yields:
859// {x="nil"}
860func (g *GroupingAggregator[F, S]) labelsFor(vals S) (Labels, SeriesMapKey) {
861 labels := make(Labels, 0, len(g.by)+1)
862 for i := range g.by {
863 if vals[i].Type == TypeNil {
864 continue
865 }
866 labels = append(labels, Label{g.by[i].String(), vals[i]})
867 }
868 if g.byFunc != nil {
869 labels = append(labels, Label{g.byFuncLabel, vals[len(g.by)]})
870 }
871
872 if len(labels) == 0 {
873 // When all nil then force one
874 labels = append(labels, Label{g.by[0].String(), NewStaticNil()})
875 }
876
877 return labels, labels.MapKey()
878}
879
880func (g *GroupingAggregator[F, S]) Series() SeriesSet {
881 ss := SeriesSet{}

Callers 1

SeriesMethod · 0.95

Calls 3

NewStaticNilFunction · 0.85
StringMethod · 0.45
MapKeyMethod · 0.45

Tested by

no test coverage detected