Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for metric to track the maximum number of devices permitted to connect to a Talaria instance. #454

Merged
merged 4 commits into from
Oct 22, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@
const (
applicationName = "talaria"
tracingConfigKey = "tracing"
maxDeviceCount = "max_device_count"
)

var (
Expand Down Expand Up @@ -93,6 +94,13 @@
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

Check warning on line 101 in main.go

View check run for this annotation

Codecov / codecov/patch

main.go#L97-L101

Added lines #L97 - L101 were not covered by tests
}

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 @@
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
}

Check warning on line 180 in main.go

View check run for this annotation

Codecov / codecov/patch

main.go#L176-L180

Added lines #L176 - L180 were not covered by tests

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