scraper

package module
v0.117.0 Latest Latest
Warning

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

Go to latest
Published: Jan 7, 2025 License: Apache-2.0 Imports: 7 Imported by: 48

README

General Information

A scraper defines how to connect and scrape telemetry data from an external source.

Status
Stability development: metrics, logs
Issues Open issues Closed issues

Documentation

Overview

Package scraper allows to define pull based receivers that can be configured using the scraperreceiver.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func MakeFactoryMap

func MakeFactoryMap(factories ...Factory) (map[component.Type]Factory, error)

MakeFactoryMap takes a list of receiver factories and returns a map with factory type as keys. It returns a non-nil error when there are factories with duplicate type.

Types

type CreateMetricsFunc

type CreateMetricsFunc func(context.Context, Settings, component.Config) (Metrics, error)

CreateMetricsFunc is the equivalent of Factory.CreateMetrics().

func (CreateMetricsFunc) CreateMetrics

func (f CreateMetricsFunc) CreateMetrics(ctx context.Context, set Settings, cfg component.Config) (Metrics, error)

CreateMetrics implements Factory.CreateMetrics.

type Factory

type Factory interface {
	component.Factory

	// CreateMetrics creates a Metrics scraper based on this config.
	// If the scraper type does not support metrics,
	// this function returns the error [pipeline.ErrSignalNotSupported].
	// Implementers can assume `next` is never nil.
	CreateMetrics(ctx context.Context, set Settings, cfg component.Config) (Metrics, error)

	// MetricsStability gets the stability level of the Metrics scraper.
	MetricsStability() component.StabilityLevel
	// contains filtered or unexported methods
}

Factory is factory interface for scrapers.

This interface cannot be directly implemented. Implementations must use the NewFactory to implement it.

func NewFactory

func NewFactory(cfgType component.Type, createDefaultConfig component.CreateDefaultConfigFunc, options ...FactoryOption) Factory

NewFactory returns a Factory.

type FactoryOption

type FactoryOption interface {
	// contains filtered or unexported methods
}

FactoryOption apply changes to Options.

func WithMetrics

func WithMetrics(createMetrics CreateMetricsFunc, sl component.StabilityLevel) FactoryOption

WithMetrics overrides the default "error not supported" implementation for CreateMetrics and the default "undefined" stability level.

type Logs added in v0.116.0

type Logs interface {
	component.Component

	// ScrapeLogs is the base interface to indicate that how should logs be scraped.
	ScrapeLogs(context.Context) (plog.Logs, error)
}

Logs is the base interface for logs scrapers.

func NewLogs added in v0.116.0

func NewLogs(scrape ScrapeLogsFunc, options ...Option) (Logs, error)

NewLogs creates a new Logs scraper.

type Metrics

type Metrics interface {
	component.Component

	ScrapeMetrics(context.Context) (pmetric.Metrics, error)
}

Metrics is the base interface for metrics scrapers.

func NewMetrics

func NewMetrics(scrape ScrapeMetricsFunc, options ...Option) (Metrics, error)

NewMetrics creates a new Metrics scraper.

type Option

type Option interface {
	// contains filtered or unexported methods
}

Option apply changes to internal options.

func WithShutdown

func WithShutdown(shutdown component.ShutdownFunc) Option

WithShutdown sets the function that will be called on shutdown.

func WithStart

func WithStart(start component.StartFunc) Option

WithStart sets the function that will be called on startup.

type ScrapeFunc

type ScrapeFunc[T any] func(context.Context) (T, error)

ScrapeFunc scrapes data.

type ScrapeLogsFunc added in v0.116.0

type ScrapeLogsFunc ScrapeFunc[plog.Logs]

ScrapeLogsFunc is a helper function that is similar to Logs.ScrapeLogs.

func (ScrapeLogsFunc) ScrapeLogs added in v0.116.0

func (sf ScrapeLogsFunc) ScrapeLogs(ctx context.Context) (plog.Logs, error)

type ScrapeMetricsFunc

type ScrapeMetricsFunc ScrapeFunc[pmetric.Metrics]

ScrapeMetricsFunc is a helper function that is similar to Metrics.ScrapeMetrics.

func (ScrapeMetricsFunc) ScrapeMetrics

func (sf ScrapeMetricsFunc) ScrapeMetrics(ctx context.Context) (pmetric.Metrics, error)

type Settings

type Settings struct {
	// ID returns the ID of the component that will be created.
	ID component.ID

	component.TelemetrySettings

	// BuildInfo can be used by components for informational purposes.
	BuildInfo component.BuildInfo
}

Settings configures scraper creators.

Directories

Path Synopsis
Package scrapererror provides custom error types for scrapers.
Package scrapererror provides custom error types for scrapers.
scrapertest module

Jump to

Keyboard shortcuts

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