Skip to content

Commit 716e04c

Browse files
committed
Add MCSR gauge to ConnectionMetric snapshots
Register a ConnectionMetricCallback in the search pool router that reports each node's adaptive max_concurrent_shard_requests value. The callback is gated at registration by adaptiveConcurrencyEnabled(), so the per-snapshot path is unconditional — no locks needed since loadCwnd() is atomic and computeAdaptiveConcurrency() is pure math. Signed-off-by: Sean Chittenden <sean.chittenden@crowdstrike.com>
1 parent a9759ab commit 716e04c

1 file changed

Lines changed: 16 additions & 0 deletions

File tree

opensearchtransport/policy_pool_router.go

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -387,6 +387,22 @@ func (p *poolRouter) configurePolicySettings(config policyConfig) error {
387387
p.poolInfoReady = config.poolInfoReady
388388
p.clusterSearchCwnd = config.clusterSearchCwnd
389389

390+
// Register the MCSR metric callback for the search pool so that
391+
// ConnectionMetric snapshots include the current per-node value.
392+
if p.poolName == "search" && config.metrics != nil && p.cache.features.adaptiveConcurrencyEnabled() {
393+
cache := p.cache
394+
poolInfoReady := p.poolInfoReady
395+
config.metrics.connMetricCallbacks = append(config.metrics.connMetricCallbacks,
396+
func(conns []*Connection, cms []ConnectionMetric) error {
397+
for i, conn := range conns {
398+
cwnd := conn.loadCwnd("search", loadPoolInfoReady(poolInfoReady))
399+
mcsr := computeAdaptiveConcurrency(cwnd, cache.adaptiveConcurrency, cache.features)
400+
cms[i].MCSR = &mcsr
401+
}
402+
return nil
403+
})
404+
}
405+
390406
// Register the router cache snapshot callback.
391407
if config.metrics != nil {
392408
cache := p.cache

0 commit comments

Comments
 (0)