Skip to content

Commit

Permalink
Add support for Gauge function and max devices connected to Talaria
Browse files Browse the repository at this point in the history
  • Loading branch information
chaitanyasingla-dt committed Aug 9, 2024
1 parent 3727688 commit 8bdf1d4
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 @@ -46,6 +46,7 @@ import (
const (
applicationName = "talaria"
tracingConfigKey = "tracing"
maxDeviceCount = "max_device_count"
)

var (
Expand Down Expand Up @@ -86,6 +87,13 @@ func newDeviceManager(logger *zap.Logger, r xmetrics.Registry, v *viper.Viper) (
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 @@ -145,6 +153,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 8bdf1d4

Please sign in to comment.