Documentation
¶
Index ¶
- func BoolToFloat(b bool) float64
- func CompileAnchored(expr string) (*regexp.Regexp, error)
- func IsMatchAll(re *regexp.Regexp) bool
- func IsMatchNone(re *regexp.Regexp) bool
- func MBToBytes(mb float64) float64
- func MilliSecToSec(t float64) float64
- func Must[T any](v T, err error) T
- func MustCompileAnchored(expr string) *regexp.Regexp
- func PercentageToRatio(percentage float64) float64
- func RegexpFlag(app *kingpin.Application, name, help, defaultValue string, ...) *kingpin.FlagClause
- func SplitError(err error) []error
- type Counter
- type Counter32
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func BoolToFloat ¶
func CompileAnchored ¶ added in v0.32.0
CompileAnchored compiles expr, so that it must match the whole input.
func IsMatchAll ¶ added in v0.32.0
IsMatchAll reports whether re is an include filter that matches every name: the default of an include flag, types.RegExpAny or nil, which the New function of a collector replaces with the default.
func IsMatchNone ¶ added in v0.32.0
IsMatchNone reports whether re is an exclude filter that matches no name: the default of an exclude flag, types.RegExpEmpty or nil, which the New function of a collector replaces with the default.
func MilliSecToSec ¶
func MustCompileAnchored ¶ added in v0.32.0
MustCompileAnchored is like CompileAnchored, but panics if expr can't be parsed.
func PercentageToRatio ¶
func RegexpFlag ¶ added in v0.32.0
func RegexpFlag(app *kingpin.Application, name, help, defaultValue string, target **regexp.Regexp) *kingpin.FlagClause
RegexpFlag registers the flag name, whose value is a regular expression that must match the whole name. The compiled expression is stored in target when the flags are parsed, including the default and a value from the configuration file. An invalid expression fails the parsing with an error that starts with the name of the flag.
func SplitError ¶
SplitError returns a slice of errors from the given error. It reverses the errors.Join function.
Types ¶
type Counter ¶
type Counter struct {
// contains filtered or unexported fields
}
func NewCounter ¶
NewCounter creates a new Counter that accepts uint32 values and returns float64 values. It resolve the overflow issue of uint32 by using the difference between the last value and the current value.
type Counter32 ¶ added in v0.32.0
type Counter32 struct {
// contains filtered or unexported fields
}
Counter32 extends a raw 32-bit performance counter, such as a PERF_COUNTER_COUNTER or the numerator of a PERF_AVERAGE_TIMER, beyond 2^32. Unlike Counter, it starts at the raw value and follows a restart of the source, so its value equals the raw value until the first wrap. It can only detect one wrap between two samples.
func NewCounter32 ¶ added in v0.32.0
NewCounter32 creates a Counter32 from the first raw value. If restartBelow is not zero, a decrease from a raw value below restartBelow is taken as a restart of the source instead of a wrap. Use it for counters that cannot grow by 2^32-restartBelow between two samples, such as request counts.