Documentation ¶
Overview ¶
Package state provides the persistent storage layer for the metrics.
Index ¶
- Constants
- func AvgSince(ctx context.Context, db *sql.DB, tableName string, name string, ...) (float64, error)
- func CreateTableMetrics(ctx context.Context, db *sql.DB, tableName string) error
- func EMASince(ctx context.Context, db *sql.DB, tableName string, name string, ...) (float64, error)
- func InsertMetric(ctx context.Context, db *sql.DB, tableName string, metric Metric) error
- func PurgeMetrics(ctx context.Context, db *sql.DB, tableName string, before time.Time) (int, error)
- type Metric
- type Metrics
Constants ¶
View Source
const ( ColumnUnixSeconds = "unix_seconds" ColumnMetricName = "metric_name" ColumnMetricSecondaryName = "metric_secondary_name" ColumnMetricValue = "metric_value" )
View Source
const DefaultTableName = "components_metrics"
Variables ¶
This section is empty.
Functions ¶
func AvgSince ¶
func AvgSince(ctx context.Context, db *sql.DB, tableName string, name string, secondaryName string, since time.Time) (float64, error)
Computes the average of the last metrics. If the since is zero, all metrics are used. Returns zero if no record is found ("database/sql.ErrNoRows").
func CreateTableMetrics ¶ added in v0.1.6
func EMASince ¶
func EMASince(ctx context.Context, db *sql.DB, tableName string, name string, secondaryName string, period time.Duration, since time.Time) (float64, error)
EMASince calculates the Exponential Moving Average since a given time
func InsertMetric ¶ added in v0.1.6
Types ¶
Click to show internal directories.
Click to hide internal directories.