From 924d5919f3a0edff4d2479d05e07f9efe5e4d71c Mon Sep 17 00:00:00 2001 From: Sevag Hanssian Date: Fri, 2 Nov 2018 09:31:30 -0700 Subject: [PATCH] Improve WriteToTextfile doc Signed-off-by: Sevag Hanssian --- prometheus/registry.go | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/prometheus/registry.go b/prometheus/registry.go index 99cdc87..0137d35 100644 --- a/prometheus/registry.go +++ b/prometheus/registry.go @@ -537,9 +537,12 @@ func (r *Registry) Gather() ([]*dto.MetricFamily, error) { return internal.NormalizeMetricFamilies(metricFamiliesByName), errs.MaybeUnwrap() } -// WriteToTextfile formats the metrics of the provided Gatherer interface and -// emits them in text format to the path. Intended for use with the node_exporter -// textfile collector +// WriteToTextfile calls Gather on the provided Gatherer, encodes the result in the +// Prometheus text format, and writes it to a temporary file. Upon success, the +// temporary file is renamed to the provided filename. +// +// This is intended for use with the textfile collector of the node exporter. +// Note that the node exporter expects the filename to be suffixed with ".prom". func WriteToTextfile(filename string, g Gatherer) error { tmp, err := ioutil.TempFile(filepath.Dir(filename), filepath.Base(filename)) if err != nil {