Skip to content

Commit 119501e

Browse files
committed
feat: disk cache
1 parent 1c2fd41 commit 119501e

File tree

1 file changed

+11
-6
lines changed

1 file changed

+11
-6
lines changed

cmd/exporters/prometheus/prometheus.go

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -23,12 +23,6 @@ package prometheus
2323

2424
import (
2525
"bytes"
26-
"github.com/netapp/harvest/v2/cmd/poller/exporter"
27-
"github.com/netapp/harvest/v2/cmd/poller/plugin/changelog"
28-
"github.com/netapp/harvest/v2/pkg/errs"
29-
"github.com/netapp/harvest/v2/pkg/matrix"
30-
"github.com/netapp/harvest/v2/pkg/set"
31-
"github.com/netapp/harvest/v2/pkg/slogx"
3226
"log/slog"
3327
"path/filepath"
3428
"regexp"
@@ -37,6 +31,13 @@ import (
3731
"strconv"
3832
"strings"
3933
"time"
34+
35+
"github.com/netapp/harvest/v2/cmd/poller/exporter"
36+
"github.com/netapp/harvest/v2/cmd/poller/plugin/changelog"
37+
"github.com/netapp/harvest/v2/pkg/errs"
38+
"github.com/netapp/harvest/v2/pkg/matrix"
39+
"github.com/netapp/harvest/v2/pkg/set"
40+
"github.com/netapp/harvest/v2/pkg/slogx"
4041
)
4142

4243
// Default parameters
@@ -729,6 +730,10 @@ func (p *Prometheus) render(data *matrix.Matrix) ([][]byte, exporter.Stats) {
729730
}
730731
}
731732

733+
// Both memory and disk cache add a newline character after each metric line
734+
// when serving via HTTP (see writeMetric() and writeToDisk())
735+
renderedBytes += uint64(len(rendered)) // Add 1 byte per line for '\n'
736+
732737
stats := exporter.Stats{
733738
InstancesExported: instancesExported,
734739
MetricsExported: uint64(len(rendered)),

0 commit comments

Comments
 (0)