metricdb

package
v0.5.0 Latest Latest
Warning

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

Go to latest
Published: Apr 11, 2023 License: Apache-2.0 Imports: 16 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type T

type T struct {
	// contains filtered or unexported fields
}

T represents a metrics database.

func Open

func Open(ctx context.Context) (*T, error)

Open opens the default metric database on the local machine, creating it if necessary.

func OpenFile

func OpenFile(ctx context.Context, fname string) (*T, error)

OpenFile opens the metric database stored in the provided file, creating it if necessary. Useful for tests where using the default database isn't desirable.

func (*T) Close

func (s *T) Close() error

Close closes the metric database.

func (*T) Query

func (s *T) Query(ctx context.Context, startTime, endTime time.Time, name string, labels map[string]string, fn func(*metrics.MetricSnapshot) error) error

Query calls fn with metrics whose name and labels match the provided arguments. If either argument is empty, no matching on that argument is performed. Leaving both arguments empty will call fn on all recorded metrics.

Only metric values recorded in the [startTime, endTime] time period are considered; if there are multiple metric values recorded in the given time period, only the latest value for a given metric is considered. If startTime is zero, it is treated as negative infinity. If endTime is zero, it is treated as the current time.

Callers should assume that metric values passed to fn are ephemeral and only valid during the call.

func (*T) Record

func (s *T) Record(ctx context.Context, m *metrics.MetricSnapshot, time time.Time) error

Record adds an observation for the specified metric.

Jump to

Keyboard shortcuts

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