mirror of
https://github.com/prometheus/prometheus.git
synced 2024-11-10 15:44:05 -08:00
Merge branch 'beorn7/fix-deadlock' into beorn7/storage3
This commit is contained in:
commit
536e0bc86b
|
@ -22,7 +22,6 @@ scrape_configs:
|
||||||
|
|
||||||
# Override the global default and scrape targets from this job every 5 seconds.
|
# Override the global default and scrape targets from this job every 5 seconds.
|
||||||
scrape_interval: 5s
|
scrape_interval: 5s
|
||||||
scrape_timeout: 10s
|
|
||||||
|
|
||||||
# metrics_path defaults to '/metrics'
|
# metrics_path defaults to '/metrics'
|
||||||
# scheme defaults to 'http'.
|
# scheme defaults to 'http'.
|
||||||
|
|
|
@ -335,6 +335,7 @@ func (t *Target) path() string {
|
||||||
}
|
}
|
||||||
|
|
||||||
// wrapAppender wraps a SampleAppender for samples ingested from the target.
|
// wrapAppender wraps a SampleAppender for samples ingested from the target.
|
||||||
|
// RLock must be acquired by the caller.
|
||||||
func (t *Target) wrapAppender(app storage.SampleAppender) storage.SampleAppender {
|
func (t *Target) wrapAppender(app storage.SampleAppender) storage.SampleAppender {
|
||||||
// The relabelAppender has to be inside the label-modifying appenders
|
// The relabelAppender has to be inside the label-modifying appenders
|
||||||
// so the relabeling rules are applied to the correct label set.
|
// so the relabeling rules are applied to the correct label set.
|
||||||
|
@ -348,12 +349,12 @@ func (t *Target) wrapAppender(app storage.SampleAppender) storage.SampleAppender
|
||||||
if t.scrapeConfig.HonorLabels {
|
if t.scrapeConfig.HonorLabels {
|
||||||
app = honorLabelsAppender{
|
app = honorLabelsAppender{
|
||||||
SampleAppender: app,
|
SampleAppender: app,
|
||||||
labels: t.Labels(),
|
labels: t.unlockedLabels(),
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
app = ruleLabelsAppender{
|
app = ruleLabelsAppender{
|
||||||
SampleAppender: app,
|
SampleAppender: app,
|
||||||
labels: t.Labels(),
|
labels: t.unlockedLabels(),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return app
|
return app
|
||||||
|
@ -361,6 +362,7 @@ func (t *Target) wrapAppender(app storage.SampleAppender) storage.SampleAppender
|
||||||
|
|
||||||
// wrapReportingAppender wraps an appender for target status report samples.
|
// wrapReportingAppender wraps an appender for target status report samples.
|
||||||
// It ignores any relabeling rules set for the target.
|
// It ignores any relabeling rules set for the target.
|
||||||
|
// RLock must not be acquired by the caller.
|
||||||
func (t *Target) wrapReportingAppender(app storage.SampleAppender) storage.SampleAppender {
|
func (t *Target) wrapReportingAppender(app storage.SampleAppender) storage.SampleAppender {
|
||||||
return ruleLabelsAppender{
|
return ruleLabelsAppender{
|
||||||
SampleAppender: app,
|
SampleAppender: app,
|
||||||
|
@ -647,6 +649,12 @@ func (t *Target) Labels() model.LabelSet {
|
||||||
t.RLock()
|
t.RLock()
|
||||||
defer t.RUnlock()
|
defer t.RUnlock()
|
||||||
|
|
||||||
|
return t.unlockedLabels()
|
||||||
|
}
|
||||||
|
|
||||||
|
// unlockedLabels does the same as Labels but does not lock the mutex (useful
|
||||||
|
// for internal usage when the mutex is already locked).
|
||||||
|
func (t *Target) unlockedLabels() model.LabelSet {
|
||||||
lset := make(model.LabelSet, len(t.labels))
|
lset := make(model.LabelSet, len(t.labels))
|
||||||
for ln, lv := range t.labels {
|
for ln, lv := range t.labels {
|
||||||
if !strings.HasPrefix(string(ln), model.ReservedLabelPrefix) {
|
if !strings.HasPrefix(string(ln), model.ReservedLabelPrefix) {
|
||||||
|
|
Loading…
Reference in a new issue