mirror of
https://github.com/coder/coder.git
synced 2026-09-24 15:04:27 +08:00
feat: Implement aggregator for agent metrics (#7259)
This commit is contained in:
@@ -723,6 +723,20 @@ func (r *RootCmd) Server(newAPI func(context.Context, *coderd.Options) (*coderd.
|
||||
return xerrors.Errorf("register agent stats prometheus metric: %w", err)
|
||||
}
|
||||
defer closeAgentStatsFunc()
|
||||
|
||||
metricsAggregator, err := prometheusmetrics.NewMetricsAggregator(logger, options.PrometheusRegistry, 0)
|
||||
if err != nil {
|
||||
return xerrors.Errorf("can't initialize metrics aggregator: %w", err)
|
||||
}
|
||||
|
||||
cancelMetricsAggregator := metricsAggregator.Run(ctx)
|
||||
defer cancelMetricsAggregator()
|
||||
|
||||
options.UpdateAgentMetrics = metricsAggregator.Update
|
||||
err = options.PrometheusRegistry.Register(metricsAggregator)
|
||||
if err != nil {
|
||||
return xerrors.Errorf("can't register metrics aggregator as collector: %w", err)
|
||||
}
|
||||
}
|
||||
|
||||
//nolint:revive
|
||||
|
||||
Reference in New Issue
Block a user