observe

package
v1.2.3 Latest Latest
Warning

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

Go to latest
Published: Oct 20, 2026 License: Apache-2.0 Imports: 14 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package observe connects a run to the target's own telemetry: it queries Prometheus for the target's metrics over the run, for the report.

Index

Constants

View Source
const MaxPoints = 10_000

MaxPoints bounds the points per query. Prometheus refuses ranges of more than 11,000 points per series, so long runs use a coarser step.

Variables

This section is empty.

Functions

func Collect

func Collect(ctx context.Context, p *Prometheus, queries []Query, start, end time.Time, interval time.Duration) []report.TargetMetric

Collect evaluates each query over [start, end] and returns them as report target metrics, with times relative to start. A query that fails is returned with its error rather than failing the others.

func Step

func Step(start, end time.Time, interval time.Duration) time.Duration

Step returns the query step for a run: the report interval, made coarser when the run is long enough to exceed MaxPoints.

Types

type Config

type Config struct {
	// Prometheus is nil when no metrics are queried.
	Prometheus *Prometheus
	Queries    []Query
	// TraceURL is a link template containing {traceId}; empty for none.
	TraceURL string
}

Config is an observe block with its URLs and credentials resolved: from the scenario for stampede run, from named integrations on the server.

func (*Config) Apply

func (c *Config) Apply(ctx context.Context, rep *report.Report, interval time.Duration)

Apply adds the target's metrics over the run and trace links for the slowest requests to a finished run's report.

func (*Config) Empty

func (c *Config) Empty() bool

Empty reports whether there is nothing to do.

type Error

type Error struct {
	Status int
	Type   string
	Msg    string
}

Error is an error reported by Prometheus itself, such as a PromQL syntax error.

func (*Error) Error

func (e *Error) Error() string

type Point

type Point struct {
	T time.Time
	V float64
}

Point is one sample of a series.

type Prometheus

type Prometheus struct {
	// URL is the base URL, for example http://prometheus:9090. A path
	// prefix (https://host/prometheus) is kept.
	URL string
	// BearerToken, when set, is sent as Authorization: Bearer.
	BearerToken string
	// Client defaults to a client with a 30 second timeout.
	Client *http.Client
}

Prometheus is a client for the Prometheus HTTP API (and compatible servers such as Thanos, Mimir and VictoriaMetrics).

func (*Prometheus) QueryRange

func (p *Prometheus) QueryRange(ctx context.Context, query string, start, end time.Time, step time.Duration) ([]Series, error)

QueryRange evaluates query at every step between start and end.

type Query

type Query struct {
	Name, Expr string
}

Query is a named PromQL expression.

func QueriesOf

func QueriesOf(p *scenario.PrometheusObserve) []Query

QueriesOf lists a scenario's queries in name order.

type Series

type Series struct {
	Labels map[string]string
	Points []Point
}

Series is one time series returned by a range query.

Jump to

Keyboard shortcuts

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