@@ -84,7 +84,7 @@ func ResponseFormat(h http.Header) Format {
8484
8585// NewDecoder returns a new decoder based on the given input format. Metric
8686// names are validated based on the provided Format -- if the format requires
87- // escaping, raditional Prometheues validity checking is used. Otherwise, names
87+ // escaping, traditional Prometheus validity checking is used. Otherwise, names
8888// are checked for UTF-8 validity. Supported formats include delimited protobuf
8989// and the Prometheus/OpenMetrics text formats. For historical reasons, this
9090// decoder fallbacks to classic text decoding for any other format. This decoder
@@ -100,7 +100,7 @@ func NewDecoder(r io.Reader, format Format) Decoder {
100100 case TypeProtoDelim :
101101 return & protoDecoder {r : bufio .NewReader (r ), s : scheme }
102102 case TypeOpenMetrics :
103- return & openMetricsDecoder {r : r }
103+ return & openMetricsDecoder {r : r , s : scheme }
104104 case TypeProtoText , TypeProtoCompact :
105105 return & errDecoder {err : fmt .Errorf ("format %s not supported for decoding" , format )}
106106 }
@@ -156,14 +156,15 @@ func (d *errDecoder) Decode(*dto.MetricFamily) error {
156156type openMetricsDecoder struct {
157157 r io.Reader
158158 fams map [string ]* dto.MetricFamily
159+ s model.ValidationScheme
159160 err error
160161}
161162
162163// Decode implements the Decoder interface.
163164func (d * openMetricsDecoder ) Decode (mf * dto.MetricFamily ) error {
164165 if d .err == nil {
165166 // Read all metrics in one shot.
166- var p OpenMetricsParser
167+ p := OpenMetricsParser { scheme : d . s }
167168 d .fams , d .err = p .OpenMetricsToMetricFamilies (d .r )
168169 // If we don't get an error, store io.EOF for the end.
169170 if d .err == nil {
0 commit comments