package expfmt
Import Path
github.com/prometheus/common/expfmt (on go.dev)
Dependency Relation
imports 19 packages, and imported by 2 packages
Involved Source Files
decode.go
encode.go
Package expfmt contains tools for reading and writing Prometheus metrics.
openmetrics_create.go
text_create.go
text_parse.go
Package-Level Type Names (total 10)
Closer is implemented by Encoders that need to be closed to finalize
encoding. (For example, OpenMetrics needs a final `# EOF` line.)
Note that all Encoder implementations returned from this package implement
Closer, too, even if the Close call is a no-op. This happens in preparation
for adding a Close method to the Encoder interface directly in a (mildly
breaking) release in the future.
( Closer) Close() error
*github.com/andybalholm/brotli.Writer
*github.com/andybalholm/brotli/matchfinder.Writer
*github.com/apache/arrow-go/v18/arrow/ipc.FileReader
*github.com/apache/arrow-go/v18/arrow/ipc.FileWriter
github.com/apache/arrow-go/v18/arrow/ipc.PayloadWriter (interface)
*github.com/apache/arrow-go/v18/arrow/ipc.Writer
github.com/apache/thrift/lib/go/thrift.RichTransport
*github.com/apache/thrift/lib/go/thrift.StreamTransport
*github.com/apache/thrift/lib/go/thrift.TBufferedTransport
*github.com/apache/thrift/lib/go/thrift.TFramedTransport
*github.com/apache/thrift/lib/go/thrift.THeaderTransport
*github.com/apache/thrift/lib/go/thrift.THttpClient
*github.com/apache/thrift/lib/go/thrift.TMemoryBuffer
*github.com/apache/thrift/lib/go/thrift.TransformReader
*github.com/apache/thrift/lib/go/thrift.TransformWriter
*github.com/apache/thrift/lib/go/thrift.TServerSocket
github.com/apache/thrift/lib/go/thrift.TServerTransport (interface)
*github.com/apache/thrift/lib/go/thrift.TSocket
*github.com/apache/thrift/lib/go/thrift.TSSLServerSocket
*github.com/apache/thrift/lib/go/thrift.TSSLSocket
github.com/apache/thrift/lib/go/thrift.TTransport (interface)
*github.com/apache/thrift/lib/go/thrift.TZlibTransport
*github.com/cenkalti/rpc2.Client
github.com/cenkalti/rpc2.Codec (interface)
*github.com/chromedp/chromedp.Conn
github.com/chromedp/chromedp.Transport (interface)
github.com/coreos/etcd/pkg/fileutil.LockedFile
*github.com/fsnotify/fsnotify.Watcher
github.com/gdamore/tcell/v2.Tty (interface)
*github.com/gliderlabs/ssh.Server
github.com/gliderlabs/ssh.Session (interface)
*github.com/golang/snappy.Writer
*github.com/gorilla/websocket.Conn
*github.com/hamba/avro/v2/ocf.Encoder
*github.com/hibiken/asynq.Client
*github.com/hibiken/asynq.Inspector
github.com/hibiken/asynq/internal/base.Broker (interface)
*github.com/hibiken/asynq/internal/rdb.RDB
*github.com/huin/goupnp/httpu.HTTPUClient
*github.com/ipfs/go-log/v2.PipeReader
*github.com/klauspost/compress/flate.Writer
*github.com/klauspost/compress/gzip.Reader
*github.com/klauspost/compress/gzip.Writer
*github.com/klauspost/compress/internal/snapref.Writer
*github.com/klauspost/compress/s2.Writer
*github.com/klauspost/compress/zstd.Encoder
*github.com/koron/go-ssdp.Advertiser
*github.com/koron/go-ssdp.Monitor
*github.com/koron/go-ssdp/internal/multicast.Conn
*github.com/libp2p/go-buffer-pool.Writer
github.com/libp2p/go-libp2p/core/connmgr.ConnManager (interface)
github.com/libp2p/go-libp2p/core/connmgr.Decayer (interface)
github.com/libp2p/go-libp2p/core/connmgr.DecayingTag (interface)
github.com/libp2p/go-libp2p/core/connmgr.NullConnMgr
github.com/libp2p/go-libp2p/core/event.Emitter (interface)
github.com/libp2p/go-libp2p/core/event.Subscription (interface)
github.com/libp2p/go-libp2p/core/host.Host (interface)
github.com/libp2p/go-libp2p/core/network.Conn (interface)
github.com/libp2p/go-libp2p/core/network.MuxedConn (interface)
github.com/libp2p/go-libp2p/core/network.MuxedStream (interface)
github.com/libp2p/go-libp2p/core/network.Network (interface)
*github.com/libp2p/go-libp2p/core/network.NullResourceManager
github.com/libp2p/go-libp2p/core/network.ResourceManager (interface)
github.com/libp2p/go-libp2p/core/network.Stream (interface)
github.com/libp2p/go-libp2p/core/peerstore.Peerstore (interface)
github.com/libp2p/go-libp2p/core/sec.SecureConn (interface)
github.com/libp2p/go-libp2p/core/sec/insecure.Conn
github.com/libp2p/go-libp2p/core/transport.CapableConn (interface)
github.com/libp2p/go-libp2p/core/transport.GatedMaListener (interface)
github.com/libp2p/go-libp2p/core/transport.Listener (interface)
github.com/libp2p/go-libp2p/core/transport.TransportNetwork (interface)
*github.com/libp2p/go-libp2p/p2p/host/autonat.AmbientAutoNAT
github.com/libp2p/go-libp2p/p2p/host/autonat.AutoNAT (interface)
*github.com/libp2p/go-libp2p/p2p/host/autonat.StaticAutoNAT
*github.com/libp2p/go-libp2p/p2p/host/autorelay.AutoRelay
*github.com/libp2p/go-libp2p/p2p/host/basic.BasicHost
github.com/libp2p/go-libp2p/p2p/host/basic.NATManager (interface)
*github.com/libp2p/go-libp2p/p2p/host/blank.BlankHost
*github.com/libp2p/go-libp2p/p2p/host/pstoremanager.PeerstoreManager
*github.com/libp2p/go-libp2p/p2p/host/relaysvc.RelayManager
*github.com/libp2p/go-libp2p/p2p/host/routed.RoutedHost
*github.com/libp2p/go-libp2p/p2p/net/connmgr.BasicConnMgr
*github.com/libp2p/go-libp2p/p2p/net/nat.NAT
*github.com/libp2p/go-libp2p/p2p/net/swarm.Conn
*github.com/libp2p/go-libp2p/p2p/net/swarm.Stream
*github.com/libp2p/go-libp2p/p2p/net/swarm.Swarm
*github.com/libp2p/go-libp2p/p2p/protocol/circuitv2/client.Client
*github.com/libp2p/go-libp2p/p2p/protocol/circuitv2/client.Conn
*github.com/libp2p/go-libp2p/p2p/protocol/circuitv2/client.Listener
*github.com/libp2p/go-libp2p/p2p/protocol/circuitv2/relay.Relay
*github.com/libp2p/go-libp2p/p2p/protocol/holepunch.Service
github.com/libp2p/go-libp2p/p2p/protocol/identify.IDService (interface)
*github.com/libp2p/go-libp2p/p2p/protocol/identify.ObservedAddrManager
*github.com/libp2p/go-libp2p/p2p/transport/quicreuse.ConnManager
github.com/libp2p/go-libp2p/p2p/transport/quicreuse.Listener (interface)
github.com/libp2p/go-libp2p/p2p/transport/quicreuse.QUICListener (interface)
github.com/libp2p/go-libp2p/p2p/transport/quicreuse.QUICTransport (interface)
github.com/libp2p/go-libp2p/p2p/transport/quicreuse.RefCountedQUICTransport (interface)
github.com/libp2p/go-libp2p/p2p/transport/tcpreuse/internal/sampledconn.ManetTCPConnInterface (interface)
*github.com/libp2p/go-libp2p/p2p/transport/webrtc/udpmux.UDPMux
*github.com/libp2p/go-libp2p/p2p/transport/websocket.Conn
*github.com/libp2p/go-libp2p-pubsub.Topic
github.com/libp2p/go-msgio.ReadCloser (interface)
github.com/libp2p/go-msgio.ReadWriteCloser (interface)
github.com/libp2p/go-msgio.WriteCloser (interface)
github.com/libp2p/go-msgio/pbio.ReadCloser (interface)
github.com/libp2p/go-msgio/pbio.WriteCloser (interface)
github.com/libp2p/go-msgio/protoio.ReadCloser (interface)
github.com/libp2p/go-msgio/protoio.WriteCloser (interface)
*github.com/libp2p/go-yamux/v5.Session
*github.com/libp2p/go-yamux/v5.Stream
github.com/marten-seemann/tcp.Conn
github.com/miekg/dns.Conn
github.com/miekg/dns.ResponseWriter (interface)
github.com/miekg/dns.Transfer
github.com/multiformats/go-multiaddr/net.Conn (interface)
github.com/multiformats/go-multiaddr/net.Listener (interface)
github.com/multiformats/go-multiaddr/net.PacketConn (interface)
github.com/multiformats/go-multistream.LazyConn (interface)
github.com/nats-io/nats.go.ObjectResult (interface)
*github.com/ncruces/go-sqlite3.Backup
*github.com/ncruces/go-sqlite3.Blob
*github.com/ncruces/go-sqlite3.Conn
*github.com/ncruces/go-sqlite3.Stmt
*github.com/ncruces/go-sqlite3.Value
github.com/ncruces/go-sqlite3/driver.Conn (interface)
github.com/ncruces/go-sqlite3/vfs.File (interface)
github.com/ncruces/go-sqlite3/vfs.FileBatchAtomicWrite (interface)
github.com/ncruces/go-sqlite3/vfs.FileBusyHandler (interface)
github.com/ncruces/go-sqlite3/vfs.FileCheckpoint (interface)
github.com/ncruces/go-sqlite3/vfs.FileChunkSize (interface)
github.com/ncruces/go-sqlite3/vfs.FileCommitPhaseTwo (interface)
github.com/ncruces/go-sqlite3/vfs.FileHasMoved (interface)
github.com/ncruces/go-sqlite3/vfs.FileLockState (interface)
github.com/ncruces/go-sqlite3/vfs.FileOverwrite (interface)
github.com/ncruces/go-sqlite3/vfs.FilePersistWAL (interface)
github.com/ncruces/go-sqlite3/vfs.FilePowersafeOverwrite (interface)
github.com/ncruces/go-sqlite3/vfs.FilePragma (interface)
github.com/ncruces/go-sqlite3/vfs.FileSharedMemory (interface)
github.com/ncruces/go-sqlite3/vfs.FileSizeHint (interface)
github.com/ncruces/go-sqlite3/vfs.FileSync (interface)
github.com/ncruces/go-sqlite3/vfs.FileUnwrap (interface)
github.com/ncruces/go-sqlite3/vfs.SharedMemory (interface)
*github.com/pancsta/asyncmachine-go/pkg/x/history/frostdb.Memory
*github.com/parquet-go/parquet-go.GenericReader[...]
*github.com/parquet-go/parquet-go.GenericWriter[...]
github.com/parquet-go/parquet-go.Pages (interface)
*github.com/parquet-go/parquet-go.Reader
github.com/parquet-go/parquet-go.Rows (interface)
*github.com/parquet-go/parquet-go.SortingWriter[...]
*github.com/parquet-go/parquet-go.Writer
github.com/parquet-go/parquet-go/compress.Reader (interface)
github.com/parquet-go/parquet-go/compress.Writer (interface)
*github.com/pierrec/lz4/v4.CompressingReader
*github.com/pierrec/lz4/v4.Writer
*github.com/pion/datachannel.DataChannel
github.com/pion/datachannel.ReadWriteCloser (interface)
github.com/pion/datachannel.ReadWriteCloserDeadliner (interface)
*github.com/pion/dtls/v2.Conn
*github.com/pion/dtls/v3.Conn
*github.com/pion/dtls/v3/internal/net.PacketBuffer
*github.com/pion/dtls/v3/internal/net/udp.PacketConn
github.com/pion/dtls/v3/pkg/net.PacketListener (interface)
*github.com/pion/ice/v4.Agent
*github.com/pion/ice/v4.Conn
*github.com/pion/ice/v4.MultiTCPMuxDefault
*github.com/pion/ice/v4.MultiUDPMuxDefault
github.com/pion/ice/v4.TCPMux (interface)
*github.com/pion/ice/v4.TCPMuxDefault
github.com/pion/ice/v4.UDPMux (interface)
*github.com/pion/ice/v4.UDPMuxDefault
github.com/pion/ice/v4.UniversalUDPMux (interface)
github.com/pion/ice/v4.UniversalUDPMuxDefault
*github.com/pion/ice/v4/internal/fakenet.MockPacketConn
github.com/pion/ice/v4/internal/fakenet.PacketConn
*github.com/pion/interceptor.Chain
github.com/pion/interceptor.Interceptor (interface)
*github.com/pion/interceptor.NoOp
*github.com/pion/interceptor/pkg/flexfec.FecInterceptor
*github.com/pion/interceptor/pkg/nack.GeneratorInterceptor
*github.com/pion/interceptor/pkg/nack.ResponderInterceptor
*github.com/pion/interceptor/pkg/report.ReceiverInterceptor
*github.com/pion/interceptor/pkg/report.SenderInterceptor
*github.com/pion/interceptor/pkg/rfc8888.SenderInterceptor
*github.com/pion/interceptor/pkg/twcc.HeaderExtensionInterceptor
*github.com/pion/interceptor/pkg/twcc.SenderInterceptor
*github.com/pion/mdns/v2.Conn
*github.com/pion/sctp.Association
*github.com/pion/sctp.Stream
*github.com/pion/srtp/v3.ReadStreamSRTCP
*github.com/pion/srtp/v3.ReadStreamSRTP
*github.com/pion/srtp/v3.SessionSRTCP
*github.com/pion/srtp/v3.SessionSRTP
*github.com/pion/stun.Agent
*github.com/pion/stun.Client
github.com/pion/stun.ClientAgent (interface)
github.com/pion/stun.Collector (interface)
github.com/pion/stun.Connection (interface)
*github.com/pion/stun/v3.Agent
*github.com/pion/stun/v3.Client
github.com/pion/stun/v3.ClientAgent (interface)
github.com/pion/stun/v3.Collector (interface)
github.com/pion/stun/v3.Connection (interface)
github.com/pion/transport/v2.TCPConn (interface)
github.com/pion/transport/v2.TCPListener (interface)
github.com/pion/transport/v2.UDPConn (interface)
github.com/pion/transport/v2/connctx.ConnCtx (interface)
*github.com/pion/transport/v2/packetio.Buffer
*github.com/pion/transport/v2/udp.BatchConn
github.com/pion/transport/v2/udp.BatchPacketConn (interface)
*github.com/pion/transport/v2/udp.Conn
github.com/pion/transport/v3.TCPConn (interface)
github.com/pion/transport/v3.TCPListener (interface)
github.com/pion/transport/v3.UDPConn (interface)
github.com/pion/transport/v3/netctx.Conn (interface)
github.com/pion/transport/v3/netctx.PacketConn (interface)
*github.com/pion/transport/v3/packetio.Buffer
*github.com/pion/transport/v3/vnet.TokenBucketFilter
*github.com/pion/transport/v3/vnet.UDPConn
*github.com/pion/transport/v3/vnet.UDPProxy
*github.com/pion/turn/v4.Server
*github.com/pion/turn/v4.STUNConn
*github.com/pion/turn/v4/internal/allocation.Allocation
*github.com/pion/turn/v4/internal/allocation.Manager
*github.com/pion/turn/v4/internal/client.TCPAllocation
github.com/pion/turn/v4/internal/client.TCPConn
*github.com/pion/turn/v4/internal/client.UDPConn
*github.com/pion/webrtc/v4.DataChannel
*github.com/pion/webrtc/v4.ICEGatherer
*github.com/pion/webrtc/v4.PeerConnection
*github.com/pion/webrtc/v4/internal/mux.Endpoint
*github.com/pion/webrtc/v4/internal/mux.Mux
github.com/pion/webrtc/v4/pkg/media.Writer (interface)
*github.com/polarsignals/frostdb.ColumnStore
github.com/polarsignals/frostdb.DefaultObjstoreBucket
github.com/polarsignals/frostdb.ParquetWriter (interface)
github.com/polarsignals/frostdb.WAL (interface)
github.com/polarsignals/frostdb/dynparquet.DynamicRowReader (interface)
github.com/polarsignals/frostdb/dynparquet.ParquetWriter (interface)
github.com/polarsignals/frostdb/dynparquet.PooledWriter
*github.com/polarsignals/frostdb/index.LSM
github.com/polarsignals/frostdb/storage.Bucket (interface)
github.com/polarsignals/frostdb/storage.BucketReaderAt
github.com/polarsignals/frostdb/storage.FileReaderAt
*github.com/polarsignals/frostdb/storage.Iceberg
*github.com/polarsignals/frostdb/wal.FileWAL
*github.com/polarsignals/frostdb/wal.NopWAL
github.com/polarsignals/wal.LogStore (interface)
*github.com/polarsignals/wal.WAL
*github.com/polarsignals/wal/fs.File
*github.com/polarsignals/wal/metadb.BoltMetaDB
*github.com/polarsignals/wal/segment.Reader
*github.com/polarsignals/wal/segment.Writer
github.com/polarsignals/wal/types.MetaStore (interface)
github.com/polarsignals/wal/types.ReadableFile (interface)
github.com/polarsignals/wal/types.SegmentReader (interface)
github.com/polarsignals/wal/types.SegmentWriter (interface)
github.com/polarsignals/wal/types.WritableFile (interface)
*github.com/quic-go/qpack.Decoder
*github.com/quic-go/qpack.Encoder
*github.com/quic-go/quic-go.EarlyListener
*github.com/quic-go/quic-go.Listener
github.com/quic-go/quic-go.OOBCapablePacketConn (interface)
*github.com/quic-go/quic-go.Path
github.com/quic-go/quic-go.SendStream (interface)
github.com/quic-go/quic-go.Stream (interface)
*github.com/quic-go/quic-go.Transport
github.com/quic-go/quic-go/http3.QUICEarlyListener (interface)
github.com/quic-go/quic-go/http3.RequestStream (interface)
*github.com/quic-go/quic-go/http3.Server
github.com/quic-go/quic-go/http3.Stream (interface)
*github.com/quic-go/quic-go/http3.Transport
github.com/quic-go/quic-go/internal/handshake.CryptoSetup (interface)
*github.com/quic-go/webtransport-go.Dialer
github.com/quic-go/webtransport-go.SendStream (interface)
*github.com/quic-go/webtransport-go.Server
github.com/quic-go/webtransport-go.Stream (interface)
github.com/redis/go-redis/v9.Client
*github.com/redis/go-redis/v9.ClusterClient
*github.com/redis/go-redis/v9.Conn
*github.com/redis/go-redis/v9.PubSub
*github.com/redis/go-redis/v9.Ring
github.com/redis/go-redis/v9.SentinelClient
github.com/redis/go-redis/v9.UniversalClient (interface)
*github.com/redis/go-redis/v9/internal/pool.Conn
*github.com/redis/go-redis/v9/internal/pool.ConnPool
github.com/redis/go-redis/v9/internal/pool.Pooler (interface)
*github.com/redis/go-redis/v9/internal/pool.SingleConnPool
*github.com/redis/go-redis/v9/internal/pool.StickyConnPool
github.com/soheilhy/cmux.MuxConn
*github.com/tetratelabs/wazero/internal/sys.FSContext
github.com/tetratelabs/wazero/internal/wasm.Engine (interface)
github.com/thanos-io/objstore.Bucket (interface)
*github.com/thanos-io/objstore.InMemBucket
github.com/thanos-io/objstore.InstrumentedBucket (interface)
*github.com/thanos-io/objstore.PrefixedBucket
*compress/flate.Writer
*compress/gzip.Reader
*compress/gzip.Writer
*compress/zlib.Writer
crypto/cipher.StreamWriter
*crypto/tls.Conn
*crypto/tls.QUICConn
*database/sql.Conn
*database/sql.DB
*database/sql.Rows
*database/sql.Stmt
database/sql/driver.Conn (interface)
database/sql/driver.Rows (interface)
database/sql/driver.RowsColumnTypeDatabaseTypeName (interface)
database/sql/driver.RowsColumnTypeLength (interface)
database/sql/driver.RowsColumnTypeNullable (interface)
database/sql/driver.RowsColumnTypePrecisionScale (interface)
database/sql/driver.RowsColumnTypeScanType (interface)
database/sql/driver.RowsNextResultSet (interface)
database/sql/driver.Stmt (interface)
*encoding/xml.Encoder
*go.etcd.io/bbolt.DB
go.uber.org/zap.Sink (interface)
golang.org/x/crypto/ssh.Channel (interface)
golang.org/x/crypto/ssh.Client
golang.org/x/crypto/ssh.Conn (interface)
golang.org/x/crypto/ssh.ServerConn
*golang.org/x/crypto/ssh.Session
golang.org/x/image/font.Face (interface)
*golang.org/x/image/font/opentype.Face
*golang.org/x/net/http2.ClientConn
*golang.org/x/net/http2/hpack.Decoder
golang.org/x/net/internal/socks.Conn
*golang.org/x/net/ipv4.PacketConn
*golang.org/x/net/ipv4.RawConn
*golang.org/x/net/ipv6.PacketConn
*golang.org/x/text/transform.Writer
*google.golang.org/grpc.ClientConn
google.golang.org/grpc/internal/binarylog.Sink (interface)
google.golang.org/grpc/mem.Reader (interface)
*gopkg.in/yaml.v3.Encoder
gorm.io/gorm.Rows (interface)
*gorm.io/gorm/internal/stmt_store.Stmt
*internal/poll.FD
io.Closer (interface)
*io.PipeReader
*io.PipeWriter
io.ReadCloser (interface)
io.ReadSeekCloser (interface)
io.ReadWriteCloser (interface)
io.WriteCloser (interface)
io/fs.File (interface)
io/fs.ReadDirFile (interface)
*log/syslog.Writer
mime/multipart.File (interface)
*mime/multipart.Part
*mime/multipart.Writer
*mime/quotedprintable.Writer
net.Conn (interface)
*net.IPConn
net.Listener (interface)
net.PacketConn (interface)
*net.TCPConn
*net.TCPListener
*net.UDPConn
*net.UnixConn
*net.UnixListener
net/http.File (interface)
*net/http.Server
*net/http/httputil.ClientConn
*net/http/httputil.ServerConn
*net/rpc.Client
net/rpc.ClientCodec (interface)
net/rpc.ServerCodec (interface)
*net/textproto.Conn
*os.File
*os.Root
*vendor/golang.org/x/net/http2/hpack.Decoder
*vendor/golang.org/x/text/transform.Writer
Closer : io.Closer
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.
( Decoder) Decode(*dto.MetricFamily) error
func NewDecoder(r io.Reader, format Format) Decoder
Encoder types encode metric families into an underlying wire protocol.
( Encoder) Encode(*dto.MetricFamily) error
func NewEncoder(w io.Writer, format Format, options ...EncoderOption) Encoder
func WithCreatedLines() EncoderOption
func WithUnit() EncoderOption
func MetricFamilyToOpenMetrics(out io.Writer, in *dto.MetricFamily, options ...EncoderOption) (written int, err error)
func NewEncoder(w io.Writer, format Format, options ...EncoderOption) Encoder
Format specifies the HTTP content type of the different wire protocols.
FormatType deduces an overall FormatType for the given format.
ToEscapingScheme returns an EscapingScheme depending on the Format. Iff the
Format contains a escaping=allow-utf-8 term, it will select NoEscaping. If a valid
"escaping" term exists, that will be used. Otherwise, the global default will
be returned.
WithEscapingScheme returns a copy of Format with the specified escaping
scheme appended to the end. If an escaping scheme already exists it is
removed.
func Negotiate(h http.Header) Format
func NegotiateIncludingOpenMetrics(h http.Header) Format
func NewFormat(t FormatType) Format
func NewOpenMetricsFormat(version string) (Format, error)
func ResponseFormat(h http.Header) Format
func Format.WithEscapingScheme(s model.EscapingScheme) Format
func NewDecoder(r io.Reader, format Format) Decoder
func NewEncoder(w io.Writer, format Format, options ...EncoderOption) Encoder
func github.com/prometheus/client_golang/prometheus/push.(*Pusher).Format(format Format) *push.Pusher
const FmtOpenMetrics_0_0_1
const FmtOpenMetrics_1_0_0
const FmtProtoCompact
const FmtProtoDelim
const FmtProtoText
const FmtText
const FmtUnknown
FormatType is a Go enum representing the overall category for the given
Format. As the number of Format permutations increases, doing basic string
comparisons are not feasible, so this enum captures the most useful
high-level attribute of the Format string.
func Format.FormatType() FormatType
func NewFormat(t FormatType) Format
const TypeOpenMetrics
const TypeProtoCompact
const TypeProtoDelim
const TypeProtoText
const TypeTextPlain
const TypeUnknown
ParseError signals errors while parsing the simple and flat text-based
exchange format.
Line int
Msg string
Error implements the error interface.
ParseError : 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 13)
ExtractSamples builds a slice of samples from the provided metric
families. If an error occurs during sample extraction, it continues to
extract from the remaining metric families. The returned error is the last
error that has occurred.
FinalizeOpenMetrics writes the final `# EOF\n` line required by OpenMetrics.
MetricFamilyToOpenMetrics converts a MetricFamily proto message into the
OpenMetrics 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.
If metric names conform to the legacy validation pattern, they will be placed
outside the brackets in the traditional way, like `foo{}`. If the metric name
fails the legacy validation check, it will be placed quoted inside the
brackets: `{"foo"}`. As stated above, the input is assumed to be santized and
no error will be thrown in this case.
Similar to metric names, if label names conform to the legacy validation
pattern, they will be unquoted as normal, like `foo{bar="baz"}`. If the label
name fails the legacy validation check, it will be quoted:
`foo{"bar"="baz"}`. As stated above, the input is assumed to be santized and
no error will be thrown in this case.
This function fulfills the type 'expfmt.encoder'.
Note that OpenMetrics requires a final `# EOF` line. Since this function acts
on individual metric families, it is the responsibility of the caller to
append this line to 'out' once all metric families have been written.
Conveniently, this can be done by calling FinalizeOpenMetrics.
The output should be fully OpenMetrics compliant. However, there are a few
missing features and peculiarities to avoid complications when switching from
Prometheus to OpenMetrics or vice versa:
- Counters are expected to have the `_total` suffix in their metric name. In
the output, the suffix will be truncated from the `# TYPE`, `# HELP` and `# UNIT`
lines. A counter with a missing `_total` suffix is not an error. However,
its type will be set to `unknown` in that case to avoid invalid OpenMetrics
output.
- According to the OM specs, the `# UNIT` line is optional, but if populated,
the unit has to be present in the metric name as its suffix:
(see https://github.com/prometheus/OpenMetrics/blob/v1.0.0/specification/OpenMetrics.md#unit).
However, in order to accommodate any potential scenario where such a change in the
metric name is not desirable, the users are here given the choice of either explicitly
opt in, in case they wish for the unit to be included in the output AND in the metric name
as a suffix (see the description of the WithUnit function above),
or not to opt in, in case they don't want for any of that to happen.
- No support for the following (optional) features: info type,
stateset type, gaugehistogram type.
- The size of exemplar labels is not checked (i.e. it's possible to create
exemplars that are larger than allowed by the OpenMetrics specification).
- The value of Counters is not checked. (OpenMetrics doesn't allow counters
with a `NaN` value.)
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.
If metric names conform to the legacy validation pattern, they will be placed
outside the brackets in the traditional way, like `foo{}`. If the metric name
fails the legacy validation check, it will be placed quoted inside the
brackets: `{"foo"}`. As stated above, the input is assumed to be santized and
no error will be thrown in this case.
Similar to metric names, if label names conform to the legacy validation
pattern, they will be unquoted as normal, like `foo{bar="baz"}`. If the label
name fails the legacy validation check, it will be quoted:
`foo{"bar"="baz"}`. As stated above, the input is assumed to be santized and
no error will be thrown in this case.
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 (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.
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.
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. 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.
NewFormat generates a new Format from the type provided. Mostly used for
tests, most Formats should be generated as part of content negotiation in
encode.go. If a type has more than one version, the latest version will be
returned.
NewOpenMetricsFormat generates a new OpenMetrics format matching the
specified version number.
ResponseFormat extracts the correct format from a HTTP response header.
If no matching format can be found FormatUnknown is returned.
WithCreatedLines is an EncoderOption that configures the OpenMetrics encoder
to include _created lines (See
https://github.com/prometheus/OpenMetrics/blob/v1.0.0/specification/OpenMetrics.md#counter-1).
Created timestamps can improve the accuracy of series reset detection, but
come with a bandwidth cost.
At the time of writing, created timestamp ingestion is still experimental in
Prometheus and need to be enabled with the feature-flag
`--feature-flag=created-timestamp-zero-ingestion`, and breaking changes are
still possible. Therefore, it is recommended to use this feature with caution.
WithUnit is an EncoderOption enabling a set unit to be written to the output
and to be added to the metric name, if it's not there already, as a suffix.
Without opting in this way, the unit will not be added to the metric name and,
on top of that, the unit will not be passed onto the output, even if it
were declared in the *dto.MetricFamily struct, i.e. even if in.Unit !=nil.
Package-Level Constants (total 20)
Deprecated: Use expfmt.NewFormat(expfmt.TypeOpenMetrics) instead.
Deprecated: Use expfmt.NewFormat(expfmt.TypeOpenMetrics) instead.
Deprecated: Use expfmt.NewFormat(expfmt.TypeProtoCompact) instead.
Deprecated: Use expfmt.NewFormat(expfmt.TypeProtoDelim) instead.
Deprecated: Use expfmt.NewFormat(expfmt.TypeProtoText) instead.
Deprecated: Use expfmt.NewFormat(expfmt.TypeTextPlain) instead.
The Content-Type values for the different wire protocols. Do not do direct
comparisons to these constants, instead use the comparison functions.
Deprecated: Use expfmt.NewFormat(expfmt.TypeUnknown) instead.
Constants to assemble the Content-Type values for the different wire
protocols. The Content-Type strings here are all for the legacy exposition
formats, where valid characters for metric names and label names are limited.
Support for arbitrary UTF-8 characters in those names is already partially
implemented in this module (see model.ValidationScheme), but to actually use
it on the wire, new content-type strings will have to be agreed upon and
added here.
Constants to assemble the Content-Type values for the different wire
protocols. The Content-Type strings here are all for the legacy exposition
formats, where valid characters for metric names and label names are limited.
Support for arbitrary UTF-8 characters in those names is already partially
implemented in this module (see model.ValidationScheme), but to actually use
it on the wire, new content-type strings will have to be agreed upon and
added here.
Constants to assemble the Content-Type values for the different wire
protocols. The Content-Type strings here are all for the legacy exposition
formats, where valid characters for metric names and label names are limited.
Support for arbitrary UTF-8 characters in those names is already partially
implemented in this module (see model.ValidationScheme), but to actually use
it on the wire, new content-type strings will have to be agreed upon and
added here.
Deprecated: Use expfmt.NewFormat(expfmt.TypeProtoCompact) instead.
Constants to assemble the Content-Type values for the different wire
protocols. The Content-Type strings here are all for the legacy exposition
formats, where valid characters for metric names and label names are limited.
Support for arbitrary UTF-8 characters in those names is already partially
implemented in this module (see model.ValidationScheme), but to actually use
it on the wire, new content-type strings will have to be agreed upon and
added here.
Constants to assemble the Content-Type values for the different wire
protocols. The Content-Type strings here are all for the legacy exposition
formats, where valid characters for metric names and label names are limited.
Support for arbitrary UTF-8 characters in those names is already partially
implemented in this module (see model.ValidationScheme), but to actually use
it on the wire, new content-type strings will have to be agreed upon and
added here.
Constants to assemble the Content-Type values for the different wire
protocols. The Content-Type strings here are all for the legacy exposition
formats, where valid characters for metric names and label names are limited.
Support for arbitrary UTF-8 characters in those names is already partially
implemented in this module (see model.ValidationScheme), but to actually use
it on the wire, new content-type strings will have to be agreed upon and
added here.
const TypeOpenMetrics FormatType = 5 const TypeProtoCompact FormatType = 1 const TypeProtoDelim FormatType = 2 const TypeProtoText FormatType = 3 const TypeTextPlain FormatType = 4 const TypeUnknown FormatType = 0![]() |
The pages are generated with Golds v0.8.2. (GOOS=linux GOARCH=amd64) Golds is a Go 101 project developed by Tapir Liu. PR and bug reports are welcome and can be submitted to the issue list. Please follow @zigo_101 (reachable from the left QR code) to get the latest news of Golds. |