Skip to content

Commit 58688c1

Browse files
committed
test labels
1 parent 09fe074 commit 58688c1

File tree

1 file changed

+19
-4
lines changed

1 file changed

+19
-4
lines changed

bridges/prometheus/producer_test.go

+19-4
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,9 @@ func TestProduce(t *testing.T) {
5050
metric := prometheus.NewGauge(prometheus.GaugeOpts{
5151
Name: "test_gauge_metric",
5252
Help: "A gauge metric for testing",
53+
ConstLabels: prometheus.Labels(map[string]string{
54+
"foo": "bar",
55+
}),
5356
})
5457
reg.MustRegister(metric)
5558
metric.Set(123.4)
@@ -65,7 +68,7 @@ func TestProduce(t *testing.T) {
6568
Data: metricdata.Gauge[float64]{
6669
DataPoints: []metricdata.DataPoint[float64]{
6770
{
68-
Attributes: attribute.NewSet(),
71+
Attributes: attribute.NewSet(attribute.String("foo", "bar")),
6972
Value: 123.4,
7073
},
7174
},
@@ -80,6 +83,9 @@ func TestProduce(t *testing.T) {
8083
metric := prometheus.NewCounter(prometheus.CounterOpts{
8184
Name: "test_counter_metric",
8285
Help: "A counter metric for testing",
86+
ConstLabels: prometheus.Labels(map[string]string{
87+
"foo": "bar",
88+
}),
8389
})
8490
reg.MustRegister(metric)
8591
metric.(prometheus.ExemplarAdder).AddWithExemplar(
@@ -103,7 +109,7 @@ func TestProduce(t *testing.T) {
103109
IsMonotonic: true,
104110
DataPoints: []metricdata.DataPoint[float64]{
105111
{
106-
Attributes: attribute.NewSet(),
112+
Attributes: attribute.NewSet(attribute.String("foo", "bar")),
107113
Value: 245.3,
108114
Exemplars: []metricdata.Exemplar[float64]{
109115
{
@@ -126,6 +132,9 @@ func TestProduce(t *testing.T) {
126132
metric := prometheus.NewSummary(prometheus.SummaryOpts{
127133
Name: "test_summary_metric",
128134
Help: "A summary metric for testing",
135+
ConstLabels: prometheus.Labels(map[string]string{
136+
"foo": "bar",
137+
}),
129138
})
130139
reg.MustRegister(metric)
131140
metric.Observe(15.0)
@@ -138,6 +147,9 @@ func TestProduce(t *testing.T) {
138147
metric := prometheus.NewHistogram(prometheus.HistogramOpts{
139148
Name: "test_histogram_metric",
140149
Help: "A histogram metric for testing",
150+
ConstLabels: prometheus.Labels(map[string]string{
151+
"foo": "bar",
152+
}),
141153
})
142154
reg.MustRegister(metric)
143155
metric.(prometheus.ExemplarObserver).ObserveWithExemplar(
@@ -164,7 +176,7 @@ func TestProduce(t *testing.T) {
164176
Sum: 578.3,
165177
Bounds: []float64{0.005, 0.01, 0.025, 0.05, 0.1, 0.25, 0.5, 1, 2.5, 5, 10},
166178
BucketCounts: []uint64{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1},
167-
Attributes: attribute.NewSet(),
179+
Attributes: attribute.NewSet(attribute.String("foo", "bar")),
168180
Exemplars: []metricdata.Exemplar[float64]{
169181
{
170182
Value: 578.3,
@@ -188,6 +200,9 @@ func TestProduce(t *testing.T) {
188200
metric := prometheus.NewGauge(prometheus.GaugeOpts{
189201
Name: "test_gauge_metric",
190202
Help: "A gauge metric for testing",
203+
ConstLabels: prometheus.Labels(map[string]string{
204+
"foo": "bar",
205+
}),
191206
})
192207
reg.MustRegister(metric)
193208
metric.Set(123.4)
@@ -209,7 +224,7 @@ func TestProduce(t *testing.T) {
209224
Data: metricdata.Gauge[float64]{
210225
DataPoints: []metricdata.DataPoint[float64]{
211226
{
212-
Attributes: attribute.NewSet(),
227+
Attributes: attribute.NewSet(attribute.String("foo", "bar")),
213228
Value: 123.4,
214229
},
215230
},

0 commit comments

Comments
 (0)