Skip to content

Commit

Permalink
fix: Don't run general service metrics code for security bootstrap se…
Browse files Browse the repository at this point in the history
…rvices

fixes edgexfoundry#379

Signed-off-by: Leonard Goodell <[email protected]>
  • Loading branch information
Leonard Goodell committed Oct 11, 2022
1 parent 74237f4 commit c126679
Showing 1 changed file with 17 additions and 13 deletions.
30 changes: 17 additions & 13 deletions bootstrap/bootstrap.go
Original file line number Diff line number Diff line change
Expand Up @@ -162,20 +162,24 @@ func RunAndReturnWaitGroup(
}
}

// Have to delay registering the general common service metrics until all bootstrap handler have run so that there is
// opportunity for the MetricsManager to have been created.
metricsManager := container.MetricsManagerFrom(dic.Get)
if metricsManager != nil {
secretProvider := container.SecretProviderFrom(dic.Get)
if secretProvider != nil {
secretProvider.RegisterMetrics(func(metrics map[string]interface{}) {
registerMetrics(metricsManager, metrics, lc)
})

// TODO: use this same approach to register future service metric controlled by other components
// Service that don't use the Security Provider also will not collect metrics. These are the security services that
// run during bootstrapping of the secure deployment
if useSecretProvider && startedSuccessfully {
// Have to delay registering the general common service metrics until all bootstrap handlers have run so that there is
// opportunity for the MetricsManager to have been created.
metricsManager := container.MetricsManagerFrom(dic.Get)
if metricsManager != nil {
secretProvider := container.SecretProviderFrom(dic.Get)
if secretProvider != nil {
secretProvider.RegisterMetrics(func(metrics map[string]interface{}) {
registerMetrics(metricsManager, metrics, lc)
})

// TODO: use this same approach to register future service metric controlled by other components
}
} else {
lc.Warn("MetricsManager not available. General common service metrics will not be reported. ")
}
} else {
lc.Warn("MetricsManager not available. General common service metrics will not be reported. ")
}

return &wg, deferred, startedSuccessfully
Expand Down

0 comments on commit c126679

Please sign in to comment.