Documentation
¶
Overview ¶
Package utils contains shared helpers for metric construction and constants.
Index ¶
Constants ¶
View Source
const ( // DefaultScrapeInterval is the default scrape interval for the collectors. DefaultScrapeInterval = 1 * time.Hour // HoursInMonth is an approximate average number of hours in a month. // 24.35 is the average number of hours per day over a year. HoursInMonth = 24.35 * 30 // InstanceCPUCostSuffix is the suffix for per-core-hour CPU cost metrics. InstanceCPUCostSuffix = "instance_cpu_usd_per_core_hour" // InstanceMemoryCostSuffix is the suffix for per-GiB-hour memory cost metrics. InstanceMemoryCostSuffix = "instance_memory_usd_per_gib_hour" // InstanceTotalCostSuffix is the suffix for total per-hour instance cost metrics. InstanceTotalCostSuffix = "instance_total_usd_per_hour" // PersistentVolumeCostSuffix is the suffix for per-hour EBS volume cost metrics. PersistentVolumeCostSuffix = "persistent_volume_usd_per_hour" // Used for Azure persistent volumes following AWS naming pattern. PersistentVolumeCostPerGiBSuffix = "persistent_volume_usd_per_gib_hour" )
Variables ¶
This section is empty.
Functions ¶
func GenerateDesc ¶ added in v0.6.0
func GenerateDesc(prefix, subsystem, suffix, description string, labels []string) *prometheus.Desc
GenerateDesc creates a Prometheus metric descriptor with a standardized fqname.
func Retry ¶ added in v0.13.0
func Retry(attempts int, initialDelay, maxDelay time.Duration, retryIf func(error) bool, op func() error) error
Retry runs op up to attempts times, sleeping with exponential backoff between retries when op returns a non-nil error and retryIf(err) returns true. The delay grows as: initialDelay * 2^attempt, capped at maxDelay. If attempts <= 0, it defaults to 1 (no retries).
Types ¶
type MetricResult ¶
type MetricResult struct {
FqName string
Labels LabelMap
Value float64
MetricType prometheus.ValueType
}
func ReadMetrics ¶
func ReadMetrics(metric prometheus.Metric) *MetricResult
Click to show internal directories.
Click to hide internal directories.