@@ -41,9 +41,12 @@ func TestGauge(t *testing.T) {
4141 want := []* metricdata.Metric {
4242 {
4343 Descriptor : metricdata.Descriptor {
44- Name : "TestGauge" ,
45- LabelKeys : []string {"k1" , "k2" },
46- Type : metricdata .TypeGaugeFloat64 ,
44+ Name : "TestGauge" ,
45+ LabelKeys : []metricdata.LabelKey {
46+ {Key : "k1" },
47+ {Key : "k2" },
48+ },
49+ Type : metricdata .TypeGaugeFloat64 ,
4750 },
4851 TimeSeries : []* metricdata.TimeSeries {
4952 {
@@ -136,9 +139,33 @@ func TestGaugeMetricOptionLabelKeys(t *testing.T) {
136139 name := "testOptUnit"
137140 gf , _ := r .AddFloat64Gauge (name , WithLabelKeys ("k1" , "k3" ))
138141 want := metricdata.Descriptor {
139- Name : name ,
140- LabelKeys : []string {"k1" , "k3" },
141- Type : metricdata .TypeGaugeFloat64 ,
142+ Name : name ,
143+ LabelKeys : []metricdata.LabelKey {
144+ {Key : "k1" },
145+ {Key : "k3" },
146+ },
147+ Type : metricdata .TypeGaugeFloat64 ,
148+ }
149+ got := gf .bm .desc
150+ if ! cmp .Equal (got , want ) {
151+ t .Errorf ("metric descriptor: got %v, want %v\n " , got , want )
152+ }
153+ }
154+
155+ func TestGaugeMetricOptionLabelKeysAndDesc (t * testing.T ) {
156+ r := NewRegistry ()
157+ name := "testOptUnit"
158+ lks := []metricdata.LabelKey {}
159+ lks = append (lks , metricdata.LabelKey {Key : "k1" , Description : "desc k1" },
160+ metricdata.LabelKey {Key : "k3" , Description : "desc k3" })
161+ gf , _ := r .AddFloat64Gauge (name , WithLabelKeysAndDescription (lks ... ))
162+ want := metricdata.Descriptor {
163+ Name : name ,
164+ LabelKeys : []metricdata.LabelKey {
165+ {Key : "k1" , Description : "desc k1" },
166+ {Key : "k3" , Description : "desc k3" },
167+ },
168+ Type : metricdata .TypeGaugeFloat64 ,
142169 }
143170 got := gf .bm .desc
144171 if ! cmp .Equal (got , want ) {
@@ -263,7 +290,7 @@ func TestMapKey(t *testing.T) {
263290 for i , tc := range cases {
264291 t .Run (fmt .Sprintf ("case %d" , i ), func (t * testing.T ) {
265292 g := & baseMetric {
266- keys : make ([]string , len (tc )),
293+ keys : make ([]metricdata. LabelKey , len (tc )),
267294 }
268295 mk := g .encodeLabelVals (tc )
269296 vals := g .decodeLabelVals (mk )
0 commit comments