package expfmt

Import Path
	github.com/prometheus/common/expfmt (on go.dev)

Dependency Relation
	imports 16 packages, and imported by 2 packages

Involved Source Files decode.go encode.go Package expfmt contains tools for reading and writing Prometheus metrics. text_create.go text_parse.go
Package-Level Type Names (total 12, in which 7 are exported)
/* sort exporteds by: | */
DecodeOptions contains options used by the Decoder and in sample extraction. Timestamp is added to each value from the stream that has no explicit timestamp set. func ExtractSamples(o *DecodeOptions, fams ...*dto.MetricFamily) (model.Vector, error)
Decoder types decode an input stream into metric families. ( T) Decode(*dto.MetricFamily) error func NewDecoder(r io.Reader, format Format) Decoder
Encoder types encode metric families into an underlying wire protocol. ( T) Encode(*dto.MetricFamily) error func NewEncoder(w io.Writer, format Format) Encoder
Format specifies the HTTP content type of the different wire protocols. func Negotiate(h http.Header) Format func ResponseFormat(h http.Header) Format func NewDecoder(r io.Reader, format Format) Decoder func NewEncoder(w io.Writer, format Format) Encoder const FmtProtoCompact const FmtProtoDelim const FmtProtoText const FmtText const FmtUnknown
ParseError signals errors while parsing the simple and flat text-based exchange format. Line int Msg string Error implements the error interface. T : error
SampleDecoder wraps a Decoder to extract samples from the metric families decoded by the wrapped Decoder. Dec Decoder Opts *DecodeOptions Decode calls the Decode method of the wrapped Decoder and then extracts the samples from the decoded MetricFamily into the provided model.Vector.
TextParser is used to parse the simple and flat text-based exchange format. Its zero value is ready to use. TextToMetricFamilies reads 'in' as the simple and flat text-based exchange format and creates MetricFamily proto messages. It returns the MetricFamily proto messages in a map where the metric names are the keys, along with any error encountered. If the input contains duplicate metrics (i.e. lines with the same metric name and exactly the same label set), the resulting MetricFamily will contain duplicate Metric proto messages. Similar is true for duplicate label names. Checks for duplicates have to be performed separately, if required. Also note that neither the metrics within each MetricFamily are sorted nor the label pairs within each Metric. Sorting is not required for the most frequent use of this method, which is sample ingestion in the Prometheus server. However, for presentation purposes, you might want to sort the metrics, and in some cases, you must sort the labels, e.g. for consumption by the metric family injection hook of the Prometheus registry. Summaries and histograms are rather special beasts. You would probably not use them in the simple text format anyway. This method can deal with summaries and histograms if they are presented in exactly the way the text.Create function creates them. This method must not be called concurrently. If you want to parse different input concurrently, instantiate a separate Parser for each goroutine.
Package-Level Functions (total 28, in which 6 are exported)
ExtractSamples builds a slice of samples from the provided metric families. If an error occurrs during sample extraction, it continues to extract from the remaining metric families. The returned error is the last error that has occurred.
MetricFamilyToText converts a MetricFamily proto message into text format and writes the resulting lines to 'out'. It returns the number of bytes written and any error encountered. The output will have the same order as the input, no further sorting is performed. Furthermore, this function assumes the input is already sanitized and does not perform any sanity checks. If the input contains duplicate metrics or invalid metric or label names, the conversion will result in invalid text format output. This method fulfills the type 'prometheus.encoder'.
Negotiate returns the Content-Type based on the given Accept header. If no appropriate accepted type is found, FmtText is returned.
NewDecoder returns a new decoder based on the given input format. If the input format does not imply otherwise, a text format decoder is returned.
NewEncoder returns a new encoder based on content type negotiation.
ResponseFormat extracts the correct format from a HTTP response header. If no matching format can be found FormatUnknown is returned.
Package-Level Variables (total 4, none are exported)
Package-Level Constants (total 12, in which 9 are exported)
Constants to assemble the Content-Type values for the different wire protocols.
Constants to assemble the Content-Type values for the different wire protocols.
Constants to assemble the Content-Type values for the different wire protocols.
Constants to assemble the Content-Type values for the different wire protocols.
The Content-Type values for the different wire protocols.
Constants to assemble the Content-Type values for the different wire protocols.
Constants to assemble the Content-Type values for the different wire protocols.
Constants to assemble the Content-Type values for the different wire protocols.
Constants to assemble the Content-Type values for the different wire protocols.