diff --git a/rules/ast/ast.go b/rules/ast/ast.go index cf720eaed..79cc768f2 100644 --- a/rules/ast/ast.go +++ b/rules/ast/ast.go @@ -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 } diff --git a/rules/ast/view_adapter.go b/rules/ast/view_adapter.go deleted file mode 100644 index dc18611e8..000000000 --- a/rules/ast/view_adapter.go +++ /dev/null @@ -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. diff --git a/storage/local/chunk.go b/storage/local/chunk.go index c0f47d467..0145e2e15 100644 --- a/storage/local/chunk.go +++ b/storage/local/chunk.go @@ -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} } diff --git a/storage/local/instrumentation.go b/storage/local/instrumentation.go index 58f6125a2..9d11fbfeb 100644 --- a/storage/local/instrumentation.go +++ b/storage/local/instrumentation.go @@ -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, - ) ) diff --git a/storage/local/persistence.go b/storage/local/persistence.go index 513bf726b..da4ebfde2 100644 --- a/storage/local/persistence.go +++ b/storage/local/persistence.go @@ -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)) } }() diff --git a/storage/local/series.go b/storage/local/series.go index 8910cbd6f..62dc84e01 100644 --- a/storage/local/series.go +++ b/storage/local/series.go @@ -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 } diff --git a/storage/local/storage.go b/storage/local/storage.go index 20d807083..f19808eb0 100644 --- a/storage/local/storage.go +++ b/storage/local/storage.go @@ -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)) }