Skip to content

Commit 011501f

Browse files
authored
Merge branch 'main' into slow-query-logs-user-header
2 parents f062718 + 9db31c2 commit 011501f

File tree

1 file changed

+10
-3
lines changed

1 file changed

+10
-3
lines changed

pkg/query/endpointset.go

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -202,15 +202,17 @@ type endpointSetNodeCollector struct {
202202
storeNodes map[component.Component]map[string]int
203203
storePerExtLset map[string]int
204204

205+
logger log.Logger
205206
connectionsDesc *prometheus.Desc
206207
labels []string
207208
}
208209

209-
func newEndpointSetNodeCollector(labels ...string) *endpointSetNodeCollector {
210+
func newEndpointSetNodeCollector(logger log.Logger, labels ...string) *endpointSetNodeCollector {
210211
if len(labels) == 0 {
211212
labels = []string{string(ExternalLabels), string(StoreType)}
212213
}
213214
return &endpointSetNodeCollector{
215+
logger: logger,
214216
storeNodes: map[component.Component]map[string]int{},
215217
connectionsDesc: prometheus.NewDesc(
216218
"thanos_store_nodes_grpc_connections",
@@ -277,7 +279,12 @@ func (c *endpointSetNodeCollector) Collect(ch chan<- prometheus.Metric) {
277279
lbls = append(lbls, storeTypeStr)
278280
}
279281
}
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+
}
281288
}
282289
}
283290
}
@@ -319,7 +326,7 @@ func NewEndpointSet(
319326
endpointInfoTimeout time.Duration,
320327
endpointMetricLabels ...string,
321328
) *EndpointSet {
322-
endpointsMetric := newEndpointSetNodeCollector(endpointMetricLabels...)
329+
endpointsMetric := newEndpointSetNodeCollector(logger, endpointMetricLabels...)
323330
if reg != nil {
324331
reg.MustRegister(endpointsMetric)
325332
}

0 commit comments

Comments
 (0)