Merge pull request #187 from prometheus/fix/goroutine-leak

Have goroutine exit on signal via defer block.
This commit is contained in:
Matt T. Proud 2013-04-25 05:12:09 -07:00
commit d46f2fd549
2 changed files with 4 additions and 6 deletions

View File

@ -164,14 +164,12 @@ func (t *tieredStorage) Serve() {
var (
flushMemoryTicker = time.Tick(t.flushMemoryInterval)
writeMemoryTicker = time.Tick(t.writeMemoryInterval)
reportTicker = time.NewTicker(time.Second)
)
defer reportTicker.Stop()
go func() {
reportTicker := time.Tick(time.Second)
for {
<-reportTicker
for _ = range reportTicker.C {
t.reportQueues()
}
}()

View File

@ -508,7 +508,6 @@ func TestGetAllValuesForLabel(t *testing.T) {
for i, scenario := range scenarios {
tiered, closer := newTestTieredStorage(t)
defer closer.Close()
for j, metric := range scenario.in {
sample := model.Sample{
Metric: model.Metric{model.MetricNameLabel: model.LabelValue(metric.metricName)},
@ -525,6 +524,7 @@ func TestGetAllValuesForLabel(t *testing.T) {
}
}
metricNames, err := tiered.GetAllValuesForLabel(model.MetricNameLabel)
closer.Close()
if err != nil {
t.Fatalf("%d. Error getting metric names: %s", i, err)
}