Skip to content

Commit

Permalink
Merge pull request #109 from vinted/pull_pr_7336
Browse files Browse the repository at this point in the history
*: pull PR 7336
  • Loading branch information
GiedriusS authored Jun 3, 2024
2 parents 13610e4 + 1f1575f commit 0cfdd6a
Showing 1 changed file with 10 additions and 3 deletions.
13 changes: 10 additions & 3 deletions pkg/query/endpointset.go
Original file line number Diff line number Diff line change
Expand Up @@ -197,15 +197,17 @@ type endpointSetNodeCollector struct {
storeNodes map[component.Component]map[string]int
storePerExtLset map[string]int

logger log.Logger
connectionsDesc *prometheus.Desc
labels []string
}

func newEndpointSetNodeCollector(labels ...string) *endpointSetNodeCollector {
func newEndpointSetNodeCollector(logger log.Logger, labels ...string) *endpointSetNodeCollector {
if len(labels) == 0 {
labels = []string{string(ExternalLabels), string(StoreType)}
}
return &endpointSetNodeCollector{
logger: logger,
storeNodes: map[component.Component]map[string]int{},
connectionsDesc: prometheus.NewDesc(
"thanos_store_nodes_grpc_connections",
Expand Down Expand Up @@ -272,7 +274,12 @@ func (c *endpointSetNodeCollector) Collect(ch chan<- prometheus.Metric) {
lbls = append(lbls, storeTypeStr)
}
}
ch <- prometheus.MustNewConstMetric(c.connectionsDesc, prometheus.GaugeValue, float64(occurrences), lbls...)
select {
case ch <- prometheus.MustNewConstMetric(c.connectionsDesc, prometheus.GaugeValue, float64(occurrences), lbls...):
case <-time.After(1 * time.Second):
level.Warn(c.logger).Log("msg", "failed to collect endpointset metrics", "timeout", 1*time.Second)
return
}
}
}
}
Expand Down Expand Up @@ -314,7 +321,7 @@ func NewEndpointSet(
endpointInfoTimeout time.Duration,
endpointMetricLabels ...string,
) *EndpointSet {
endpointsMetric := newEndpointSetNodeCollector(endpointMetricLabels...)
endpointsMetric := newEndpointSetNodeCollector(logger, endpointMetricLabels...)
if reg != nil {
reg.MustRegister(endpointsMetric)
}
Expand Down

0 comments on commit 0cfdd6a

Please sign in to comment.