@@ -267,90 +267,89 @@ func TestWriteAllWithEmptyStores(t *testing.T) {
267
267
}
268
268
}
269
269
270
- // TODO: AFFAIR empty headers are ignored by Prometheus? If not, we should remove them.
271
270
// No two consecutive headers will be entirely the same. The cases used below are only for their suffixes.
272
271
func TestSanitizeHeaders (t * testing.T ) {
273
- boilerplateHeaders := []string {
274
- "" ,
275
- "" ,
276
- "# HELP foo foo_help\n # TYPE foo gauge" ,
277
- "# HELP foo foo_help\n # TYPE foo info" ,
278
- "# HELP foo foo_help\n # TYPE foo stateset" ,
279
- "# HELP foo foo_help\n # TYPE foo counter" ,
280
- }
281
- duplicatedBoilerplateHeaders := []string {
282
- "" ,
283
- "" ,
284
- "# HELP foo foo_help\n # TYPE foo gauge" ,
285
- "# HELP foo foo_help\n # TYPE foo gauge" ,
286
- "# HELP foo foo_help\n # TYPE foo info" ,
287
- "# HELP foo foo_help\n # TYPE foo info" ,
288
- "# HELP foo foo_help\n # TYPE foo stateset" ,
289
- "# HELP foo foo_help\n # TYPE foo stateset" ,
290
- "# HELP foo foo_help\n # TYPE foo counter" ,
291
- "# HELP foo foo_help\n # TYPE foo counter" ,
292
- }
293
- dedepedBoilerplateHeaders := []string {
294
- "" ,
295
- "" ,
296
- "# HELP foo foo_help\n # TYPE foo gauge" ,
297
- "" ,
298
- "# HELP foo foo_help\n # TYPE foo info" ,
299
- "" ,
300
- "# HELP foo foo_help\n # TYPE foo stateset" ,
301
- "" ,
302
- "# HELP foo foo_help\n # TYPE foo counter" ,
303
- "" ,
304
- }
305
- protoIngestibleHeaders := []string {
306
- "" ,
307
- "" ,
308
- "# HELP foo foo_help\n # TYPE foo gauge" ,
309
- "# HELP foo foo_help\n # TYPE foo gauge" ,
310
- "# HELP foo foo_help\n # TYPE foo gauge" ,
311
- "# HELP foo foo_help\n # TYPE foo counter" ,
312
- }
313
- dedepedProtoIngestibleHeaders := []string {
314
- "" ,
315
- "" ,
316
- "# HELP foo foo_help\n # TYPE foo gauge" ,
317
- "" ,
318
- "# HELP foo foo_help\n # TYPE foo gauge" ,
319
- "" ,
320
- "# HELP foo foo_help\n # TYPE foo gauge" ,
321
- "" ,
322
- "# HELP foo foo_help\n # TYPE foo counter" ,
323
- "" ,
324
- }
325
272
testcases := []struct {
326
273
name string
327
274
contentType expfmt.Format
328
275
headers []string
329
276
expectedHeaders []string
330
277
}{
331
278
{
332
- name : "text-format unique headers" ,
333
- contentType : expfmt .FmtText ,
334
- headers : boilerplateHeaders ,
335
- expectedHeaders : boilerplateHeaders ,
279
+ name : "text-format unique headers" ,
280
+ contentType : expfmt .FmtText ,
281
+ headers : []string {
282
+ "" ,
283
+ "# HELP foo foo_help\n # TYPE foo gauge" ,
284
+ "# HELP foo foo_help\n # TYPE foo info" ,
285
+ "# HELP foo foo_help\n # TYPE foo stateset" ,
286
+ "# HELP foo foo_help\n # TYPE foo counter" ,
287
+ },
288
+ expectedHeaders : []string {
289
+ "# HELP foo foo_help\n # TYPE foo gauge" ,
290
+ "# HELP foo foo_help\n # TYPE foo info" ,
291
+ "# HELP foo foo_help\n # TYPE foo stateset" ,
292
+ "# HELP foo foo_help\n # TYPE foo counter" ,
293
+ },
336
294
},
337
295
{
338
- name : "text-format consecutive duplicate headers" ,
339
- contentType : expfmt .FmtText ,
340
- headers : duplicatedBoilerplateHeaders ,
341
- expectedHeaders : dedepedBoilerplateHeaders ,
296
+ name : "text-format consecutive duplicate headers" ,
297
+ contentType : expfmt .FmtText ,
298
+ headers : []string {
299
+ "" ,
300
+ "" ,
301
+ "" ,
302
+ "# HELP foo foo_help\n # TYPE foo gauge" ,
303
+ "# HELP foo foo_help\n # TYPE foo gauge" ,
304
+ "# HELP foo foo_help\n # TYPE foo info" ,
305
+ "# HELP foo foo_help\n # TYPE foo info" ,
306
+ "# HELP foo foo_help\n # TYPE foo stateset" ,
307
+ "# HELP foo foo_help\n # TYPE foo stateset" ,
308
+ "# HELP foo foo_help\n # TYPE foo counter" ,
309
+ "# HELP foo foo_help\n # TYPE foo counter" ,
310
+ },
311
+ expectedHeaders : []string {
312
+ "# HELP foo foo_help\n # TYPE foo gauge" ,
313
+ "# HELP foo foo_help\n # TYPE foo info" ,
314
+ "# HELP foo foo_help\n # TYPE foo stateset" ,
315
+ "# HELP foo foo_help\n # TYPE foo counter" ,
316
+ },
342
317
},
343
318
{
344
- name : "proto-format unique headers" ,
345
- contentType : expfmt .ProtoFmt , // Prometheus ProtoFmt is the only proto-based format we check for.
346
- headers : boilerplateHeaders ,
347
- expectedHeaders : protoIngestibleHeaders ,
319
+ name : "proto-format unique headers" ,
320
+ contentType : expfmt .ProtoFmt , // Prometheus ProtoFmt is the only proto-based format we check for.
321
+ headers : []string {
322
+ "" ,
323
+ "# HELP foo foo_help\n # TYPE foo gauge" ,
324
+ "# HELP foo foo_help\n # TYPE foo info" ,
325
+ "# HELP foo foo_help\n # TYPE foo stateset" ,
326
+ "# HELP foo foo_help\n # TYPE foo counter" ,
327
+ },
328
+ expectedHeaders : []string {
329
+ "# HELP foo foo_help\n # TYPE foo gauge" ,
330
+ "# HELP foo foo_help\n # TYPE foo counter" ,
331
+ },
348
332
},
349
333
{
350
- name : "proto-format consecutive duplicate headers" ,
351
- contentType : expfmt .ProtoFmt , // Prometheus ProtoFmt is the only proto-based format we check for.
352
- headers : duplicatedBoilerplateHeaders ,
353
- expectedHeaders : dedepedProtoIngestibleHeaders ,
334
+ name : "proto-format consecutive duplicate headers" ,
335
+ contentType : expfmt .ProtoFmt , // Prometheus ProtoFmt is the only proto-based format we check for.
336
+ headers : []string {
337
+ "" ,
338
+ "" ,
339
+ "" ,
340
+ "# HELP foo foo_help\n # TYPE foo gauge" ,
341
+ "# HELP foo foo_help\n # TYPE foo gauge" ,
342
+ "# HELP foo foo_help\n # TYPE foo info" ,
343
+ "# HELP foo foo_help\n # TYPE foo info" ,
344
+ "# HELP foo foo_help\n # TYPE foo stateset" ,
345
+ "# HELP foo foo_help\n # TYPE foo stateset" ,
346
+ "# HELP foo foo_help\n # TYPE foo counter" ,
347
+ "# HELP foo foo_help\n # TYPE foo counter" ,
348
+ },
349
+ expectedHeaders : []string {
350
+ "# HELP foo foo_help\n # TYPE foo gauge" ,
351
+ "# HELP foo foo_help\n # TYPE foo counter" ,
352
+ },
354
353
},
355
354
}
356
355
0 commit comments