report

package
v0.17.0 Latest Latest
Warning

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

Go to latest
Published: Aug 22, 2023 License: BSD-3-Clause Imports: 10 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Run

func Run(ctx context.Context, tx *sqlx.Tx, prom PromQuerier, queryName string, from time.Time, options ...Option) error

Run executes a prometheus query loaded from queries with using the `queryName` and the timestamp. The results of the query are saved in the facts table.

func RunRange

func RunRange(ctx context.Context, database *sqlx.DB, prom PromQuerier, queryName string, from time.Time, until time.Time, options ...Option) (int, error)

RunRange executes prometheus queries like Run() until the `until` timestamp is reached or an error occurred. Returns the number of reports run and a possible error.

Types

type Option

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

Option represents a report option.

func WithProgressReporter

func WithProgressReporter(r func(Progress)) Option

WithProgressReporter allows setting a callback function. The callback receives a progress report when generating multiple reports.

func WithPrometheusQueryTimeout

func WithPrometheusQueryTimeout(tm time.Duration) Option

WithPrometheusQueryTimeout allows setting a timout when querying prometheus.

type Progress

type Progress struct {
	Timestamp time.Time
	Count     int
}

Progress represent the progress when generating multiple reports.

type PromQuerier

type PromQuerier interface {
	Query(ctx context.Context, query string, ts time.Time, opts ...apiv1.Option) (model.Value, apiv1.Warnings, error)
}

Jump to

Keyboard shortcuts

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