Squash a few trivial TODOs.

- Delete unneeded file view_adapter.go.
- Assessed that we still need the fingerprints in nodes
  (to create iterators).
- Turned numMemChunkDescs into a metric.

Change-Id: I29be963c795a075ec00c095f76bf26405535609d
This commit is contained in:
Bjoern Rabenstein 2014-11-27 18:25:03 +01:00
parent 49683c0c20
commit 7d11019aa2
7 changed files with 14 additions and 35 deletions

View file

@ -193,7 +193,6 @@ type (
iterators map[clientmodel.Fingerprint]local.SeriesIterator
metrics map[clientmodel.Fingerprint]clientmodel.Metric
// Fingerprints are populated from label matchers at query analysis time.
// TODO: do we still need these?
fingerprints clientmodel.Fingerprints
}
@ -234,7 +233,6 @@ type (
iterators map[clientmodel.Fingerprint]local.SeriesIterator
metrics map[clientmodel.Fingerprint]clientmodel.Metric
// Fingerprints are populated from label matchers at query analysis time.
// TODO: do we still need these?
fingerprints clientmodel.Fingerprints
interval time.Duration
}

View file

@ -1,16 +0,0 @@
// Copyright 2013 Prometheus Team
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
package ast
// TODO: remove file.

View file

@ -45,9 +45,7 @@ type chunkDesc struct {
func newChunkDesc(c chunk) *chunkDesc {
chunkOps.WithLabelValues(createAndPin).Inc()
atomic.AddInt64(&numMemChunks, 1)
// TODO: numMemChunkDescs is actually never read except during metrics
// collection. Turn it into a real metric.
atomic.AddInt64(&numMemChunkDescs, 1)
numMemChunkDescs.Inc()
return &chunkDesc{chunk: c, refCount: 1}
}

View file

@ -37,6 +37,12 @@ var (
},
[]string{opTypeLabel},
)
numMemChunkDescs = prometheus.NewGauge(prometheus.GaugeOpts{
Namespace: namespace,
Subsystem: subsystem,
Name: "memory_chunkdescs",
Help: "The current number of chunk descriptors in memory.",
})
)
const (
@ -71,12 +77,13 @@ const (
func init() {
prometheus.MustRegister(chunkOps)
prometheus.MustRegister(chunkDescOps)
prometheus.MustRegister(numMemChunkDescs)
}
var (
// Global counters, also used internally, so not implemented as
// Global counter, also used internally, so not implemented as
// metrics. Collected in memorySeriesStorage.Collect.
numMemChunks, numMemChunkDescs int64
numMemChunks int64
// Metric descriptors for the above.
numMemChunksDesc = prometheus.NewDesc(
@ -84,9 +91,4 @@ var (
"The current number of chunks in memory, excluding cloned chunks (i.e. chunks without a descriptor).",
nil, nil,
)
numMemChunkDescsDesc = prometheus.NewDesc(
prometheus.BuildFQName(namespace, subsystem, "memory_chunkdescs"),
"The current number of chunk descriptors in memory.",
nil, nil,
)
)

View file

@ -766,7 +766,7 @@ func (p *persistence) loadChunkDescs(fp clientmodel.Fingerprint, beforeTime clie
cds = append(cds, cd)
}
chunkDescOps.WithLabelValues(load).Add(float64(len(cds)))
atomic.AddInt64(&numMemChunkDescs, int64(len(cds)))
numMemChunkDescs.Add(float64(len(cds)))
return cds, nil
}
@ -916,7 +916,7 @@ func (p *persistence) loadSeriesMapAndHeads() (sm *seriesMap, err error) {
}
if err == nil {
atomic.AddInt64(&numMemChunks, chunksTotal)
atomic.AddInt64(&numMemChunkDescs, chunkDescsTotal)
numMemChunkDescs.Add(float64(chunkDescsTotal))
}
}()

View file

@ -235,7 +235,7 @@ func (s *memorySeries) evictChunkDescs(iOldestNotEvicted int) {
lenEvicted := len(s.chunkDescs) - lenToKeep
s.chunkDescsOffset += lenEvicted
chunkDescOps.WithLabelValues(evict).Add(float64(lenEvicted))
atomic.AddInt64(&numMemChunkDescs, -int64(lenEvicted))
numMemChunkDescs.Sub(float64(lenEvicted))
s.chunkDescs = append(
make([]*chunkDesc, 0, lenToKeep),
s.chunkDescs[lenEvicted:]...,
@ -257,7 +257,7 @@ func (s *memorySeries) purgeOlderThan(t clientmodel.Timestamp) (int, bool) {
}
if keepIdx > 0 {
s.chunkDescs = append(make([]*chunkDesc, 0, len(s.chunkDescs)-keepIdx), s.chunkDescs[keepIdx:]...)
atomic.AddInt64(&numMemChunkDescs, -int64(keepIdx))
numMemChunkDescs.Sub(float64(keepIdx))
}
return keepIdx, len(s.chunkDescs) == 0
}

View file

@ -801,7 +801,6 @@ func (s *memorySeriesStorage) Describe(ch chan<- *prometheus.Desc) {
ch <- persistQueueCapDesc
ch <- numMemChunksDesc
ch <- numMemChunkDescsDesc
}
// Collect implements prometheus.Collector.
@ -820,6 +819,4 @@ func (s *memorySeriesStorage) Collect(ch chan<- prometheus.Metric) {
count := atomic.LoadInt64(&numMemChunks)
ch <- prometheus.MustNewConstMetric(numMemChunksDesc, prometheus.GaugeValue, float64(count))
count = atomic.LoadInt64(&numMemChunkDescs)
ch <- prometheus.MustNewConstMetric(numMemChunkDescsDesc, prometheus.GaugeValue, float64(count))
}