Skip to content

Commit 3debee8

Browse files
committed
Create a startup time metric
1 parent eb0edda commit 3debee8

2 files changed

Lines changed: 11 additions & 0 deletions

File tree

pkg/driver/driver.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -192,6 +192,10 @@ func Start(ctx context.Context, driverName string, kubeClient kubernetes.Interfa
192192
plugin.netdb = inventory.New()
193193
}
194194
go func() {
195+
begin := time.Now()
196+
defer func() {
197+
inventoryStartupDurationSeconds.Set(time.Since(begin).Seconds())
198+
}()
195199
for i := 0; i < maxAttempts; i++ {
196200
err = plugin.netdb.Run(ctx)
197201
if err != nil {

pkg/driver/metrics.go

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@ func registerMetrics() {
4747
prometheus.MustRegister(nriPluginRequestsLatencySeconds)
4848
prometheus.MustRegister(publishedDevicesTotal)
4949
prometheus.MustRegister(lastPublishedTime)
50+
prometheus.MustRegister(inventoryStartupDurationSeconds)
5051
})
5152
}
5253

@@ -87,4 +88,10 @@ var (
8788
Name: "last_published_time_seconds",
8889
Help: "The timestamp of the last successful resource publication.",
8990
})
91+
inventoryStartupDurationSeconds = prometheus.NewGauge(prometheus.GaugeOpts{
92+
Namespace: "dranet",
93+
Subsystem: "driver",
94+
Name: "inventory_startup_duration_seconds",
95+
Help: "The duration of the inventory startup.",
96+
})
9097
)

0 commit comments

Comments
 (0)