mirror of
https://github.com/coder/coder.git
synced 2026-09-24 15:04:27 +08:00
feat: add Prometheus metrics to NATS pubsub for parity with PGPubsub (#26441)
This commit is contained in:
+5
-1
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user