feat: add Prometheus metrics to NATS pubsub for parity with PGPubsub (#26441)

This commit is contained in:
Jon Ayers
2026-06-23 11:59:48 -05:00
committed by GitHub
parent d104d0dcb3
commit 6da322d59f
9 changed files with 613 additions and 10 deletions
+5 -1
View File
@@ -821,7 +821,7 @@ func (r *RootCmd) Server(newAPI func(context.Context, *coderd.Options) (*coderd.
// Use NATS for pubsub if the experiment is enabled.
if experiments.Enabled(codersdk.ExperimentNATSPubsub) {
token := fmt.Sprintf("%x", sha256.Sum256([]byte(dbURL)))
natsps, err := nats.New(ctx, logger.Named("pubsub"), nats.Options{
natsps, err := nats.New(ctx, logger.Named("nats_pubsub"), nats.Options{
ClusterAuthToken: token,
})
if err != nil {
@@ -829,6 +829,10 @@ func (r *RootCmd) Server(newAPI func(context.Context, *coderd.Options) (*coderd.
}
options.Pubsub = natsps
defer natsps.Close()
if options.DeploymentValues.Prometheus.Enable {
options.PrometheusRegistry.MustRegister(natsps)
}
}
psWatchdog := pubsub.NewWatchdog(ctx, logger.Named("pswatch"), options.Pubsub)