File tree Expand file tree Collapse file tree 1 file changed +16
-0
lines changed Expand file tree Collapse file tree 1 file changed +16
-0
lines changed Original file line number Diff line number Diff line change @@ -20,10 +20,16 @@ const (
20
20
appRevisionMetric = "app_revision"
21
21
)
22
22
23
+ type SystemMetrics struct {
24
+ Enable bool
25
+ UpdateInterval time.Duration
26
+ }
27
+
23
28
type Config struct {
24
29
ReadTimeOut time.Duration
25
30
WriteTimeOut time.Duration
26
31
Logger * logger.Logger
32
+ SystemMetrics SystemMetrics
27
33
EnableRequestID bool
28
34
AppVersion string
29
35
AppRevision string
@@ -95,6 +101,16 @@ func New(metricsServer metrics.TaskMetrics, config *Config) ZRouter {
95
101
metricsServer : metricsServer ,
96
102
config : config ,
97
103
}
104
+
105
+ if config .SystemMetrics .Enable {
106
+ if err := metrics .RegisterSystemMetrics (metricsServer ); err != nil {
107
+ logger .GetLoggerFromContext (context .Background ()).Errorf ("Error registering metrics %v" , err )
108
+ }
109
+
110
+ updateInterval := config .SystemMetrics .UpdateInterval
111
+ go metrics .UpdateSystemMetrics (metricsServer , updateInterval )
112
+ }
113
+
98
114
return zr
99
115
}
100
116
You can’t perform that action at this time.
0 commit comments