(b []byte, contentType string, ts time.Time)
| 1593 | var _ scrapeLoopAppendAdapter = &scrapeLoopAppender{} |
| 1594 | |
| 1595 | func (sl *scrapeLoopAppender) append(b []byte, contentType string, ts time.Time) (total, added, seriesAdded int, err error) { |
| 1596 | defTime := timestamp.FromTime(ts) |
| 1597 | |
| 1598 | if len(b) == 0 { |
| 1599 | // Empty scrape. Just update the stale makers and swap the cache (but don't flush it). |
| 1600 | err = sl.updateStaleMarkers(sl.Appender, defTime) |
| 1601 | sl.cache.iterDone(false) |
| 1602 | return total, added, seriesAdded, err |
| 1603 | } |
| 1604 | |
| 1605 | p, err := textparse.New(b, contentType, sl.symbolTable, textparse.ParserOptions{ |
| 1606 | EnableTypeAndUnitLabels: sl.enableTypeAndUnitLabels, |
| 1607 | IgnoreNativeHistograms: !sl.enableNativeHistogramScraping, |
| 1608 | ConvertClassicHistogramsToNHCB: sl.convertClassicHistToNHCB, |
| 1609 | KeepClassicOnClassicAndNativeHistograms: sl.alwaysScrapeClassicHist, |
| 1610 | OpenMetricsSkipSTSeries: sl.enableSTZeroIngestion, |
| 1611 | FallbackContentType: sl.fallbackScrapeProtocol, |
| 1612 | }) |
| 1613 | if p == nil { |
| 1614 | sl.l.Error( |
| 1615 | "Failed to determine correct type of scrape target.", |
| 1616 | "content_type", contentType, |
| 1617 | "fallback_media_type", sl.fallbackScrapeProtocol, |
| 1618 | "err", err, |
| 1619 | ) |
| 1620 | return total, added, seriesAdded, err |
| 1621 | } |
| 1622 | if err != nil { |
| 1623 | sl.l.Debug( |
| 1624 | "Invalid content type on scrape, using fallback setting.", |
| 1625 | "content_type", contentType, |
| 1626 | "fallback_media_type", sl.fallbackScrapeProtocol, |
| 1627 | "err", err, |
| 1628 | ) |
| 1629 | } |
| 1630 | var ( |
| 1631 | appErrs = appendErrors{} |
| 1632 | sampleLimitErr error |
| 1633 | bucketLimitErr error |
| 1634 | lset labels.Labels // Escapes to heap so hoisted out of loop. |
| 1635 | e exemplar.Exemplar // Escapes to heap so hoisted out of loop. |
| 1636 | lastMeta *metaEntry |
| 1637 | lastMFName []byte |
| 1638 | ) |
| 1639 | |
| 1640 | exemplars := make([]exemplar.Exemplar, 0, 1) |
| 1641 | |
| 1642 | // Take an appender with limits. |
| 1643 | app := appenderWithLimits(sl.Appender, sl.sampleLimit, sl.bucketLimit, sl.maxSchema) |
| 1644 | |
| 1645 | defer func() { |
| 1646 | if err != nil { |
| 1647 | return |
| 1648 | } |
| 1649 | // Flush and swap the cache as the scrape was non-empty. |
| 1650 | sl.cache.iterDone(true) |
| 1651 | }() |
| 1652 |
nothing calls this directly
no test coverage detected