Documentation
¶
Index ¶
Constants ¶
const ( OTLPGRPC = "otlpgrpc" OTLPHTTP = "otlphttp" Stdout = "stdout" )
Exporter names, the values of the metrics.exporter config key and WithExporter. Each maps to a subpackage under pkg/services/metrics/exporters that registers its Factory during init().
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Factory ¶
Factory builds a metric Exporter from the metrics.config block, handed over as raw YAML - nil when the block is absent. Different exporters need different config shapes, so the manager never interprets the block: each factory strict-decodes its own config struct and fails the build on unknown keys - the same contract the tracing factories carry. Each exporter subpackage under pkg/services/metrics/exporters/* registers one during its init() so the core package never links exporter machinery (grpc most of all) into binaries that don't use it. An exporter whose construction config cannot express is still a Factory: the app Registers its own under a name - a closure captures whatever it needs.
type Manager ¶
type Manager interface {
// business
model.Meter
// health.go: Alive guards the manager's own wiring only (enabled but no
// exporter built - Init rebuilds it, so a restart is the remedy). There
// is deliberately NO common.Readiness: metrics are auxiliary, so an
// unreachable collector must never gate app readiness - and the monitor
// rolls a dependency's probes into every dependent's healthcheck, which
// would let a dead collector degrade the api server. Export failures
// never fail Alive either - the monitor restarts on liveness failure,
// and a dead collector must not flap the service; they surface in logs
// and Info instead.
common.Liveness
// lifecycle
common.Initializable
common.Daemon
common.Debuggable
}
type Option ¶
type Option func(*manager)
func WithEnabled ¶
WithEnabled switches the service on or off, carrying the wiring layer's reading of metrics.enabled - which the same key overrides on every Init, since it is also read there. Enabling is its own decision: WithExporter says where metrics would go, never that metrics are on.
func WithExporter ¶
WithExporter picks a registry exporter by name together with the config block its factory strict-decodes - one decision, since the block only has meaning for the exporter that reads it. nil config means the exporter's defaults. The programmatic twin of the metrics.exporter + metrics.config yaml keys, which override it when set. An exporter whose construction no config can express is registered as an app-owned Factory (metrics.Register) - a closure captures whatever it needs - and picked here by its name.
Choosing where metrics would go does not turn the service on: enabling is ops state, not a wiring decision, so metrics.enabled is the only thing that does it and there is no option for it.
func WithInterval ¶
WithInterval sets the export loop period. Zero reads as unset - newManager defaults it - since Go cannot tell an absent duration from an explicit zero, which lets a wiring layer pass a missing config key straight through. Viper does distinguish unset, so a config file could still ask for zero - it lands on the default, never on a spinning loop.
func WithLogger ¶
Source Files
¶
Directories
¶
| Path | Synopsis |
|---|---|
|
exporters
|
|
|
otlpgrpc
Package otlpgrpc registers the OTLP-over-gRPC metric exporter under metrics.OTLPGRPC.
|
Package otlpgrpc registers the OTLP-over-gRPC metric exporter under metrics.OTLPGRPC. |
|
otlphttp
Package otlphttp registers the OTLP-over-HTTP metric exporter under metrics.OTLPHTTP.
|
Package otlphttp registers the OTLP-over-HTTP metric exporter under metrics.OTLPHTTP. |
|
stdout
Package stdout registers the stdout metric exporter under metrics.Stdout.
|
Package stdout registers the stdout metric exporter under metrics.Stdout. |