mirror of
https://github.com/prometheus/statsd_exporter.git
synced 2024-11-22 15:30:59 +00:00
Add comments about thread-safety
Signed-off-by: glightfoot <glightfoot@rsglab.com>
This commit is contained in:
parent
8b306c8c76
commit
a197834f64
2 changed files with 3 additions and 1 deletions
|
@ -263,6 +263,8 @@ func (m *MetricMapper) InitFromFile(fileName string) error {
|
||||||
return m.InitFromYAMLString(string(mappingStr))
|
return m.InitFromYAMLString(string(mappingStr))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// UseCache tells the mapper to use a cache that implements the MetricMapperCache interface.
|
||||||
|
// This cache MUST be thread-safe!
|
||||||
func (m *MetricMapper) UseCache(cache MetricMapperCache) {
|
func (m *MetricMapper) UseCache(cache MetricMapperCache) {
|
||||||
m.mutex.Lock()
|
m.mutex.Lock()
|
||||||
defer m.mutex.Unlock()
|
defer m.mutex.Unlock()
|
||||||
|
|
|
@ -59,7 +59,7 @@ type MetricMapperCacheResult struct {
|
||||||
Labels prometheus.Labels
|
Labels prometheus.Labels
|
||||||
}
|
}
|
||||||
|
|
||||||
// MetricMapperCache must be thread-safe and should be instrumented with CacheMetrics
|
// MetricMapperCache MUST be thread-safe and should be instrumented with CacheMetrics
|
||||||
type MetricMapperCache interface {
|
type MetricMapperCache interface {
|
||||||
// Get a cached result
|
// Get a cached result
|
||||||
Get(metricKey string) (interface{}, bool)
|
Get(metricKey string) (interface{}, bool)
|
||||||
|
|
Loading…
Reference in a new issue