add mutex for DiscoveredLabels
Signed-off-by: Krasi Georgiev <krasi.root@gmail.com>
This commit is contained in:
parent
e65fc8591a
commit
dc29dd1c6f
|
@ -110,6 +110,8 @@ func (t *Target) Labels() labels.Labels {
|
||||||
|
|
||||||
// DiscoveredLabels returns a copy of the target's labels before any processing.
|
// DiscoveredLabels returns a copy of the target's labels before any processing.
|
||||||
func (t *Target) DiscoveredLabels() labels.Labels {
|
func (t *Target) DiscoveredLabels() labels.Labels {
|
||||||
|
t.mtx.Lock()
|
||||||
|
defer t.mtx.Unlock()
|
||||||
lset := make(labels.Labels, len(t.discoveredLabels))
|
lset := make(labels.Labels, len(t.discoveredLabels))
|
||||||
copy(lset, t.discoveredLabels)
|
copy(lset, t.discoveredLabels)
|
||||||
return lset
|
return lset
|
||||||
|
@ -117,6 +119,8 @@ func (t *Target) DiscoveredLabels() labels.Labels {
|
||||||
|
|
||||||
// SetDiscoveredLabels sets new DiscoveredLabels
|
// SetDiscoveredLabels sets new DiscoveredLabels
|
||||||
func (t *Target) SetDiscoveredLabels(l labels.Labels) {
|
func (t *Target) SetDiscoveredLabels(l labels.Labels) {
|
||||||
|
t.mtx.Lock()
|
||||||
|
defer t.mtx.Unlock()
|
||||||
t.discoveredLabels = l
|
t.discoveredLabels = l
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue