stats

package
v1.20.0 Latest Latest
Warning

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

Go to latest
Published: Jul 12, 2023 License: Apache-2.0 Imports: 6 Imported by: 0

Documentation

Overview

Package stats provides the store for measurements associated with agents and configurations.

Index

Constants

View Source
const (
	AgentAttributeName         = "agent"
	ConfigurationAttributeName = "configuration"
	ProcessorAttributeName     = "processor"
	LogDataSizeMetricName      = "otelcol_processor_throughputmeasurement_log_data_size"
	MetricDataSizeMetricName   = "otelcol_processor_throughputmeasurement_metric_data_size"
	TraceDataSizeMetricName    = "otelcol_processor_throughputmeasurement_trace_data_size"
)

Metric Attribute names used for measurements and Metric Names as they come exported with prometheus

Variables

SupportedMetricNames is the list of metrics we care about coming from the self-monitoring of the agent

Functions

func Agent

func Agent(m *record.Metric) string

Agent returns the value of the metric attribute that corresponds to the processor name or "" if the attribute is missing or not a string.

func Configuration

func Configuration(m *record.Metric) string

Configuration returns the value of the metric attribute that corresponds to the configuration name or "" if the attribute is missing or not a string.

func GetDurationFromPeriod

func GetDurationFromPeriod(opts QueryOptions) time.Duration

GetDurationFromPeriod returns the rollup duration for a given query period

func ParseProcessorName

func ParseProcessorName(processorName string) (position string, pipelineType string, name string)

ParseProcessorName parses a processor name like throughputmeasurement/_s0_metrics_source0, returning the position, type, and name of the processor.

func Processor

func Processor(m *record.Metric) string

Processor returns the value of the metric attribute that corresponds to the processor name or "" if the attribute is missing or not a string.

func ProcessorParsed

func ProcessorParsed(m *record.Metric) (position string, pipelineType string, name string)

ProcessorParsed returns the individual parts of the processor name parsed out of the processor attribute

func Value

func Value(m *record.Metric) (value float64, ok bool)

Value returns the value of the metric as a float64

Types

type Measurements

type Measurements interface {
	// Clear clears the store and is mostly used for testing.
	Clear()

	// MeasurementsSize returns the count of keys in the store, and is used only for testing
	MeasurementsSize(context.Context) (int, error)

	// AgentMetrics provides metrics for an individual agents. They are essentially configuration metrics filtered to a
	// list of agents.
	//
	// Note: While the same record.Metric struct is used to return the metrics, these are not the same metrics provided to
	// Store. They will be aggregated and counter metrics will be converted into rates.
	AgentMetrics(ctx context.Context, id []string, options ...QueryOption) (MetricData, error)

	// ConfigurationMetrics provides all metrics associated with a configuration aggregated from all agents using the
	// configuration.
	//
	// Note: While the same record.Metric struct is used to return the metrics, these are not the same metrics provided to
	// Store. They will be aggregated and counter metrics will be converted into rates.
	ConfigurationMetrics(ctx context.Context, name string, options ...QueryOption) (MetricData, error)

	// OverviewMetrics provides all metrics needed for the overview page. This page shows configurations and destinations.
	// The metrics required are the MeasurementPositionDestinationAfterProcessors metric of each configuration which has a
	// processor with the prefix "throughputmeasurement/_d1_"
	OverviewMetrics(ctx context.Context, options ...QueryOption) (MetricData, error)

	// SaveAgentMetrics saves new metrics. These metrics will be aggregated to determine metrics associated with agents and configurations.
	SaveAgentMetrics(ctx context.Context, metrics []*record.Metric) error

	// ProcessMetrics is called in the background at regular intervals and performs metric roll-up and removes old data
	ProcessMetrics(ctx context.Context) error
}

Measurements provides query and storage of time-series metrics associated with agents and configurations.

type MetricData

type MetricData []*record.Metric

MetricData is returned by Measurements when metrics are requested for agents and configurations

type QueryOption

type QueryOption func(*QueryOptions)

QueryOption is an option used in Store queries

func WithPeriod

func WithPeriod(period time.Duration) QueryOption

WithPeriod specifies the period for which the metrics should be returned

type QueryOptions

type QueryOptions struct {
	Period time.Duration
}

QueryOptions represents the set of options available for a measurements query

func MakeQueryOptions

func MakeQueryOptions(options []QueryOption) QueryOptions

MakeQueryOptions constructs a QueryOptions struct from the requested options

type RateMetric

type RateMetric struct {
	Timestamp      time.Time
	StartTimestamp time.Time
	Value          float64
}

RateMetric is a metric that can be used to calculate a rate of change, as the Rate function can be called from locations using pmetrics or pgMeasurements

func Rate

func Rate(first, last RateMetric) (*RateMetric, error)

Rate returns the rate of change of the metric over the time period between the two metrics

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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