// RuntimeMetricsToProm produces a Prometheus metric name from a runtime/metrics // metric description and validates whether the metric is suitable for integration // with Prometheus. // // Returns false if a name could not be produced, or if Prometheus does not understand // the runtime/metrics Kind. // // Note that the main reason a name couldn't be produced is if the runtime/metrics // package exports a name with characters outside the valid Prometheus metric name // character set. This is theoretically possible, but should never happen in practice. // Still, don't rely on it. func RuntimeMetricsToProm(d *metrics.Description) (string, string, string, bool) { … } // RuntimeMetricsBucketsForUnit takes a set of buckets obtained for a runtime/metrics histogram // type (so, lower-bound inclusive) and a unit from a runtime/metrics name, and produces // a reduced set of buckets. This function always removes any -Inf bucket as it's represented // as the bottom-most upper-bound inclusive bucket in Prometheus. func RuntimeMetricsBucketsForUnit(buckets []float64, unit string) []float64 { … } // reBucketExp takes a list of bucket boundaries (lower bound inclusive) and // downsamples the buckets to those a multiple of base apart. The end result // is a roughly exponential (in many cases, perfectly exponential) bucketing // scheme. func reBucketExp(buckets []float64, base float64) []float64 { … }