Commit 4aa6e83 1 parent c2a1ae8 commit 4aa6e83 Copy full SHA for 4aa6e83
File tree 2 files changed +16
-11
lines changed
2 files changed +16
-11
lines changed Original file line number Diff line number Diff line change @@ -137,10 +137,7 @@ func (bt *BloomTokenizer) Populate(
137
137
// If a bloom is full, the chunk wasn't completely added
138
138
// so we'll submit this bloom, start a new one, and continue indexing
139
139
if full {
140
- ch <- & BloomCreation {
141
- Bloom : bloom ,
142
- SourceBytesAdded : bytesAdded ,
143
- }
140
+ bt .sendBloom (ch , bloom , bytesAdded )
144
141
145
142
// start a new bloom + reset bytesAdded counter
146
143
bytesAdded = 0
@@ -158,11 +155,25 @@ func (bt *BloomTokenizer) Populate(
158
155
}
159
156
160
157
// Send the last bloom
158
+ bt .sendBloom (ch , bloom , bytesAdded )
159
+ close (ch )
160
+ }
161
+
162
+ func (bt * BloomTokenizer ) sendBloom (
163
+ ch chan <- * BloomCreation ,
164
+ bloom * Bloom ,
165
+ bytesAdded int ,
166
+ ) {
167
+ fillRatio := bloom .ScalableBloomFilter .FillRatio ()
168
+ bt .metrics .hammingWeightRatio .Observe (fillRatio )
169
+ bt .metrics .estimatedCount .Observe (
170
+ float64 (estimatedCount (bloom .ScalableBloomFilter .Capacity (), fillRatio )),
171
+ )
172
+ bt .metrics .bloomSize .Observe (float64 (bloom .ScalableBloomFilter .Capacity () / eightBits ))
161
173
ch <- & BloomCreation {
162
174
Bloom : bloom ,
163
175
SourceBytesAdded : bytesAdded ,
164
176
}
165
- close (ch )
166
177
}
167
178
168
179
// addChunkToBloom adds the tokens from the given chunk to the given bloom.
Original file line number Diff line number Diff line change @@ -10,7 +10,6 @@ import (
10
10
type Metrics struct {
11
11
// writes
12
12
bloomsTotal * prometheus.CounterVec // number of blooms created
13
- sbfCreationTime * prometheus.CounterVec // time spent creating sbfs
14
13
bloomSize prometheus.Histogram // size of the bloom filter in bytes
15
14
hammingWeightRatio prometheus.Histogram // ratio of the hamming weight of the bloom filter to the number of bits in the bloom filter
16
15
estimatedCount prometheus.Histogram // estimated number of elements in the bloom filter
@@ -68,11 +67,6 @@ func NewMetrics(r prometheus.Registerer) *Metrics {
68
67
Name : "blooms_created_total" ,
69
68
Help : "Number of blooms created" ,
70
69
}, []string {"type" }),
71
- sbfCreationTime : promauto .With (r ).NewCounterVec (prometheus.CounterOpts {
72
- Namespace : constants .Loki ,
73
- Name : "bloom_creation_time_total" ,
74
- Help : "Time spent creating scalable bloom filters" ,
75
- }, []string {"type" }),
76
70
bloomSize : promauto .With (r ).NewHistogram (prometheus.HistogramOpts {
77
71
Namespace : constants .Loki ,
78
72
Name : "bloom_size" ,
You can’t perform that action at this time.
0 commit comments