Skip to content

Test the Mongo integration with the real driver#1531

Merged
unflxw merged 1 commit into
mainfrom
mongo-real-driver-tests
Jun 26, 2026
Merged

Test the Mongo integration with the real driver#1531
unflxw merged 1 commit into
mainfrom
mongo-real-driver-tests

Conversation

@unflxw

@unflxw unflxw commented Jun 26, 2026

Copy link
Copy Markdown
Contributor

Part of #1515, spun as a separate PR to make reviewing easier. This extracts a test-quality improvement the OpenTelemetry work drags in, so it can be reviewed and validated independently of collector mode.

Test the Mongo integration with the real driver

The subscriber specs fed the monitoring callbacks hand-built doubles, so the integration was never exercised against the driver's real event API. Build real Mongo::Monitoring::Event objects instead and drive the started/succeeded/failed callbacks; their constructors don't open a connection, so no MongoDB server is needed. Assert on the recorded event rather than on internal extension calls.

This needs the gem, so add a mongo gemfile and build matrix entry and gate the specs on it.

@backlog-helper

backlog-helper Bot commented Jun 26, 2026

Copy link
Copy Markdown

Hi @unflxw,

We've found some issues with your Pull Request.

  • This Pull Request does not include a changeset. Add a changeset if the change impacts users and should be included in the changelog upon release. Read more about changesets.
    Ignore this rule by adding [skip changeset] to your Pull Request body. - (More info)

New issue guide | Backlog management | Rules | Feedback

@unflxw
unflxw requested a review from Copilot June 26, 2026 10:15
@unflxw unflxw added the chore A small task that takes a day or two at the most. label Jun 26, 2026

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR improves coverage of the Mongo Ruby driver integration by exercising Appsignal::Hooks::MongoMonitorSubscriber against real Mongo::Monitoring::Event objects (without needing a MongoDB server), and wires CI to run those specs under a dedicated mongo.gemfile.

Changes:

  • Add DependencyHelper.mongo_present? and gate Mongo-related specs based on the mongo gem being present.
  • Rewrite Mongo subscriber specs to use real Mongo::Monitoring::Event::{CommandStarted,CommandSucceeded,CommandFailed} objects and assert on recorded transaction events/metrics.
  • Add gemfiles/mongo.gemfile and extend the build matrix + generated GitHub Actions workflow to run the mongo job.

Reviewed changes

Copilot reviewed 6 out of 6 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
spec/support/helpers/dependency_helper.rb Adds mongo_present? helper for conditional specs.
spec/lib/appsignal/integrations/mongo_ruby_driver_spec.rb Switches to real Mongo monitoring events and new assertions for recorded events/metrics.
spec/lib/appsignal/hooks/mongo_ruby_driver_spec.rb Adjusts dependency expectations when the real driver is loaded via mongo.gemfile.
gemfiles/mongo.gemfile Introduces a gemfile that includes the mongo gem for CI/spec gating.
build_matrix.yml Adds mongo to the build matrix gem variants.
.github/workflows/ci.yml Regenerates CI workflow to include mongo gemfile jobs.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread spec/lib/appsignal/integrations/mongo_ruby_driver_spec.rb
Comment thread spec/lib/appsignal/integrations/mongo_ruby_driver_spec.rb
Comment thread spec/lib/appsignal/integrations/mongo_ruby_driver_spec.rb
@unflxw

unflxw commented Jun 26, 2026

Copy link
Copy Markdown
Contributor Author

@copilot resolve the merge conflicts in this pull request

Copilot AI commented Jun 26, 2026

Copy link
Copy Markdown

@copilot resolve the merge conflicts in this pull request

Resolved the merge conflict by merging origin/main into this branch and fixing the conflict in spec/lib/appsignal/integrations/mongo_ruby_driver_spec.rb in commit 39743acb.

The subscriber specs fed the monitoring callbacks hand-built doubles,
so the integration was never exercised against the driver's real event
API. Build real `Mongo::Monitoring::Event` objects instead and drive
the started/succeeded/failed callbacks; their constructors don't open a
connection, so no MongoDB server is needed. Assert on the recorded
event rather than on internal extension calls.

This needs the gem, so add a mongo gemfile and build matrix entry and
gate the specs on it.

[skip changeset]
@unflxw
unflxw force-pushed the mongo-real-driver-tests branch from 39743ac to 885b0fc Compare June 26, 2026 13:51
@unflxw
unflxw merged commit 41ac2c1 into main Jun 26, 2026
214 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

chore A small task that takes a day or two at the most.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants