MCPcopy
hub / github.com/prometheus/prometheus / testScrapeLoopFailLegacyUnderUTF8

Function testScrapeLoopFailLegacyUnderUTF8

scrape/scrape_test.go:1410–1434  ·  view source on GitHub ↗
(t *testing.T, appV2 bool)

Source from the content-addressed store, hash-verified

1408}
1409
1410func testScrapeLoopFailLegacyUnderUTF8(t *testing.T, appV2 bool) {
1411 sl, _ := newTestScrapeLoop(t, withAppendable(teststorage.NewAppendable(), appV2), func(sl *scrapeLoop) {
1412 sl.validationScheme = model.LegacyValidation
1413 })
1414
1415 app := sl.appender()
1416 total, added, seriesAdded, err := app.append([]byte("{\"test.metric\"} 1\n"), "text/plain", time.Time{})
1417 require.ErrorContains(t, err, "invalid metric name or label names")
1418 require.NoError(t, app.Rollback())
1419 require.Equal(t, 1, total)
1420 require.Equal(t, 0, added)
1421 require.Equal(t, 0, seriesAdded)
1422
1423 // When scrapeloop has validation set to UTF-8, the metric is allowed.
1424 sl, _ = newTestScrapeLoop(t, withAppendable(teststorage.NewAppendable(), appV2), func(sl *scrapeLoop) {
1425 sl.validationScheme = model.UTF8Validation
1426 })
1427
1428 app = sl.appender()
1429 total, added, seriesAdded, err = app.append([]byte("{\"test.metric\"} 1\n"), "text/plain", time.Time{})
1430 require.NoError(t, err)
1431 require.Equal(t, 1, total)
1432 require.Equal(t, 1, added)
1433 require.Equal(t, 1, seriesAdded)
1434}
1435
1436func readTextParseTestMetrics(t testing.TB) []byte {
1437 t.Helper()

Callers 1

Calls 6

NewAppendableFunction · 0.92
newTestScrapeLoopFunction · 0.85
withAppendableFunction · 0.85
appendMethod · 0.65
RollbackMethod · 0.65
appenderMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…