Documentation ¶
Index ¶
- Constants
- Variables
- type Dimensions
- type Metric
- func NewCount(timestamp time.Time, name string, value float64) (Metric, error)
- func NewCumulativeCount(timestamp time.Time, name string, value float64) (Metric, error)
- func NewCumulativeRate(timestamp time.Time, name string, value float64) (Metric, error)
- func NewGauge(timestamp time.Time, name string, value float64) (Metric, error)
- func NewRate(timestamp time.Time, name string, value float64) (Metric, error)
- func NewSummary(timestamp time.Time, name string, count float64, average float64, sum float64, ...) (Metric, error)
- type Metrics
- type PrometheusHistogram
- type PrometheusHistogramValue
- type PrometheusSummary
- type PrometheusSummaryValue
- type SourceType
Constants ¶
const ( // GAUGE is a value that may increase and decrease. // It generally represents the value for something at a particular moment in time GAUGE SourceType = iota // COUNT counts the number of times an event occurred since the last time it was retrieved (time window). // It's values can go up or down COUNT SourceType = iota // SUMMARY is a composite value with avg, min, max sample count and sum SUMMARY SourceType = iota // CUMULATIVE_COUNT counts the number of times an event occurred. It is not a delta, but an absolute value. // It's value should either be the same or go up, never down CUMULATIVE_COUNT = iota // RATE represents a rate of change of a value in a specific time window RATE = iota // CUMULATIVE_RATE represents an ever-increasing rate of change. CUMULATIVE_RATE = iota // PROMETHEUS_HISTROGRAM is a histogram as defined by Prometheus PROMETHEUS_HISTOGRAM SourceType = iota // PROMETHEUS_SUMMARY is a summaru as defined by Prometheus PROMETHEUS_SUMMARY SourceType = iota )
Source types If any more SourceTypes are added update maps: SourcesTypeToName & SourcesNameToType.
Variables ¶
var SourcesNameToType = map[string]SourceType{ "gauge": GAUGE, "count": COUNT, "summary": SUMMARY, "cumulative-count": CUMULATIVE_COUNT, "rate": RATE, "cumulative-rate": CUMULATIVE_RATE, "prometheus-histogram": PROMETHEUS_HISTOGRAM, "prometheus-summary": PROMETHEUS_SUMMARY, }
SourcesNameToType metric sources list mapping its name to type.
var SourcesTypeToName = map[SourceType]string{ GAUGE: "gauge", COUNT: "count", SUMMARY: "summary", CUMULATIVE_COUNT: "cumulative-count", RATE: "rate", CUMULATIVE_RATE: "cumulative-rate", PROMETHEUS_HISTOGRAM: "prometheus-histogram", PROMETHEUS_SUMMARY: "prometheus-summary", }
SourcesTypeToName metric sources list mapping its type to readable name.
Functions ¶
This section is empty.
Types ¶
type Metric ¶
type Metric interface { AddDimension(key string, value string) error Dimension(key string) string GetDimensions() Dimensions }
Metric is the common interface for all metric types
func NewCumulativeCount ¶
NewCumulativeCount creates a new metric of type cumulative count
func NewCumulativeRate ¶
NewCumulativeRate creates a new metric of type cumulative rate
type PrometheusHistogram ¶
type PrometheusHistogram struct { Value PrometheusHistogramValue `json:"value,omitempty"` // contains filtered or unexported fields }
PrometheusHistogram represents a Prometheus histogram
func NewPrometheusHistogram ¶
func NewPrometheusHistogram(timestamp time.Time, name string, sampleCount uint64, sampleSum float64) (*PrometheusHistogram, error)
NewPrometheusHistogram creates a new metric structurally similar to a Prometheus histogram
func (*PrometheusHistogram) AddBucket ¶
func (ph *PrometheusHistogram) AddBucket(cumulativeCount uint64, upperBound float64)
AddBucket adds a new bucket to the histogram. Note that no attempt is made to keep buckets ordered, it's on the caller to guarantee the buckets are added in the correct order.
func (*PrometheusHistogram) AddDimension ¶
AddDimension adds a dimension to the metric instance
func (*PrometheusHistogram) GetDimensions ¶
func (m *PrometheusHistogram) GetDimensions() Dimensions
GetDimensions gets all the dimensions
type PrometheusHistogramValue ¶
type PrometheusHistogramValue struct { SampleCount *uint64 `json:"sample_count,omitempty"` SampleSum *float64 `json:"sample_sum,omitempty"` // Buckets defines the buckets into which observations are counted. Each // element in the slice is the upper inclusive bound of a bucket. The // values must are sorted in strictly increasing order. Buckets []*bucket `json:"buckets,omitempty"` }
PrometheusHistogramValue represents the Value type for a Prometheus histogram.
type PrometheusSummary ¶
type PrometheusSummary struct { Value PrometheusSummaryValue `json:"value,omitempty"` // contains filtered or unexported fields }
PrometheusSummary represents a Prometheus summary
func NewPrometheusSummary ¶
func NewPrometheusSummary(timestamp time.Time, name string, sampleCount uint64, sampleSum float64) (*PrometheusSummary, error)
NewPrometheusSummary creates a new metric structurally similar to a Prometheus summary
func (*PrometheusSummary) AddDimension ¶
AddDimension adds a dimension to the metric instance
func (*PrometheusSummary) AddQuantile ¶
func (ps *PrometheusSummary) AddQuantile(quant float64, value float64)
AddQuantile adds a new quantile to the summary.
func (*PrometheusSummary) GetDimensions ¶
func (m *PrometheusSummary) GetDimensions() Dimensions
GetDimensions gets all the dimensions
type PrometheusSummaryValue ¶
type PrometheusSummaryValue struct { SampleCount *uint64 `json:"sample_count,omitempty"` SampleSum *float64 `json:"sample_sum,omitempty"` Quantiles []*quantile `json:"quantiles,omitempty"` }
PrometheusSummaryValue represents the Value type for a Prometheus summary.
type SourceType ¶
type SourceType int
SourceType defines the kind of data source. Based on this SourceType, metric package performs some calculations with it. Check below the description for each one.
func SourceTypeForName ¶
func SourceTypeForName(sourceTypeTag string) (SourceType, error)
SourceTypeForName does a case insensitive conversion from a string to a SourceType. An error will be returned if no valid SourceType matched.
func (SourceType) String ¶
func (t SourceType) String() string
String fulfills stringer interface, returning empty string on invalid source types.