Commit d2db6af
committed
fix(metrics): fix race condition in metrics.Init()
IterationMetricsEnabled can be concurrently set
```
==================
WARNING: DATA RACE
Write at 0x00c000124098 by goroutine 12:
github.com/form3tech-oss/f1/v2/internal/metrics.Init()
/Users/nikolayvladimirov/go/src/github.com/form3tech-oss/f1/internal/metrics/metrics.go:82 +0x7c
github.com/form3tech-oss/f1/v2/internal/metrics_test.TestMetrics_Init_IsSafe.func1()
/Users/nikolayvladimirov/go/src/github.com/form3tech-oss/f1/internal/metrics/metrics_test.go:15 +0x20
Previous write at 0x00c000124098 by goroutine 14:
github.com/form3tech-oss/f1/v2/internal/metrics.Init()
/Users/nikolayvladimirov/go/src/github.com/form3tech-oss/f1/internal/metrics/metrics.go:82 +0x7c
github.com/form3tech-oss/f1/v2/internal/metrics_test.TestMetrics_Init_IsSafe.func1()
/Users/nikolayvladimirov/go/src/github.com/form3tech-oss/f1/internal/metrics/metrics_test.go:15 +0x20
Goroutine 12 (running) created at:
github.com/form3tech-oss/f1/v2/internal/metrics_test.TestMetrics_Init_IsSafe()
/Users/nikolayvladimirov/go/src/github.com/form3tech-oss/f1/internal/metrics/metrics_test.go:14 +0xa4
testing.tRunner()
/opt/homebrew/Cellar/go/1.23.1/libexec/src/testing/testing.go:1690 +0x184
testing.(*T).Run.gowrap1()
/opt/homebrew/Cellar/go/1.23.1/libexec/src/testing/testing.go:1743 +0x40
Goroutine 14 (finished) created at:
github.com/form3tech-oss/f1/v2/internal/metrics_test.TestMetrics_Init_IsSafe()
/Users/nikolayvladimirov/go/src/github.com/form3tech-oss/f1/internal/metrics/metrics_test.go:14 +0xa4
testing.tRunner()
/opt/homebrew/Cellar/go/1.23.1/libexec/src/testing/testing.go:1690 +0x184
testing.(*T).Run.gowrap1()
/opt/homebrew/Cellar/go/1.23.1/libexec/src/testing/testing.go:1743 +0x40
```1 parent f016ea2 commit d2db6af
2 files changed
+24
-1
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
79 | 79 | | |
80 | 80 | | |
81 | 81 | | |
82 | | - | |
83 | 82 | | |
84 | 83 | | |
85 | 84 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
0 commit comments