@@ -202,15 +202,17 @@ type endpointSetNodeCollector struct {
202
202
storeNodes map [component.Component ]map [string ]int
203
203
storePerExtLset map [string ]int
204
204
205
+ logger log.Logger
205
206
connectionsDesc * prometheus.Desc
206
207
labels []string
207
208
}
208
209
209
- func newEndpointSetNodeCollector (labels ... string ) * endpointSetNodeCollector {
210
+ func newEndpointSetNodeCollector (logger log. Logger , labels ... string ) * endpointSetNodeCollector {
210
211
if len (labels ) == 0 {
211
212
labels = []string {string (ExternalLabels ), string (StoreType )}
212
213
}
213
214
return & endpointSetNodeCollector {
215
+ logger : logger ,
214
216
storeNodes : map [component.Component ]map [string ]int {},
215
217
connectionsDesc : prometheus .NewDesc (
216
218
"thanos_store_nodes_grpc_connections" ,
@@ -277,7 +279,12 @@ func (c *endpointSetNodeCollector) Collect(ch chan<- prometheus.Metric) {
277
279
lbls = append (lbls , storeTypeStr )
278
280
}
279
281
}
280
- ch <- prometheus .MustNewConstMetric (c .connectionsDesc , prometheus .GaugeValue , float64 (occurrences ), lbls ... )
282
+ select {
283
+ case ch <- prometheus .MustNewConstMetric (c .connectionsDesc , prometheus .GaugeValue , float64 (occurrences ), lbls ... ):
284
+ case <- time .After (1 * time .Second ):
285
+ level .Warn (c .logger ).Log ("msg" , "failed to collect endpointset metrics" , "timeout" , 1 * time .Second )
286
+ return
287
+ }
281
288
}
282
289
}
283
290
}
@@ -319,7 +326,7 @@ func NewEndpointSet(
319
326
endpointInfoTimeout time.Duration ,
320
327
endpointMetricLabels ... string ,
321
328
) * EndpointSet {
322
- endpointsMetric := newEndpointSetNodeCollector (endpointMetricLabels ... )
329
+ endpointsMetric := newEndpointSetNodeCollector (logger , endpointMetricLabels ... )
323
330
if reg != nil {
324
331
reg .MustRegister (endpointsMetric )
325
332
}
0 commit comments