Skip to content

Commit

Permalink
Merge pull request #454 from ChaitanyaSingla/max-device-metric
Browse files Browse the repository at this point in the history
Add support for metric to track the maximum number of devices permitted to connect to a Talaria instance.
  • Loading branch information
denopink authored Oct 22, 2024
2 parents 94a661b + 6745563 commit f259b51
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ import (
const (
applicationName = "talaria"
tracingConfigKey = "tracing"
maxDeviceCount = "max_device_count"
)

var (
Expand Down Expand Up @@ -93,6 +94,13 @@ func newDeviceManager(logger *zap.Logger, r xmetrics.Registry, tf *touchstone.Fa
return device.NewManager(deviceOptions), g, watcher, nil
}

func newStaticMetrics(m device.Manager, r xmetrics.Registry) (err error) {
r.NewGaugeFunc(maxDeviceCount, func() float64 {
return float64(m.MaxDevices())
})
return
}

func loadTracing(v *viper.Viper, appName string) (candlelight.Tracing, error) {
var traceConfig candlelight.Config
err := v.UnmarshalKey(tracingConfigKey, &traceConfig)
Expand Down Expand Up @@ -164,6 +172,13 @@ func talaria(arguments []string) int {
logger.Error("unable to create device manager", zap.Error(err))
return 2
}

err = newStaticMetrics(manager, metricsRegistry)
if err != nil {
logger.Error("unable to register static metrics", zap.Error(err))
return 6
}

var log = &adapter.Logger{
Logger: logger,
}
Expand Down

0 comments on commit f259b51

Please sign in to comment.