Source File
encode.go
Belonging Package
github.com/prometheus/common/expfmt
package expfmt
import (
dto
)
type Encoder interface {
Encode(*dto.MetricFamily) error
}
type encoder func(*dto.MetricFamily) error
func ( encoder) ( *dto.MetricFamily) error {
return ()
}
if .Type+"/"+.SubType == ProtoType && .Params["proto"] == ProtoProtocol {
switch .Params["encoding"] {
case "delimited":
return FmtProtoDelim
case "text":
return FmtProtoText
case "compact-text":
return FmtProtoCompact
}
func ( io.Writer, Format) Encoder {
switch {
case FmtProtoDelim:
return encoder(func( *dto.MetricFamily) error {
, := pbutil.WriteDelimited(, )
return
})
case FmtProtoCompact:
return encoder(func( *dto.MetricFamily) error {
, := fmt.Fprintln(, .String())
return
})
case FmtProtoText:
return encoder(func( *dto.MetricFamily) error {
, := fmt.Fprintln(, proto.MarshalTextString())
return
})
case FmtText:
return encoder(func( *dto.MetricFamily) error {
, := MetricFamilyToText(, )
return
})
}
panic("expfmt.NewEncoder: unknown format")
![]() |
The pages are generated with Golds v0.3.2-preview. (GOOS=darwin 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 @Go100and1 (reachable from the left QR code) to get the latest news of Golds. |