scrapecache

package
v0.32.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 29, 2026 License: MIT Imports: 0 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package scrapecache lets the collection own the caches that collectors keep between scrapes, such as internal/labelcache and internal/metriccache.

A collector lists its caches with ScrapeCaches. The collection resets them before Build and after Close, and begins a scrape of each cache before Collect and ends it after Collect returned. Collect calls of one collector never overlap, so a scrape always belongs to exactly one Collect call, even one that outlives its scrape budget.

Outside of the collection, for example when a test or a library consumer calls Collect directly, the caches have no scrape and every metric is built without them.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Reset

func Reset(collector any)

Reset resets the caches of collector, if it is an Owner.

Types

type Cache

type Cache interface {
	// BeginScrape begins the scrape of a Collect call.
	BeginScrape()
	// EndScrape ends the scrape after Collect returned err.
	EndScrape(err error)
	// Reset drops the cached entries. Their descriptors may be stale after
	// a new Build.
	Reset()
}

Cache is a cache that a collector keeps between scrapes.

type Owner

type Owner interface {
	// ScrapeCaches returns the caches of the collector. The collection may
	// call it before Build.
	ScrapeCaches() []Cache
}

Owner is implemented by collectors that keep caches between scrapes.

type Scrape

type Scrape struct {
	// contains filtered or unexported fields
}

Scrape is a scrape of the caches of a collector.

func Begin

func Begin(collector any) Scrape

Begin begins a scrape of the caches of collector, if it is an Owner. Call End with the error of Collect once Collect returned.

func (Scrape) End

func (s Scrape) End(err error)

End ends the scrape after Collect returned err.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL