Fix SSE gauge leak, config bool handling, and metric error logging#3756
Merged
ChrisJBurns merged 1 commit intomainfrom Feb 10, 2026
Merged
Fix SSE gauge leak, config bool handling, and metric error logging#3756ChrisJBurns merged 1 commit intomainfrom
ChrisJBurns merged 1 commit intomainfrom
Conversation
- Fix SSE active connections gauge that was incremented but never decremented. Move increment into Handler with a defer decrement so the gauge correctly tracks SSE connection lifecycle. - Fix config file `use-legacy-attributes: false` being silently ignored. Change UseLegacyAttributes from bool to *bool in app config so nil (not set) is distinguishable from explicit false. Add two test cases covering both scenarios. - Log metric creation errors at debug level instead of silently discarding them. The OTEL SDK returns no-op instruments on error so there is no runtime risk, but logging aids troubleshooting. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
rdimitrov
approved these changes
Feb 10, 2026
Merged
4 tasks
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #3756 +/- ##
==========================================
- Coverage 66.38% 66.37% -0.01%
==========================================
Files 427 427
Lines 41926 41935 +9
==========================================
+ Hits 27831 27836 +5
- Misses 11980 11982 +2
- Partials 2115 2117 +2 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
This was referenced Feb 10, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Three small telemetry bug fixes identified during OTEL MCP semantic conventions review (#3399):
SSE active connections gauge leak: The
toolhive_mcp_active_connectionsgauge withconnection_type=ssewas incremented inrecordSSEConnectionbut never decremented, growing monotonically. Moved the increment intoHandlerwith adeferdecrement so the gauge correctly tracks SSE connection lifecycle.Config file
use-legacy-attributes: falsesilently ignored: Go's zero-valuefalsewas indistinguishable from "not set", so settinguse-legacy-attributes: falsein YAML had no effect — the CLI defaulttruealways won. ChangedUseLegacyAttributesfromboolto*boolin the app config struct sonil(not set) is distinguishable from explicitfalse.Metric creation errors silently discarded: All four metric instruments in
NewHTTPMiddlewareused_ :=for errors. Now logged at debug level. The OTEL SDK returns no-op instruments on error so there is no runtime risk, but logging aids troubleshooting.Test plan
UseLegacyAttributesconfig handling:false→ correctly appliednil) → CLI defaulttrueused🤖 Generated with Claude Code