@@ -87,34 +87,65 @@ func setupMetricsReceiver(t *testing.T) *prometheusRemoteWriteReceiver {
87
87
88
88
func TestHandlePRWContentTypeNegotiation (t * testing.T ) {
89
89
for _ , tc := range []struct {
90
- name string
91
- contentType string
92
- expectedCode int
90
+ name string
91
+ contentType string
92
+ expectedCode int
93
+ expectedStats remote.WriteResponseStats
93
94
}{
94
95
{
95
96
name : "no content type" ,
96
97
contentType : "" ,
97
98
expectedCode : http .StatusUnsupportedMediaType ,
99
+ expectedStats : remote.WriteResponseStats {
100
+ Confirmed : false ,
101
+ Samples : 0 ,
102
+ Histograms : 0 ,
103
+ Exemplars : 0 ,
104
+ },
98
105
},
99
106
{
100
107
name : "unsupported content type" ,
101
108
contentType : "application/json" ,
102
109
expectedCode : http .StatusUnsupportedMediaType ,
110
+ expectedStats : remote.WriteResponseStats {
111
+ Confirmed : false ,
112
+ Samples : 0 ,
113
+ Histograms : 0 ,
114
+ Exemplars : 0 ,
115
+ },
103
116
},
104
117
{
105
118
name : "x-protobuf/no proto parameter" ,
106
119
contentType : "application/x-protobuf" ,
107
120
expectedCode : http .StatusUnsupportedMediaType ,
121
+ expectedStats : remote.WriteResponseStats {
122
+ Confirmed : false ,
123
+ Samples : 0 ,
124
+ Histograms : 0 ,
125
+ Exemplars : 0 ,
126
+ },
108
127
},
109
128
{
110
129
name : "x-protobuf/v1 proto parameter" ,
111
130
contentType : fmt .Sprintf ("application/x-protobuf;proto=%s" , promconfig .RemoteWriteProtoMsgV1 ),
112
131
expectedCode : http .StatusUnsupportedMediaType ,
132
+ expectedStats : remote.WriteResponseStats {
133
+ Confirmed : false ,
134
+ Samples : 0 ,
135
+ Histograms : 0 ,
136
+ Exemplars : 0 ,
137
+ },
113
138
},
114
139
{
115
140
name : "x-protobuf/v2 proto parameter" ,
116
141
contentType : fmt .Sprintf ("application/x-protobuf;proto=%s" , promconfig .RemoteWriteProtoMsgV2 ),
117
142
expectedCode : http .StatusNoContent ,
143
+ expectedStats : remote.WriteResponseStats {
144
+ Confirmed : true ,
145
+ Samples : 0 ,
146
+ Histograms : 0 ,
147
+ Exemplars : 0 ,
148
+ },
118
149
},
119
150
} {
120
151
t .Run (tc .name , func (t * testing.T ) {
@@ -170,6 +201,12 @@ func TestTranslateV2(t *testing.T) {
170
201
},
171
202
},
172
203
expectError : "missing metric name in labels" ,
204
+ expectedStats : remote.WriteResponseStats {
205
+ Confirmed : false ,
206
+ Samples : 0 ,
207
+ Histograms : 0 ,
208
+ Exemplars : 0 ,
209
+ },
173
210
},
174
211
{
175
212
name : "duplicate label" ,
@@ -183,6 +220,12 @@ func TestTranslateV2(t *testing.T) {
183
220
},
184
221
},
185
222
expectError : `duplicate label "__name__" in labels` ,
223
+ expectedStats : remote.WriteResponseStats {
224
+ Confirmed : false ,
225
+ Samples : 0 ,
226
+ Histograms : 0 ,
227
+ Exemplars : 0 ,
228
+ },
186
229
},
187
230
{
188
231
name : "UnitRef bigger than symbols length" ,
@@ -266,7 +309,12 @@ func TestTranslateV2(t *testing.T) {
266
309
267
310
return expected
268
311
}(),
269
- expectedStats : remote.WriteResponseStats {},
312
+ expectedStats : remote.WriteResponseStats {
313
+ Confirmed : true ,
314
+ Samples : 3 ,
315
+ Histograms : 0 ,
316
+ Exemplars : 0 ,
317
+ },
270
318
},
271
319
{
272
320
name : "timeseries with different scopes" ,
@@ -342,7 +390,12 @@ func TestTranslateV2(t *testing.T) {
342
390
343
391
return expected
344
392
}(),
345
- expectedStats : remote.WriteResponseStats {},
393
+ expectedStats : remote.WriteResponseStats {
394
+ Confirmed : true ,
395
+ Samples : 3 ,
396
+ Histograms : 0 ,
397
+ Exemplars : 0 ,
398
+ },
346
399
},
347
400
{
348
401
name : "separate timeseries - same labels - should be same datapointslice" ,
@@ -426,6 +479,12 @@ func TestTranslateV2(t *testing.T) {
426
479
427
480
return expected
428
481
}(),
482
+ expectedStats : remote.WriteResponseStats {
483
+ Confirmed : true ,
484
+ Samples : 3 ,
485
+ Histograms : 0 ,
486
+ Exemplars : 0 ,
487
+ },
429
488
},
430
489
{
431
490
name : "service with target_info metric" ,
@@ -488,6 +547,12 @@ func TestTranslateV2(t *testing.T) {
488
547
489
548
return metrics
490
549
}(),
550
+ expectedStats : remote.WriteResponseStats {
551
+ Confirmed : true ,
552
+ Samples : 1 ,
553
+ Histograms : 0 ,
554
+ Exemplars : 0 ,
555
+ },
491
556
},
492
557
} {
493
558
t .Run (tc .name , func (t * testing.T ) {
0 commit comments