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 ¶
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.