Skip to content

Commit

Permalink
load plugins when init metrics (#608)
Browse files Browse the repository at this point in the history
  • Loading branch information
yuyang0 authored Aug 24, 2023
1 parent 3038a70 commit 9bee0e8
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
2 changes: 1 addition & 1 deletion cluster/calcium/metrics.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ func (c *Calcium) InitMetrics(ctx context.Context) {
logger.Error(ctx, err, "failed to get metrics description")
return
}
if err = metrics.InitMetrics(c.config, metricsDescriptions); err != nil {
if err = metrics.InitMetrics(ctx, c.config, metricsDescriptions); err != nil {
logger.Error(ctx, err, "failed to init metrics")
return
}
Expand Down
6 changes: 5 additions & 1 deletion metrics/metrics.go
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ var Client = Metrics{}
var once sync.Once

// InitMetrics new a metrics obj
func InitMetrics(config types.Config, metricsDescriptions []*plugintypes.MetricsDescription) error {
func InitMetrics(ctx context.Context, config types.Config, metricsDescriptions []*plugintypes.MetricsDescription) error {
hostname, err := os.Hostname()
if err != nil {
return err
Expand All @@ -139,6 +139,10 @@ func InitMetrics(config types.Config, metricsDescriptions []*plugintypes.Metrics
if err != nil {
return err
}
if err := rmgr.LoadPlugins(ctx, nil); err != nil {
return err
}

Client = Metrics{
Config: config,
StatsdAddr: config.Statsd,
Expand Down

0 comments on commit 9bee0e8

Please sign in to comment.