MCPcopy Create free account
hub / github.com/prometheus/common / testTextParseError

Function testTextParseError

expfmt/text_parse_test.go:431–659  ·  view source on GitHub ↗
(t testing.TB)

Source from the content-addressed store, hash-verified

429}
430
431func testTextParseError(t testing.TB) {
432 scenarios := []struct {
433 in string
434 err string
435 }{
436 // 0: No new-line at end of input.
437 {
438 in: `
439bla 3.14
440blubber 42`,
441 err: "text format parsing error in line 3: unexpected end of input stream",
442 },
443 // 1: Invalid escape sequence in label value.
444 {
445 in: `metric{label="\t"} 3.14`,
446 err: "text format parsing error in line 1: invalid escape sequence",
447 },
448 // 2: Newline in label value.
449 {
450 in: `
451metric{label="new
452line"} 3.14
453`,
454 err: `text format parsing error in line 2: label value "new" contains unescaped new-line`,
455 },
456 // 3:
457 {
458 in: `metric{@="bla"} 3.14`,
459 err: "text format parsing error in line 1: invalid label name for metric",
460 },
461 // 4:
462 {
463 in: `metric{__name__="bla"} 3.14`,
464 err: `text format parsing error in line 1: label name "__name__" is reserved`,
465 },
466 // 5:
467 {
468 in: `metric{label+="bla"} 3.14`,
469 err: "text format parsing error in line 1: expected '=' after label name",
470 },
471 // 6:
472 {
473 in: `metric{label=bla} 3.14`,
474 err: "text format parsing error in line 1: expected '\"' at start of label value",
475 },
476 // 7:
477 {
478 in: `
479# TYPE metric summary
480metric{quantile="bla"} 3.14
481`,
482 err: "text format parsing error in line 3: expected float as value for 'quantile' label",
483 },
484 // 8:
485 {
486 in: `metric{label="bla"+} 3.14`,
487 err: "text format parsing error in line 1: unexpected end of label value",
488 },

Callers 2

TestTextParseErrorFunction · 0.85
BenchmarkParseErrorFunction · 0.85

Calls 2

TextToMetricFamiliesMethod · 0.80
ErrorMethod · 0.80

Tested by

no test coverage detected