mirror of
https://github.com/pomerium/pomerium.git
synced 2025-08-02 16:30:17 +02:00
core/metrics: improve memory usage (#5364)
This commit is contained in:
parent
1a448708fa
commit
699679bc57
9 changed files with 3978 additions and 101 deletions
30
internal/telemetry/prometheus/export.go
Normal file
30
internal/telemetry/prometheus/export.go
Normal file
|
@ -0,0 +1,30 @@
|
|||
package prometheus
|
||||
|
||||
import (
|
||||
"io"
|
||||
"iter"
|
||||
|
||||
dto "github.com/prometheus/client_model/go"
|
||||
"github.com/prometheus/common/expfmt"
|
||||
)
|
||||
|
||||
// Export writes the metric families to the writer in text format
|
||||
func Export(
|
||||
w io.Writer,
|
||||
src iter.Seq2[*dto.MetricFamily, error],
|
||||
) error {
|
||||
for mf, err := range src {
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
if err := exportMetricFamily(w, mf); err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func exportMetricFamily(w io.Writer, mf *dto.MetricFamily) error {
|
||||
_, err := expfmt.MetricFamilyToText(w, mf)
|
||||
return err
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue