bootstrap

package
v0.17.1 Latest Latest
Warning

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

Go to latest
Published: Jul 1, 2026 License: Apache-2.0 Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Bootstrap

type Bootstrap struct {
	// Logger is the configured logger for the exporter process.
	Logger *slog.Logger
	// MetricsPath is the parsed value of --web.telemetry-path.
	MetricsPath string
	// FlagConfig contains the parsed exporter-toolkit web flags.
	FlagConfig *web.FlagConfig
	// DisableExporterMetrics reports whether exporter self-metrics should be disabled.
	DisableExporterMetrics bool
	// MaxRequests is the parsed value of --web.max-requests.
	MaxRequests int
}

Bootstrap captures parsed startup options that handler factories can use to construct exporter-specific HTTP handlers after CLI parsing.

type Config

type Config struct {
	// App is the Kingpin application to register flags on. When nil,
	// kingpin.CommandLine is used.
	App *kingpin.Application
	// Name is the exporter name used for version output and startup logging.
	Name string
	// Description is used as the default landing page description.
	Description string
	// DefaultAddress is the default value for --web.listen-address.
	DefaultAddress string
	// Logger is the logger to use. When nil, toolkit configures promslog flags
	// and builds a logger during Parse.
	Logger *slog.Logger
	// LandingConfig customizes the generated landing page.
	LandingConfig web.LandingConfig
	// MetricsHandler is the static handler to register at the metrics path.
	MetricsHandler http.Handler
	// MetricsHandlerFactory builds the metrics handler after flags are parsed.
	MetricsHandlerFactory MetricsHandlerFactory
}

Config defines the generic exporter bootstrap inputs.

type MetricsHandlerFactory

type MetricsHandlerFactory func(*Bootstrap) (http.Handler, error)

MetricsHandlerFactory builds an exporter-specific metrics handler after the common toolkit flags have been parsed.

type Runner

type Runner struct {

	// Logger is the resolved logger after parsing configuration.
	Logger *slog.Logger
	// MetricsPath is the parsed value of --web.telemetry-path.
	MetricsPath string
	// FlagConfig contains the parsed exporter-toolkit web flags.
	FlagConfig *web.FlagConfig
	// DisableExporterMetrics is the parsed value of --web.disable-exporter-metrics.
	DisableExporterMetrics bool
	// MaxRequests is the parsed value of --web.max-requests.
	MaxRequests int
	// LandingConfig is the resolved landing page configuration.
	LandingConfig web.LandingConfig
	// MetricsHandler is the configured static metrics handler.
	MetricsHandler http.Handler
	// MetricsHandlerFactory is the configured deferred metrics handler builder.
	MetricsHandlerFactory MetricsHandlerFactory
	// contains filtered or unexported fields
}

Runner manages generic exporter startup around flag parsing, landing page setup, and web listener bootstrapping.

func New

func New(c Config) *Runner

New creates a generic exporter bootstrap instance.

func (*Runner) Run

func (t *Runner) Run() error

Run parses os.Args and starts serving the configured exporter endpoints.

Jump to

Keyboard shortcuts

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