Skip to content

Fix mongodb_connections metric for mongos instances#1151

Open
vtomasr5 wants to merge 8 commits into
percona:mainfrom
vtomasr5:mongodb_connections_for_mongos
Open

Fix mongodb_connections metric for mongos instances#1151
vtomasr5 wants to merge 8 commits into
percona:mainfrom
vtomasr5:mongodb_connections_for_mongos

Conversation

@vtomasr5

@vtomasr5 vtomasr5 commented Aug 20, 2025

Copy link
Copy Markdown

The getDiagnosticData command returns empty data for mongos, causing connection metrics to be missing. This adds a fallback to serverStatus when getDiagnosticData returns empty data for mongos instances.

This ensures that mongodb_connections (and mongodb_ss_connections) metrics are properly exposed for mongos routers, maintaining compatibility with monitoring dashboards and alerting rules.

May fix #916

@vtomasr5
vtomasr5 requested review from a team, BupycHuk and JiriCtvrtka and removed request for a team August 20, 2025 11:40
@it-percona-cla

it-percona-cla commented Aug 20, 2025

Copy link
Copy Markdown

CLA assistant check
All committers have signed the CLA.

@codecov

codecov Bot commented Sep 1, 2025

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 53.84615% with 6 lines in your changes missing coverage. Please review.
✅ Project coverage is 68.72%. Comparing base (dc46ed5) to head (697ffeb).
⚠️ Report is 230 commits behind head on main.

Files with missing lines Patch % Lines
exporter/diagnostic_data_collector.go 53.84% 2 Missing and 4 partials ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #1151      +/-   ##
==========================================
- Coverage   70.88%   68.72%   -2.16%     
==========================================
  Files          28       29       +1     
  Lines        3569     2440    -1129     
==========================================
- Hits         2530     1677     -853     
+ Misses        904      589     -315     
- Partials      135      174      +39     
Flag Coverage Δ
agent 68.72% <53.84%> (-2.16%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@idoqo

idoqo commented Sep 27, 2025

Copy link
Copy Markdown
Contributor

Thanks a lot for your contribution @vtomasr5 .

If you're still up, can we add some tests for mongos instances? Maybe something similar to TestAllDiagnosticDataCollectorMetrics but connected to the mongos instance instead - only checking for mongodb_ss_connections_* is fine.

Additionally, you can sync this branch with current main and it should fix the duplicate metrics errors in CI.

@JiriCtvrtka

Copy link
Copy Markdown
Contributor

@ademidoff
ademidoff requested a review from a team as a code owner April 7, 2026 08:00
@ademidoff
ademidoff requested review from ademidoff and maxkondr and removed request for a team and BupycHuk April 7, 2026 08:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

mongodb_connections metric not available

5 participants