scraper

package module
v0.159.0 Latest Latest
Warning

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

Go to latest
Published: Aug 17, 2026 License: Apache-2.0 Imports: 6 Imported by: 91

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

This section is empty.

Types

type CreateLogsFunc added in v0.119.0

type CreateLogsFunc func(context.Context, Settings, component.Config) (Logs, error)

CreateLogsFunc is the equivalent of Factory.CreateLogs().

type CreateMetricsFunc

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

CreateMetricsFunc is the equivalent of Factory.CreateMetrics().

type Factory

type Factory interface {
	component.Factory

	// CreateLogs creates a Logs scraper based on this config.
	// If the scraper type does not support logs,
	// this function returns the error [pipeline.ErrSignalNotSupported].
	CreateLogs(ctx context.Context, set Settings, cfg component.Config) (Logs, error)

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

	// LogsStability gets the stability level of the Logs scraper.
	LogsStability() component.StabilityLevel

	// 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 WithLogs added in v0.119.0

func WithLogs(createLogs CreateLogsFunc, sl component.StabilityLevel) FactoryOption

WithLogs overrides the default "error not supported" implementation for CreateLogs and the default "undefined" stability level.

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
	// contains filtered or unexported fields
}

Settings configures scraper creators.

Directories

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

Jump to

Keyboard shortcuts

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