Remove fullLabels method and fix target updating

With recent changes to a Target's internal data representation
updating by fullLabels() assigns the additional default
instance label. This breaks target identity comparison and causes
identical targets from service discovery to be constantly swapped.
This commit is contained in:
Fabian Reinartz 2016-02-22 13:06:30 +01:00
parent 209c4ad64f
commit 6df1f49c13
2 changed files with 1 additions and 13 deletions

View File

@ -405,18 +405,6 @@ func (t *Target) InstanceIdentifier() string {
return t.host()
}
func (t *Target) fullLabels() model.LabelSet {
t.RLock()
defer t.RUnlock()
lset := t.labels.Clone()
if _, ok := lset[model.InstanceLabel]; !ok {
lset[model.InstanceLabel] = t.labels[model.AddressLabel]
}
return lset
}
// RunScraper implements Target.
func (t *Target) RunScraper(sampleAppender storage.SampleAppender) {
defer close(t.scraperStopped)

View File

@ -278,7 +278,7 @@ func (tm *TargetManager) updateTargetGroup(tgroup *config.TargetGroup, cfg *conf
// to build up.
wg.Add(1)
go func(t *Target) {
if err := match.Update(cfg, t.fullLabels(), t.metaLabels); err != nil {
if err := match.Update(cfg, t.labels, t.metaLabels); err != nil {
log.Errorf("Error updating target %v: %v", t, err)
}
wg.Done()