@@ -15,7 +15,6 @@ import (
15
15
"github.com/improbable-eng/thanos/pkg/store/storepb"
16
16
"github.com/improbable-eng/thanos/pkg/strutil"
17
17
"github.com/pkg/errors"
18
- "github.com/prometheus/client_golang/prometheus"
19
18
"github.com/prometheus/tsdb/labels"
20
19
"golang.org/x/sync/errgroup"
21
20
"google.golang.org/grpc/codes"
@@ -45,50 +44,28 @@ type ProxyStore struct {
45
44
component component.StoreAPI
46
45
selectorLabels labels.Labels
47
46
48
- responseTimeout time.Duration
49
- streamResponseDuration * prometheus.HistogramVec
50
- streamDuration * prometheus.HistogramVec
47
+ responseTimeout time.Duration
51
48
}
52
49
53
50
// NewProxyStore returns a new ProxyStore that uses the given clients that implements storeAPI to fan-in all series to the client.
54
51
// Note that there is no deduplication support. Deduplication should be done on the highest level (just before PromQL)
55
52
func NewProxyStore (
56
53
logger log.Logger ,
57
- reg prometheus.Registerer ,
58
54
stores func () []Client ,
59
55
component component.StoreAPI ,
60
56
selectorLabels labels.Labels ,
61
57
responseTimeout time.Duration ,
62
58
) * ProxyStore {
63
- streamResponseDuration := prometheus .NewHistogramVec (prometheus.HistogramOpts {
64
- Name : "thanos_query_stream_read_duration_seconds" ,
65
- Help : "Time it takes to perform a single read from GRPC stream." ,
66
- Buckets : []float64 {
67
- 0.005 , 0.01 , 0.02 , 0.03 , 0.04 , 0.05 , 0.1 , 0.25 , 0.6 , 1 , 2 , 3.5 , 5 ,
68
- }}, []string {"store" })
69
- streamDuration := prometheus .NewHistogramVec (prometheus.HistogramOpts {
70
- Name : "thanos_query_stream_duration_seconds" ,
71
- Help : "Time it takes to consume GRPC stream." ,
72
- Buckets : []float64 {
73
- 0.01 , 0.02 , 0.03 , 0.04 , 0.05 , 0.1 , 0.25 , 0.6 , 1 , 2 , 3.5 , 5 , 7.5 , 10 , 15 , 20 ,
74
- }}, []string {"store" })
75
- reg .MustRegister (
76
- streamResponseDuration ,
77
- streamDuration ,
78
- )
79
-
80
59
if logger == nil {
81
60
logger = log .NewNopLogger ()
82
61
}
83
62
84
63
s := & ProxyStore {
85
- logger : logger ,
86
- stores : stores ,
87
- component : component ,
88
- selectorLabels : selectorLabels ,
89
- responseTimeout : responseTimeout ,
90
- streamResponseDuration : streamResponseDuration ,
91
- streamDuration : streamDuration ,
64
+ logger : logger ,
65
+ stores : stores ,
66
+ component : component ,
67
+ selectorLabels : selectorLabels ,
68
+ responseTimeout : responseTimeout ,
92
69
}
93
70
return s
94
71
}
@@ -198,7 +175,7 @@ func (s *ProxyStore) Series(r *storepb.SeriesRequest, srv storepb.Store_SeriesSe
198
175
}
199
176
200
177
// Schedule streamSeriesSet that translates gRPC streamed response into seriesSet (if series) or respCh if warnings.
201
- seriesSet = append (seriesSet , startStreamSeriesSet (seriesCtx , s .logger , closeSeries , wg , sc , respSender , st .String (), ! r .PartialResponseDisabled , s .responseTimeout , s . streamResponseDuration . WithLabelValues ( st . Addr ()), s . streamDuration . WithLabelValues ( st . Addr ()) ))
178
+ seriesSet = append (seriesSet , startStreamSeriesSet (seriesCtx , s .logger , closeSeries , wg , sc , respSender , st .String (), ! r .PartialResponseDisabled , s .responseTimeout ))
202
179
}
203
180
204
181
level .Debug (s .logger ).Log ("msg" , strings .Join (storeDebugMsgs , ";" ))
@@ -254,10 +231,8 @@ type streamSeriesSet struct {
254
231
name string
255
232
partialResponse bool
256
233
257
- responseTimeout time.Duration
258
- closeSeries context.CancelFunc
259
- streamResponseDuration prometheus.Observer
260
- streamDuration prometheus.Observer
234
+ responseTimeout time.Duration
235
+ closeSeries context.CancelFunc
261
236
}
262
237
263
238
func startStreamSeriesSet (
@@ -270,35 +245,26 @@ func startStreamSeriesSet(
270
245
name string ,
271
246
partialResponse bool ,
272
247
responseTimeout time.Duration ,
273
- streamResponseDuration prometheus.Observer ,
274
- streamDuration prometheus.Observer ,
275
248
) * streamSeriesSet {
276
249
s := & streamSeriesSet {
277
- ctx : ctx ,
278
- logger : logger ,
279
- closeSeries : closeSeries ,
280
- stream : stream ,
281
- warnCh : warnCh ,
282
- recvCh : make (chan * storepb.Series , 10 ),
283
- name : name ,
284
- partialResponse : partialResponse ,
285
- responseTimeout : responseTimeout ,
286
- streamResponseDuration : streamResponseDuration ,
287
- streamDuration : streamDuration ,
250
+ ctx : ctx ,
251
+ logger : logger ,
252
+ closeSeries : closeSeries ,
253
+ stream : stream ,
254
+ warnCh : warnCh ,
255
+ recvCh : make (chan * storepb.Series , 10 ),
256
+ name : name ,
257
+ partialResponse : partialResponse ,
258
+ responseTimeout : responseTimeout ,
288
259
}
289
260
290
261
wg .Add (1 )
291
262
go func () {
292
263
defer wg .Done ()
293
264
defer close (s .recvCh )
294
265
295
- timer := prometheus .NewTimer (s .streamDuration )
296
- defer timer .ObserveDuration ()
297
-
298
266
for {
299
- timer := prometheus .NewTimer (s .streamResponseDuration )
300
267
r , err := s .stream .Recv ()
301
- timer .ObserveDuration ()
302
268
303
269
if err == io .EOF {
304
270
return
0 commit comments