Skip to content

Commit 5005c87

Browse files
committed
fix data race
1 parent c55120b commit 5005c87

File tree

1 file changed

+6
-5
lines changed

1 file changed

+6
-5
lines changed

metrics/metrics.go

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -23,11 +23,6 @@ func initPrometheus(ctx context.Context, serviceName string, cfg config.Promethe
2323
return
2424
}
2525

26-
go func() {
27-
log.Infof(ctx, "Start HTTP Prometheus metrics. http://%s", cfg.Addr)
28-
log.Fatal(ctx, http.ListenAndServe(cfg.Addr, promhttp.Handler()))
29-
}()
30-
3126
if len(cfg.HTTPServerRequestsDurationHistogramBuckets) < 1 {
3227
cfg.HTTPServerRequestsDurationHistogramBuckets = skyprome.DefaultBuckets
3328
}
@@ -51,4 +46,10 @@ func initPrometheus(ctx context.Context, serviceName string, cfg config.Promethe
5146
skyprome.LogInit()
5247
skyprome.HttpServerInit()
5348
skyprome.HttpClientInit()
49+
50+
go func() {
51+
log.Infof(ctx, "Start HTTP Prometheus metrics. http://%s", cfg.Addr)
52+
log.Fatal(ctx, http.ListenAndServe(cfg.Addr, promhttp.Handler()))
53+
}()
54+
5455
}

0 commit comments

Comments
 (0)