@@ -19,11 +19,8 @@ import (
1919 "strings"
2020
2121 "github.com/cespare/xxhash/v2"
22- dto "github.com/prometheus/client_model/go "
22+ "github.com/prometheus/client_golang/prometheus/internal/fastdto "
2323 "github.com/prometheus/common/model"
24- "google.golang.org/protobuf/proto"
25-
26- "github.com/prometheus/client_golang/prometheus/internal"
2724)
2825
2926// Desc is the descriptor used by every Prometheus Metric. It is essentially
@@ -56,7 +53,7 @@ type Desc struct {
5653 variableLabelOrder []int
5754 // labelPairs contains the sorted DTO label pairs based on the constant labels
5855 // and variable labels
59- labelPairs []* dto .LabelPair
56+ labelPairs []fastdto .LabelPair
6057 // id is a hash of the values of the ConstLabels and fqName. This
6158 // must be unique among all registered descriptors and can therefore be
6259 // used as an identifier of the descriptor.
@@ -164,24 +161,23 @@ func (v2) NewDesc(fqName, help string, variableLabels ConstrainableLabels, const
164161 }
165162 d .dimHash = xxh .Sum64 ()
166163
167- d .labelPairs = make ([]* dto.LabelPair , 0 , len (constLabels )+ len (d .variableLabels .names ))
164+ d .labelPairs = make ([]fastdto.LabelPair , len (constLabels )+ len (d .variableLabels .names ))
165+ i := 0
168166 for n , v := range constLabels {
169- d .labelPairs = append (d .labelPairs , & dto.LabelPair {
170- Name : proto .String (n ),
171- Value : proto .String (v ),
172- })
167+ d .labelPairs [i ].Name = n
168+ d .labelPairs [i ].Value = v
169+ i ++
173170 }
174171 for _ , labelName := range d .variableLabels .names {
175- d .labelPairs = append (d .labelPairs , & dto.LabelPair {
176- Name : proto .String (labelName ),
177- })
172+ d .labelPairs [i ].Name = labelName
173+ i ++
178174 }
179- sort .Sort (internal .LabelPairSorter (d .labelPairs ))
175+ sort .Sort (fastdto .LabelPairSorter (d .labelPairs ))
180176
181177 d .variableLabelOrder = make ([]int , len (d .variableLabels .names ))
182178 for outputIndex , pair := range d .labelPairs {
183179 // Constant labels have values variable labels do not.
184- if pair .Value != nil {
180+ if pair .Value != "" {
185181 continue
186182 }
187183 for sourceIndex , variableLabel := range d .variableLabels .names {
@@ -190,7 +186,6 @@ func (v2) NewDesc(fqName, help string, variableLabels ConstrainableLabels, const
190186 }
191187 }
192188 }
193-
194189 return d
195190}
196191
@@ -207,7 +202,7 @@ func NewInvalidDesc(err error) *Desc {
207202func (d * Desc ) String () string {
208203 lpStrings := make ([]string , 0 , len (d .labelPairs ))
209204 for _ , lp := range d .labelPairs {
210- if lp .Value == nil {
205+ if lp .Value == "" {
211206 continue
212207 }
213208 lpStrings = append (
0 commit comments