Fix metrics being injected after node initalization

License: MIT
Signed-off-by: Jakub Sztandera <kubuxu@protonmail.ch>
This commit is contained in:
Jakub Sztandera 2016-10-18 08:59:15 +02:00
parent 62fcf7e9e2
commit de34ef813b
No known key found for this signature in database
GPG Key ID: 9A9AF56F8B3879BA

View File

@ -181,6 +181,13 @@ func defaultMux(path string) corehttp.ServeOption {
var fileDescriptorCheck = func() error { return nil }
func daemonFunc(req cmds.Request, res cmds.Response) {
// Inject metrics before we do anything
err := mprome.Inject()
if err != nil {
log.Warningf("Injecting prometheus handler for metrics failed with message: %s\n", err.Error())
}
// let the user know we're going.
fmt.Printf("Initializing daemon...\n")
@ -388,10 +395,6 @@ func daemonFunc(req cmds.Request, res cmds.Response) {
}
// initialize metrics collector
err = mprome.Inject()
if err != nil {
log.Warningf("Injecting prometheus handler for metrics failed with message: %s\n", err.Error())
}
prometheus.MustRegister(&corehttp.IpfsNodeCollector{Node: node})
fmt.Printf("Daemon is ready\n")