Skip to content

Commit 924d591

Browse files
committed
Improve WriteToTextfile doc
Signed-off-by: Sevag Hanssian <[email protected]>
1 parent 42e6616 commit 924d591

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

prometheus/registry.go

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -537,9 +537,12 @@ func (r *Registry) Gather() ([]*dto.MetricFamily, error) {
537537
return internal.NormalizeMetricFamilies(metricFamiliesByName), errs.MaybeUnwrap()
538538
}
539539

540-
// WriteToTextfile formats the metrics of the provided Gatherer interface and
541-
// emits them in text format to the path. Intended for use with the node_exporter
542-
// textfile collector
540+
// WriteToTextfile calls Gather on the provided Gatherer, encodes the result in the
541+
// Prometheus text format, and writes it to a temporary file. Upon success, the
542+
// temporary file is renamed to the provided filename.
543+
//
544+
// This is intended for use with the textfile collector of the node exporter.
545+
// Note that the node exporter expects the filename to be suffixed with ".prom".
543546
func WriteToTextfile(filename string, g Gatherer) error {
544547
tmp, err := ioutil.TempFile(filepath.Dir(filename), filepath.Base(filename))
545548
if err != nil {

0 commit comments

Comments
 (0)