@@ -76,18 +76,18 @@ func Negotiate(h http.Header) Format {
76
76
if ac .Type + "/" + ac .SubType == ProtoType && ac .Params ["proto" ] == ProtoProtocol {
77
77
switch ac .Params ["encoding" ] {
78
78
case "delimited" :
79
- return FmtProtoDelim + escapingScheme
79
+ return fmtProtoDelim + escapingScheme
80
80
case "text" :
81
- return FmtProtoText + escapingScheme
81
+ return fmtProtoText + escapingScheme
82
82
case "compact-text" :
83
- return FmtProtoCompact + escapingScheme
83
+ return fmtProtoCompact + escapingScheme
84
84
}
85
85
}
86
86
if ac .Type == "text" && ac .SubType == "plain" && (ver == TextVersion || ver == "" ) {
87
- return FmtText + escapingScheme
87
+ return fmtText + escapingScheme
88
88
}
89
89
}
90
- return FmtText + escapingScheme
90
+ return fmtText + escapingScheme
91
91
}
92
92
93
93
// NegotiateIncludingOpenMetrics works like Negotiate but includes
@@ -109,26 +109,26 @@ func NegotiateIncludingOpenMetrics(h http.Header) Format {
109
109
if ac .Type + "/" + ac .SubType == ProtoType && ac .Params ["proto" ] == ProtoProtocol {
110
110
switch ac .Params ["encoding" ] {
111
111
case "delimited" :
112
- return FmtProtoDelim + escapingScheme
112
+ return fmtProtoDelim + escapingScheme
113
113
case "text" :
114
- return FmtProtoText + escapingScheme
114
+ return fmtProtoText + escapingScheme
115
115
case "compact-text" :
116
- return FmtProtoCompact + escapingScheme
116
+ return fmtProtoCompact + escapingScheme
117
117
}
118
118
}
119
119
if ac .Type == "text" && ac .SubType == "plain" && (ver == TextVersion || ver == "" ) {
120
- return FmtText + escapingScheme
120
+ return fmtText + escapingScheme
121
121
}
122
122
if ac .Type + "/" + ac .SubType == OpenMetricsType && (ver == OpenMetricsVersion_0_0_1 || ver == OpenMetricsVersion_1_0_0 || ver == "" ) {
123
123
switch ver {
124
124
case OpenMetricsVersion_1_0_0 :
125
- return FmtOpenMetrics_1_0_0 + escapingScheme
125
+ return fmtOpenMetrics_1_0_0 + escapingScheme
126
126
default :
127
- return FmtOpenMetrics_0_0_1 + escapingScheme
127
+ return fmtOpenMetrics_0_0_1 + escapingScheme
128
128
}
129
129
}
130
130
}
131
- return FmtText + escapingScheme
131
+ return fmtText + escapingScheme
132
132
}
133
133
134
134
// NewEncoder returns a new encoder based on content type negotiation. All
@@ -139,7 +139,13 @@ func NegotiateIncludingOpenMetrics(h http.Header) Format {
139
139
// interface is kept for backwards compatibility.
140
140
// In cases where the Format does not allow for UTF-8 names, the global
141
141
// NameEscapingScheme will be applied.
142
- func NewEncoder (w io.Writer , format Format , options ... ToOpenMetricsOption ) Encoder {
142
+ //
143
+ // NewEncoder can be called with additional options to customize the OpenMetrics text output.
144
+ // For example:
145
+ // NewEncoder(w, FmtOpenMetrics_1_0_0, WithCreatedLines())
146
+ //
147
+ // Extra options are ignored for all other formats.
148
+ func NewEncoder (w io.Writer , format Format , options ... EncoderOption ) Encoder {
143
149
escapingScheme := format .ToEscapingScheme ()
144
150
145
151
switch format .FormatType () {
@@ -178,7 +184,7 @@ func NewEncoder(w io.Writer, format Format, options ...ToOpenMetricsOption) Enco
178
184
case TypeOpenMetrics :
179
185
return encoderCloser {
180
186
encode : func (v * dto.MetricFamily ) error {
181
- _ , err := MetricFamilyToOpenMetrics (w , model .EscapeMetricFamily (v , escapingScheme ), options ... )
187
+ _ , err := MetricFamilyToOpenMetrics (w , model .EscapeMetricFamily (v , escapingScheme )) // , options...?
182
188
return err
183
189
},
184
190
close : func () error {
0 commit comments