@@ -46,32 +46,17 @@ func TestDeleteWithCollisions(t *testing.T) {
46
46
}
47
47
48
48
func TestDeleteWithConstraints (t * testing.T ) {
49
- t .Run ("constrainedLabels overlap variableLabels" , func (t * testing.T ) {
50
- vec := NewConstrainedGaugeVec (
51
- GaugeOpts {
52
- Name : "test" ,
53
- Help : "helpless" ,
54
- },
55
- []string {"l1" , "l2" },
56
- ConstrainedLabels {
57
- "l2" : func (s string ) string { return "x" + s },
58
- },
59
- )
60
- testDelete (t , vec )
61
- })
62
- t .Run ("constrainedLabels are distinct from variableLabels" , func (t * testing.T ) {
63
- vec := NewConstrainedGaugeVec (
64
- GaugeOpts {
65
- Name : "test" ,
66
- Help : "helpless" ,
67
- },
68
- []string {"l1" },
69
- ConstrainedLabels {
70
- "l2" : func (s string ) string { return "x" + s },
71
- },
72
- )
73
- testDelete (t , vec )
49
+ vec := V2 .NewGaugeVec (GaugeVecOpts {
50
+ GaugeOpts {
51
+ Name : "test" ,
52
+ Help : "helpless" ,
53
+ },
54
+ ConstrainedLabels {
55
+ {Name : "l1" },
56
+ {Name : "l2" , Constraint : func (s string ) string { return "x" + s }},
57
+ },
74
58
})
59
+ testDelete (t , vec )
75
60
}
76
61
77
62
func testDelete (t * testing.T , vec * GaugeVec ) {
@@ -129,32 +114,17 @@ func TestDeleteLabelValuesWithCollisions(t *testing.T) {
129
114
}
130
115
131
116
func TestDeleteLabelValuesWithConstraints (t * testing.T ) {
132
- t .Run ("constrainedLabels overlap variableLabels" , func (t * testing.T ) {
133
- vec := NewConstrainedGaugeVec (
134
- GaugeOpts {
135
- Name : "test" ,
136
- Help : "helpless" ,
137
- },
138
- []string {"l1" , "l2" },
139
- ConstrainedLabels {
140
- "l2" : func (s string ) string { return "x" + s },
141
- },
142
- )
143
- testDeleteLabelValues (t , vec )
144
- })
145
- t .Run ("constrainedLabels are distinct from variableLabels" , func (t * testing.T ) {
146
- vec := NewConstrainedGaugeVec (
147
- GaugeOpts {
148
- Name : "test" ,
149
- Help : "helpless" ,
150
- },
151
- []string {"l1" },
152
- ConstrainedLabels {
153
- "l2" : func (s string ) string { return "x" + s },
154
- },
155
- )
156
- testDeleteLabelValues (t , vec )
117
+ vec := V2 .NewGaugeVec (GaugeVecOpts {
118
+ GaugeOpts {
119
+ Name : "test" ,
120
+ Help : "helpless" ,
121
+ },
122
+ ConstrainedLabels {
123
+ {Name : "l1" },
124
+ {Name : "l2" , Constraint : func (s string ) string { return "x" + s }},
125
+ },
157
126
})
127
+ testDeleteLabelValues (t , vec )
158
128
}
159
129
160
130
func testDeleteLabelValues (t * testing.T , vec * GaugeVec ) {
@@ -196,32 +166,18 @@ func TestDeletePartialMatch(t *testing.T) {
196
166
}
197
167
198
168
func TestDeletePartialMatchWithConstraints (t * testing.T ) {
199
- t .Run ("constrainedLabels overlap variableLabels" , func (t * testing.T ) {
200
- vec := NewConstrainedGaugeVec (
201
- GaugeOpts {
202
- Name : "test" ,
203
- Help : "helpless" ,
204
- },
205
- []string {"l1" , "l2" , "l3" },
206
- ConstrainedLabels {
207
- "l2" : func (s string ) string { return "x" + s },
208
- },
209
- )
210
- testDeletePartialMatch (t , vec )
211
- })
212
- t .Run ("constrainedLabels are distinct from variableLabels" , func (t * testing.T ) {
213
- vec := NewConstrainedGaugeVec (
214
- GaugeOpts {
215
- Name : "test" ,
216
- Help : "helpless" ,
217
- },
218
- []string {"l1" , "l2" },
219
- ConstrainedLabels {
220
- "l3" : func (s string ) string { return "x" + s },
221
- },
222
- )
223
- testDeletePartialMatch (t , vec )
169
+ vec := V2 .NewGaugeVec (GaugeVecOpts {
170
+ GaugeOpts {
171
+ Name : "test" ,
172
+ Help : "helpless" ,
173
+ },
174
+ ConstrainedLabels {
175
+ {Name : "l1" },
176
+ {Name : "l2" , Constraint : func (s string ) string { return "x" + s }},
177
+ {Name : "l3" },
178
+ },
224
179
})
180
+ testDeletePartialMatch (t , vec )
225
181
}
226
182
227
183
func testDeletePartialMatch (t * testing.T , baseVec * GaugeVec ) {
@@ -386,32 +342,17 @@ func testMetricVec(t *testing.T, vec *GaugeVec) {
386
342
387
343
func TestMetricVecWithConstraints (t * testing.T ) {
388
344
constraint := func (s string ) string { return "x" + s }
389
- t .Run ("constrainedLabels overlap variableLabels" , func (t * testing.T ) {
390
- vec := NewConstrainedGaugeVec (
391
- GaugeOpts {
392
- Name : "test" ,
393
- Help : "helpless" ,
394
- },
395
- []string {"l1" , "l2" },
396
- ConstrainedLabels {
397
- "l2" : constraint ,
398
- },
399
- )
400
- testConstrainedMetricVec (t , vec , constraint )
401
- })
402
- t .Run ("constrainedLabels are distinct from variableLabels" , func (t * testing.T ) {
403
- vec := NewConstrainedGaugeVec (
404
- GaugeOpts {
405
- Name : "test" ,
406
- Help : "helpless" ,
407
- },
408
- []string {"l1" },
409
- ConstrainedLabels {
410
- "l2" : constraint ,
411
- },
412
- )
413
- testConstrainedMetricVec (t , vec , constraint )
345
+ vec := V2 .NewGaugeVec (GaugeVecOpts {
346
+ GaugeOpts {
347
+ Name : "test" ,
348
+ Help : "helpless" ,
349
+ },
350
+ ConstrainedLabels {
351
+ {Name : "l1" },
352
+ {Name : "l2" , Constraint : constraint },
353
+ },
414
354
})
355
+ testConstrainedMetricVec (t , vec , constraint )
415
356
}
416
357
417
358
func testConstrainedMetricVec (t * testing.T , vec * GaugeVec , constrain func (string ) string ) {
@@ -531,43 +472,32 @@ func TestCurryVecWithCollisions(t *testing.T) {
531
472
func TestCurryVecWithConstraints (t * testing.T ) {
532
473
constraint := func (s string ) string { return "x" + s }
533
474
t .Run ("constrainedLabels overlap variableLabels" , func (t * testing.T ) {
534
- vec := NewConstrainedCounterVec (
475
+ vec := V2 . NewCounterVec ( CounterVecOpts {
535
476
CounterOpts {
536
477
Name : "test" ,
537
478
Help : "helpless" ,
538
479
},
539
- []string {"one" , "two" , "three" },
540
480
ConstrainedLabels {
541
- "three" : constraint ,
481
+ {Name : "one" },
482
+ {Name : "two" },
483
+ {Name : "three" , Constraint : constraint },
542
484
},
543
- )
544
- testCurryVec (t , vec )
545
- })
546
- t .Run ("constrainedLabels are distinct from variableLabels" , func (t * testing.T ) {
547
- vec := NewConstrainedCounterVec (
548
- CounterOpts {
549
- Name : "test" ,
550
- Help : "helpless" ,
551
- },
552
- []string {"one" , "two" },
553
- ConstrainedLabels {
554
- "three" : constraint ,
555
- },
556
- )
485
+ })
557
486
testCurryVec (t , vec )
558
487
})
559
488
t .Run ("constrainedLabels reducing cardinality" , func (t * testing.T ) {
560
489
constraint := func (s string ) string { return "x" }
561
- vec := NewConstrainedCounterVec (
490
+ vec := V2 . NewCounterVec ( CounterVecOpts {
562
491
CounterOpts {
563
492
Name : "test" ,
564
493
Help : "helpless" ,
565
494
},
566
- []string {"one" , "two" , "three" },
567
495
ConstrainedLabels {
568
- "three" : constraint ,
496
+ {Name : "one" },
497
+ {Name : "two" },
498
+ {Name : "three" , Constraint : constraint },
569
499
},
570
- )
500
+ } )
571
501
testConstrainedCurryVec (t , vec , constraint )
572
502
})
573
503
}
0 commit comments