Documentation
¶
Overview ¶
Package metrics provides backend-agnostic service instrumentation.
Services record metrics through Client or the Processor interface. Concrete exporters live in pkg/metrics/processors/* and register themselves at init, following the same plugin pattern used by pkg/fastlog.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func NormalizeTags ¶
NormalizeTags returns a stable copy of tags suitable for processors.
func RegisteredProcessors ¶
func RegisteredProcessors() []string
RegisteredProcessors returns all registered processor names.
func SetDefault ¶
func SetDefault(c *Client)
SetDefault stores the process-wide metrics client for service-specific instrumentation.
Types ¶
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
Client fans metric calls out to configured processors.
func Default ¶
func Default() *Client
Default returns the process-wide metrics client, or nil when metrics are disabled.
func New ¶
New creates a metrics client from configured processors. Returns nil if cfg is not enabled.
func (*Client) Distribution ¶
Distribution records a distribution metric.
type Config ¶
type Config struct {
Processors []string `env:"_PROCESSORS" envDefault:"prometheus"`
}
Config holds backend-agnostic metrics configuration.
Environment:
- METRICS_PROCESSORS defaults to prometheus.
func GetEnvConfig ¶
GetEnvConfig reads metrics configuration from environment variables. Default prefix is METRICS. Processor-specific packages own their own env config.
func PrometheusOnly ¶ added in v1.2.1
PrometheusOnly returns a config that uses Prometheus for every enabled metrics setup.
func (Config) EnabledProcessors ¶
EnabledProcessors returns the configured processors.
type DefaultHandle ¶
type DefaultHandle struct {
// contains filtered or unexported fields
}
DefaultHandle restores a package-level metrics default and closes its client.
func InstallDefault ¶
func InstallDefault(c *Client) *DefaultHandle
InstallDefault installs a process-wide metrics default with an explicit close path.
func (*DefaultHandle) Client ¶
func (h *DefaultHandle) Client() *Client
Client returns the installed default client.
func (*DefaultHandle) Close ¶
func (h *DefaultHandle) Close() error
Close restores the previous default client and closes the installed client.
Directories
¶
| Path | Synopsis |
|---|---|
|
Package all imports every in-tree metrics processor so each processor registers with the default metrics registry through its init hook.
|
Package all imports every in-tree metrics processor so each processor registers with the default metrics registry through its init hook. |
|
processors
|
|