File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -156,6 +156,8 @@ func (db *DB) GetPodNetNs(pod string) string {
156156}
157157
158158func (db * DB ) Run (ctx context.Context ) error {
159+ registerMetrics ()
160+ begin := time .Now ()
159161 defer close (db .notifications )
160162
161163 // Resources are published periodically or if there is a netlink notification
@@ -171,7 +173,7 @@ func (db *DB) Run(ctx context.Context) error {
171173 db .instance = getInstanceProperties (ctx )
172174 db .gwInterfaces = getDefaultGwInterfaces ()
173175 klog .V (2 ).Infof ("Default gateway interfaces: %v" , db .gwInterfaces .UnsortedList ())
174-
176+ inventoryStartupDurationSeconds . Set ( time . Since ( begin ). Seconds ())
175177 for {
176178 err := db .rateLimiter .Wait (ctx )
177179 if err != nil {
Original file line number Diff line number Diff line change 1+ /*
2+ Copyright The Kubernetes Authors
3+
4+ Licensed under the Apache License, Version 2.0 (the "License");
5+ you may not use this file except in compliance with the License.
6+ You may obtain a copy of the License at
7+
8+ https://www.apache.org/licenses/LICENSE-2.0
9+
10+ Unless required by applicable law or agreed to in writing, software
11+ distributed under the License is distributed on an "AS IS" BASIS,
12+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+ See the License for the specific language governing permissions and
14+ limitations under the License.
15+ */
16+
17+ package inventory
18+
19+ import (
20+ "sync"
21+
22+ "github.com/prometheus/client_golang/prometheus"
23+ )
24+
25+ var registerMetricsOnce sync.Once
26+
27+ func registerMetrics () {
28+ registerMetricsOnce .Do (func () {
29+ prometheus .MustRegister (inventoryStartupDurationSeconds )
30+ })
31+ }
32+
33+ var (
34+ inventoryStartupDurationSeconds = prometheus .NewGauge (prometheus.GaugeOpts {
35+ Namespace : "dranet" ,
36+ Subsystem : "inventory" ,
37+ Name : "inventory_startup_duration_seconds" ,
38+ Help : "The duration of the inventory startup." ,
39+ })
40+ )
You can’t perform that action at this time.
0 commit comments