package module
v0.37.1 Latest Latest

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

Go to latest
Published: Oct 15, 2021 License: Apache-2.0 Imports: 13 Imported by: 8



Package scraperhelper provides utilities for scrapers.



This section is empty.


This section is empty.


func NewScraperControllerReceiver

func NewScraperControllerReceiver(
	cfg *ScraperControllerSettings,
	set component.ReceiverCreateSettings,
	nextConsumer consumer.Metrics,
	options ...ScraperControllerOption,
) (component.Receiver, error)

NewScraperControllerReceiver creates a Receiver with the configured options, that can control multiple scrapers.


type ScrapeMetrics

type ScrapeMetrics func(context.Context) (pdata.MetricSlice, error)

ScrapeMetrics scrapes metrics.

type ScrapeResourceMetrics

type ScrapeResourceMetrics func(context.Context) (pdata.ResourceMetricsSlice, error)

ScrapeResourceMetrics scrapes resource metrics.

type Scraper

type Scraper interface {

	// ID returns the scraper id.
	ID() config.ComponentID
	Scrape(context.Context, config.ComponentID, component.ReceiverCreateSettings) (pdata.Metrics, error)

Scraper is the base interface for scrapers.

func NewMetricsScraper

func NewMetricsScraper(
	name string,
	scrape ScrapeMetrics,
	options ...ScraperOption,
) Scraper

NewMetricsScraper creates a Scraper that calls Scrape at the specified collection interval, reports observability information, and passes the scraped metrics to the next consumer.

func NewResourceMetricsScraper

func NewResourceMetricsScraper(
	id config.ComponentID,
	scrape ScrapeResourceMetrics,
	options ...ScraperOption,
) Scraper

NewResourceMetricsScraper creates a Scraper that calls Scrape at the specified collection interval, reports observability information, and passes the scraped resource metrics to the next consumer.

type ScraperControllerOption

type ScraperControllerOption func(*controller)

ScraperControllerOption apply changes to internal options.

func AddScraper

func AddScraper(scraper Scraper) ScraperControllerOption

AddScraper configures the provided scrape function to be called with the specified options, and at the specified collection interval.

Observability information will be reported, and the scraped metrics will be passed to the next consumer.

func WithTickerChannel

func WithTickerChannel(tickerCh <-chan time.Time) ScraperControllerOption

WithTickerChannel allows you to override the scraper controllers ticker channel to specify when scrape is called. This is only expected to be used by tests.

type ScraperControllerSettings

type ScraperControllerSettings struct {
	config.ReceiverSettings `mapstructure:",squash"` // squash ensures fields are correctly decoded in embedded struct
	CollectionInterval      time.Duration            `mapstructure:"collection_interval"`

ScraperControllerSettings defines common settings for a scraper controller configuration. Scraper controller receivers can embed this struct, instead of config.ReceiverSettings, and extend it with more fields if needed.

func DefaultScraperControllerSettings

func DefaultScraperControllerSettings(cfgType config.Type) ScraperControllerSettings

DefaultScraperControllerSettings returns default scraper controller settings with a collection interval of one minute.

type ScraperOption

type ScraperOption func(*baseSettings)

ScraperOption apply changes to internal options.

func WithShutdown

func WithShutdown(shutdown componenthelper.ShutdownFunc) ScraperOption

WithShutdown sets the function that will be called on shutdown.

func WithStart

func WithStart(start componenthelper.StartFunc) ScraperOption

WithStart sets the function that will be called on startup.

Jump to

Keyboard shortcuts

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