Documentation
¶
Overview ¶
Package metrics provides a Wrapper around hashicorp/go-metrics.
Index ¶
Constants ¶
const ComponentType = "metrics"
ComponentType is the components name.
Variables ¶
var ( // DefaultMetricsPlugin is the default metrics plugin to use. DefaultMetricsPlugin = "memory" // DefaultConfigSection is the section key used in config files used to configure the metrics options. DefaultConfigSection = "metrics" )
var Plugins = container.NewMap[string, ProviderFunc]()
Plugins is the plugins container for registries.
Functions ¶
This section is empty.
Types ¶
type Config ¶
type Config struct {
Plugin string // Plugin sets the metrics sink plugin to use.
Hostname string // Hostname to use. If not provided and EnableHostname, it will be os.Hostname
EnableHostname bool // Hostname to use. If not provided and EnableHostname, it will be os.Hostname
EnableHostnameLabel bool // Enable prefixing gauge values with hostname
EnableRuntimeMetrics bool // Enables profiling of runtime metrics (GC, Goroutines, Memory)
EnableTypePrefix bool // Prefixes key with a type ("counter", "gauge", "timer")
TimerGranularity config.Duration // Granularity of timers.
ProfileInterval config.Duration // Interval to profile runtime metrics
AllowedPrefixes []string // A list of metric prefixes to allow, with '.' as the separator
BlockedPrefixes []string // A list of metric prefixes to block, with '.' as the separator
AllowedLabels []string // A list of metric labels to allow, with '.' as the separator
BlockedLabels []string // A list of metric labels to block, with '.' as the separator
FilterDefault bool // Whether to allow metrics by default
}
Config contains the metrics config.
type ConfigType ¶
type ConfigType interface {
// contains filtered or unexported methods
}
ConfigType is a wrapper for config, so we can pass it back to the this plugin handler.
type Metrics ¶
type Metrics interface {
types.Component
SetGauge(key []string, val float32) // Set gauge key and value with 32 bit precision
SetGaugeWithLabels(key []string, val float32, labels []Label) // Set gauge key and value with 32 bit precision
SetPrecisionGauge(key []string, val float64)
SetPrecisionGaugeWithLabels(key []string, val float64, labels []Label)
EmitKey(key []string, val float32)
IncrCounter(key []string, val float32)
IncrCounterWithLabels(key []string, val float32, labels []Label)
AddSample(key []string, val float32)
AddSampleWithLabels(key []string, val float32, labels []Label)
MeasureSince(key []string, start time.Time)
MeasureSinceWithLabels(key []string, start time.Time, labels []Label)
// UpdateFilter overwrites the existing filter with the given rules.
UpdateFilter(allow, block []string)
// UpdateFilterAndLabels overwrites the existing filter with the given rules.
UpdateFilterAndLabels(allow, block, allowedLabels, blockedLabels []string)
// Emits various runtime statsitics
EmitRuntimeStats()
}
Metrics contains all hashicorp/go-metrics.Metrics methods we have found so far.
type ProviderFunc ¶
type ProviderFunc func( svcCtx *cli.ServiceContextWithConfig, logger log.Logger, opts ...Option, ) (Type, error)
ProviderFunc is provider function type is used to create a new metrics plugin.
type Type ¶
type Type struct {
Metrics
}
Type is the registry type it is returned when you use metrics.Provide which selects a registry to use based on the plugin configuration.
func Provide ¶
func Provide( svcCtx *cli.ServiceContextWithConfig, components *types.Components, logger log.Logger, opts ...Option, ) (Type, error)
Provide is the metrics provider for wire. It parses the config from "configs", fetches the "Plugin" from the config and then forwards all it's arguments to the factory which it get's from "Plugins".