Fix metrics being injected after node initalization
License: MIT Signed-off-by: Jakub Sztandera <kubuxu@protonmail.ch>
Jakub Sztandera committed
Oct 18, 2016 at 08:59 UTC
de34ef813b99d58b4d8eba2ad26e75738ae5f789
1 file changed
+7
-4
cmd/ipfs/daemon.go
+7
-4
@@ -181,6 +181,13 @@ func defaultMux(path string) corehttp.ServeOption {
181
var fileDescriptorCheck = func() error { return nil }
182
183
func daemonFunc(req cmds.Request, res cmds.Response) {
184
+ // Inject metrics before we do anything
185
+
186
+ err := mprome.Inject()
187
+ if err != nil {
188
+ log.Warningf("Injecting prometheus handler for metrics failed with message: %s\n", err.Error())
189
+ }
190
+
191
// let the user know we're going.
192
fmt.Printf("Initializing daemon...\n")
193
@@ -388,10 +395,6 @@ func daemonFunc(req cmds.Request, res cmds.Response) {
395
}
396
397
// initialize metrics collector
391
- err = mprome.Inject()
392
- if err != nil {
393
- log.Warningf("Injecting prometheus handler for metrics failed with message: %s\n", err.Error())
394
- }
398
prometheus.MustRegister(&corehttp.IpfsNodeCollector{Node: node})
399
400
fmt.Printf("Daemon is ready\n")