RUBY-3456 Suppress no-op SDAM debug log lines#3030
Merged
comandeo-mongo merged 7 commits intomongodb:masterfrom Apr 28, 2026
Merged
RUBY-3456 Suppress no-op SDAM debug log lines#3030comandeo-mongo merged 7 commits intomongodb:masterfrom
comandeo-mongo merged 7 commits intomongodb:masterfrom
Conversation
The driver does a one-time legacy-isMaster to modern-hello protocol switch on the initial handshake, per the SDAM Server Monitoring spec. The two responses populate different config keys (ismaster + helloOk vs isWritablePrimary), so descriptions for the same logical role were not considered equal. Add the three protocol-flip keys to EXCLUDE_FOR_COMPARISON so descriptions that differ only in protocol shape compare as equal. The role itself remains differentiated by the SECONDARY flag and the rest of the replica-set metadata.
Contributor
There was a problem hiding this comment.
Pull request overview
This PR reduces steady-state SDAM debug log noise by suppressing no-op output from the built-in SDAM log subscribers, while keeping SDAM monitoring events unchanged.
Changes:
- Add early-return guards in
ServerDescriptionChangedLogSubscriberandTopologyChangedLogSubscriberto avoid emitting debug lines when the logged information would be unchanged. - Extend
Mongo::Server::Descriptioncomparison exclusions to treat legacyisMastervs modernhelloreply shape differences as equivalent. - Add unit coverage for the new subscriber suppression behavior and the legacy-vs-modern equality case; remove an obsolete commented Evergreen buildvariant block.
Reviewed changes
Copilot reviewed 8 out of 8 changed files in this pull request and generated 4 comments.
Show a summary per file
| File | Description |
|---|---|
lib/mongo/monitoring/server_description_changed_log_subscriber.rb |
Suppresses debug output when descriptions compare equal. |
lib/mongo/monitoring/topology_changed_log_subscriber.rb |
Suppresses debug output when topology class and server descriptions are unchanged. |
lib/mongo/server/description.rb |
Expands Description#== exclusions to ignore ismaster/isWritablePrimary/helloOk differences. |
spec/mongo/monitoring/server_description_changed_log_subscriber_spec.rb |
New unit coverage for no-op suppression and awaited suffix behavior. |
spec/mongo/monitoring/topology_changed_log_subscriber_spec.rb |
New unit coverage for topology no-op suppression vs member/type change logging. |
spec/mongo/server/description_spec.rb |
Adds a focused equality test for legacy isMaster vs modern hello replies. |
.evergreen/config/standard.yml.erb |
Removes a commented-out JRuby buildvariant block. |
.evergreen/config.yml |
Removes the same commented-out JRuby buildvariant block. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| expect(legacy == modern).to be(true) | ||
| end | ||
| end | ||
|
|
Comment on lines
25
to
+29
| def log_event(event) | ||
| if event.previous_topology.class == event.new_topology.class | ||
| return if event.previous_topology.server_descriptions == | ||
| event.new_topology.server_descriptions | ||
|
|
Comment on lines
198
to
+216
| # Fields to exclude when comparing two descriptions. | ||
| # | ||
| # The PRIMARY (legacy `ismaster`), IS_WRITABLE_PRIMARY (modern `hello`), | ||
| # and HELLO_OK keys are excluded because the driver does a one-time | ||
| # legacy-`isMaster` to modern-`hello` protocol switch on the initial | ||
| # handshake (per the SDAM Server Monitoring spec). Two responses for the | ||
| # same logical role differ only in which of these keys is populated. | ||
| # The role itself is still differentiated by the SECONDARY flag and the | ||
| # remaining replica-set metadata. | ||
| # | ||
| # @since 2.0.6 | ||
| EXCLUDE_FOR_COMPARISON = [ LOCAL_TIME, | ||
| LAST_WRITE, | ||
| OPERATION_TIME, | ||
| Operation::CLUSTER_TIME, | ||
| CONNECTION_ID, ].freeze | ||
| CONNECTION_ID, | ||
| PRIMARY, | ||
| IS_WRITABLE_PRIMARY, | ||
| HELLO_OK, ].freeze |
| private | ||
|
|
||
| def log_event(event) | ||
| return if event.previous_description == event.new_description |
Adding ismaster/isWritablePrimary to EXCLUDE_FOR_COMPARISON made it possible for two descriptions with different server_type (e.g. RSOther vs Primary, where only isWritablePrimary flips) to compare equal, which would let the new SDAM log subscriber early-returns suppress real role transitions. Guard == with a server_type check and add a spec covering the RSOther -> Primary boundary.
jamis
approved these changes
Apr 28, 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.
ServerDescriptionChangedLogSubscriber#log_eventand
TopologyChangedLogSubscriber#log_eventso steady-state heartbeatsno longer produce
Server description for ... changed from 'primary' to 'primary'/ "There was a change in the members of the 'ReplicaSetWithPrimary' topology"
debug lines when nothing the message conveys has actually changed.
ismaster,isWritablePrimary,helloOktoServer::Description::EXCLUDE_FOR_COMPARISONso the one-time legacy-isMaster→ modern-
helloprotocol switch (mandated by the SDAM Server Monitoring spec)also stops producing transient
'X' → 'X'lines on connection startup. Therole itself is still differentiated by the
secondaryflag and the rest ofthe replica-set metadata.
Monitoring::Event::ServerDescriptionChanged/Monitoring::Event::TopologyChangedevents are unchanged and continue tofire — only the production log subscribers suppress no-op output. SDAM
unified test runners (which use a separate fixture in
spec/support/sdam_formatter_integration.rb) and any user-installedsubscribers are unaffected.
While investigating, I also noticed that in MongoDB 4.4+ streaming mode the
regular
Monitorcontinues to publishServerDescriptionChangedevents whilePushMonitoris also publishing them, contrary to the SDAM spec's "MUST NOTpublish any events when running an RTT command" rule. That's a separate issue,
filed as RUBY-3822.
Resolves https://jira.mongodb.org/browse/RUBY-3456.
Test Plan
bundle exec rspec spec/mongo/monitoring/server_description_changed_log_subscriber_spec.rb spec/mongo/monitoring/topology_changed_log_subscriber_spec.rb spec/mongo/server/description_spec.rb— 126 examples, 0 failures locally.bundle exec rubocopclean on all four changed files.mongodb://localhost:27017,27018,27019/at debug log level: 3 lines for initial discovery, then zero'X' → 'X'lines for the rest of the run.spec/runners/sdam.rb).