Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
var Component = &component.Component{ Name: "runner.metric", Dependencies: component.Components{ runner.Component, }, Init: component.StepFunc(func(container container.Container) error { return container.Provide(NewMetric) }), PreExecute: component.StepFunc(func(container container.Container) error { return container.Invoke(func(r runner.Runner, middleware *Metric) { r.Use(middleware) }) }), }
Component is a ready-to-use Compogo component that automatically adds Prometheus metrics middleware to the application's runner.
It depends on runner.Component and registers itself during the PreRun phase. The exported metrics follow the naming convention:
compogo_runner_task{app="<app-name>"}
Usage:
compogo.WithComponents(
runner.Component,
metric.Component, // ← adds Prometheus metrics to all tasks
)
Functions ¶
This section is empty.
Types ¶
type Metric ¶
type Metric struct {
// contains filtered or unexported fields
}
Metric is a middleware that increments a Prometheus counter for each task execution. It helps track how many tasks are being run and can be used for monitoring task activity.
func NewMetric ¶
NewMetric creates a new Metric middleware instance. The appConfig provides the application name which is added as a label to the counter, allowing per-application metrics in multi-service environments.
The exported metric follows the naming convention:
compogo_runner_task{app="<app-name>"}