mirror of
https://gitlab.torproject.org/tpo/anti-censorship/pluggable-transports/snowflake.git
synced 2025-10-14 05:11:19 -04:00
Remove sync.Once from around logMetrics
Follow up to160ae2d
Analysis by @dcf, > I don't think the sync.Once around logMetrics is necessary anymore. Its original purpose was to inhibit logging on later file handles of metrics.log, if there were more than one opened. See171c55a9
and #29734 (comment 2593039) "Making a singleton *Metrics variable causes problems with how Convey does tests. It shouldn't be called more than once, but for now I'm using sync.Once on the logging at least so it's explicit." Commitba4fe1a7
changed it so that metrics.log is opened in main, used to create a *log.Logger, and that same instance of *log.Logger is passed to both NewMetrics and NewBrokerContext. It's safe to share the same *log.Logger across multiple BrokerContext.
This commit is contained in:
parent
160ae2dd71
commit
7ef49272fa
1 changed files with 1 additions and 2 deletions
|
@ -53,7 +53,6 @@ type Metrics struct {
|
||||||
lock sync.Mutex
|
lock sync.Mutex
|
||||||
|
|
||||||
promMetrics *PromMetrics
|
promMetrics *PromMetrics
|
||||||
once sync.Once
|
|
||||||
}
|
}
|
||||||
|
|
||||||
type record struct {
|
type record struct {
|
||||||
|
@ -202,7 +201,7 @@ func NewMetrics(metricsLogger *log.Logger) (*Metrics, error) {
|
||||||
m.promMetrics = initPrometheus()
|
m.promMetrics = initPrometheus()
|
||||||
|
|
||||||
// Write to log file every hour with updated metrics
|
// Write to log file every hour with updated metrics
|
||||||
go m.once.Do(m.logMetrics)
|
go m.logMetrics()
|
||||||
|
|
||||||
return m, nil
|
return m, nil
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue