summaryrefslogtreecommitdiff
path: root/vendor/github.com/prometheus/common/expfmt/encode.go
diff options
context:
space:
mode:
authorLibravatar dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>2024-08-19 10:13:46 +0000
committerLibravatar GitHub <noreply@github.com>2024-08-19 10:13:46 +0000
commit6ff8376d96f094daacf62decf2ee7ff602c2d531 (patch)
tree0b0ad45951ef1aae841384fd550e01b44f4cba76 /vendor/github.com/prometheus/common/expfmt/encode.go
parent[bugfix] permit unspecified orientation data (#3205) (diff)
downloadgotosocial-6ff8376d96f094daacf62decf2ee7ff602c2d531.tar.xz
[chore]: Bump github.com/prometheus/client_golang from 1.19.1 to 1.20.0 (#3210)
Diffstat (limited to 'vendor/github.com/prometheus/common/expfmt/encode.go')
-rw-r--r--vendor/github.com/prometheus/common/expfmt/encode.go13
1 files changed, 10 insertions, 3 deletions
diff --git a/vendor/github.com/prometheus/common/expfmt/encode.go b/vendor/github.com/prometheus/common/expfmt/encode.go
index 8fd806184..ff5ef7a9d 100644
--- a/vendor/github.com/prometheus/common/expfmt/encode.go
+++ b/vendor/github.com/prometheus/common/expfmt/encode.go
@@ -21,9 +21,10 @@ import (
"google.golang.org/protobuf/encoding/protodelim"
"google.golang.org/protobuf/encoding/prototext"
- "github.com/prometheus/common/internal/bitbucket.org/ww/goautoneg"
"github.com/prometheus/common/model"
+ "github.com/munnerz/goautoneg"
+
dto "github.com/prometheus/client_model/go"
)
@@ -139,7 +140,13 @@ func NegotiateIncludingOpenMetrics(h http.Header) Format {
// interface is kept for backwards compatibility.
// In cases where the Format does not allow for UTF-8 names, the global
// NameEscapingScheme will be applied.
-func NewEncoder(w io.Writer, format Format) Encoder {
+//
+// NewEncoder can be called with additional options to customize the OpenMetrics text output.
+// For example:
+// NewEncoder(w, FmtOpenMetrics_1_0_0, WithCreatedLines())
+//
+// Extra options are ignored for all other formats.
+func NewEncoder(w io.Writer, format Format, options ...EncoderOption) Encoder {
escapingScheme := format.ToEscapingScheme()
switch format.FormatType() {
@@ -178,7 +185,7 @@ func NewEncoder(w io.Writer, format Format) Encoder {
case TypeOpenMetrics:
return encoderCloser{
encode: func(v *dto.MetricFamily) error {
- _, err := MetricFamilyToOpenMetrics(w, model.EscapeMetricFamily(v, escapingScheme))
+ _, err := MetricFamilyToOpenMetrics(w, model.EscapeMetricFamily(v, escapingScheme), options...)
return err
},
close: func() error {