metricgenerator

package
v0.0.0-...-77fd705 Latest Latest
Warning

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

Go to latest
Published: Sep 8, 2023 License: Apache-2.0 Imports: 4 Imported by: 0

Documentation

Overview

Package metricgenerator provides utility functions intended to be used by metric receivers the generate metrics rather taking in existing metrics from an external source.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func FormatBucketOptions

func FormatBucketOptions(bounds []float64) *metricspb.DistributionValue_BucketOptions

FormatBucketOptions formats a []float64 bounds as a DistributionValue_BucketOptions proto. bounds should list the upper boundaries of the distribution buckets, except for the last bucket which has +infinity as an implied upper bound.

func GetSumOfSquaredDeviationsFromIntDist

func GetSumOfSquaredDeviationsFromIntDist(sum, sumSquares, count int64) float64

GetSumOfSquaredDeviationsFromIntDist calculates the sum of squared deviations from the mean. For values x_i this is: Sum[i=1..n]((x_i - mean)^2) Calculated from the count, sum, and sum of squares of the values.

func MakeBuckets

func MakeBuckets(values, bounds []float64) []*metricspb.DistributionValue_Bucket

MakeBuckets generates a proto representation of a distribution containing a single value. bounds defines the bucket boundaries of the distribution.

func MakeDistributionTimeSeries

func MakeDistributionTimeSeries(
	distribution []int64,
	sum float64,
	sumSquaredDeviation float64,
	count int64,
	startTime, currentTime time.Time,
	bucketOptions *metricspb.DistributionValue_BucketOptions,
	labels []*metricspb.LabelValue) *metricspb.TimeSeries

MakeDistributionTimeSeries formats a distribution and its metadata as a TimeSeries.

func MakeDoubleTimeSeries

func MakeDoubleTimeSeries(val float64, startTime, now time.Time, labels []*metricspb.LabelValue) *metricspb.TimeSeries

MakeDoubleTimeSeries generates a proto representation of a timeseries containing a single point for an double metric.

func MakeExponentialBucketOptions

func MakeExponentialBucketOptions(boundsBase, maxExponent float64) *metricspb.DistributionValue_BucketOptions

MakeExponentialBucketOptions generates a proto representation of a config which, defines a distribution's bounds. This defines maxExponent + 2 buckets. The boundaries for bucket index i are:

[0, boundsBase ^ i) for i == 0 [boundsBase ^ (i - 1)], boundsBase ^ i) for 0 < i <= maxExponent [boundsBase ^ (i - 1), +infinity) for i == maxExponent + 1

func MakeInt64TimeSeries

func MakeInt64TimeSeries(val int64, startTime, now time.Time, labels []*metricspb.LabelValue) *metricspb.TimeSeries

MakeInt64TimeSeries generates a proto representation of a timeseries containing a single point for an int64 metric.

func MakeLabelValue

func MakeLabelValue(value string) *metricspb.LabelValue

MakeLabelValue generates a proto representation of a metric label with value as its value.

func MakeSingleValueDistributionTimeSeries

func MakeSingleValueDistributionTimeSeries(
	val float64,
	startTime, currentTime time.Time,
	bucketOptions *metricspb.DistributionValue_BucketOptions,
	labels []*metricspb.LabelValue) *metricspb.TimeSeries

MakeSingleValueDistributionTimeSeries generates a proto representation of a timeseries containing a single point consisting of a distribution containing a single value. The distribution bucket bounds are defined by the bucketOptions argument.

Types

This section is empty.

Jump to

Keyboard shortcuts

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