type Encoder … type Closer … type encoderCloser … func (ec encoderCloser) Encode(v *dto.MetricFamily) error { … } func (ec encoderCloser) Close() error { … } // Negotiate returns the Content-Type based on the given Accept header. If no // appropriate accepted type is found, FmtText is returned (which is the // Prometheus text format). This function will never negotiate FmtOpenMetrics, // as the support is still experimental. To include the option to negotiate // FmtOpenMetrics, use NegotiateOpenMetrics. func Negotiate(h http.Header) Format { … } // NegotiateIncludingOpenMetrics works like Negotiate but includes // FmtOpenMetrics as an option for the result. Note that this function is // temporary and will disappear once FmtOpenMetrics is fully supported and as // such may be negotiated by the normal Negotiate function. func NegotiateIncludingOpenMetrics(h http.Header) Format { … } // NewEncoder returns a new encoder based on content type negotiation. All // Encoder implementations returned by NewEncoder also implement Closer, and // callers should always call the Close method. It is currently only required // for FmtOpenMetrics, but a future (breaking) release will add the Close method // to the Encoder interface directly. The current version of the Encoder // interface is kept for backwards compatibility. // In cases where the Format does not allow for UTF-8 names, the global // NameEscapingScheme will be applied. // // 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 { … }