Skip to content

feat(instrumentation-mongoose): Support v9#3368

Open
Farhan-Abbas wants to merge 2 commits intoopen-telemetry:mainfrom
Farhan-Abbas:add_mongoose9_support
Open

feat(instrumentation-mongoose): Support v9#3368
Farhan-Abbas wants to merge 2 commits intoopen-telemetry:mainfrom
Farhan-Abbas:add_mongoose9_support

Conversation

@Farhan-Abbas
Copy link

@Farhan-Abbas Farhan-Abbas commented Feb 1, 2026

Which problem is this PR solving?

Fixes #3285. This PR adds support for mongoose@9 to the @opentelemetry/instrumentation-mongoose package.

Short description of the changes

Breaking Changes

None. The core instrumentation code itself required no changes - only version ranges were updated to <10.

However, Mongoose@9's internal changes required some changes to our tests and the TypeScript configuration.

Here's a quick summary of all the changes:

Version Range Updates

  • Updated supported version range from >=5.9.7 <9 to >=5.9.7 <10 in:
    • src/mongoose.ts (instrumentation module definition)
    • README.md (documentation)
    • package.json (devDependencies updated to mongoose@9.1.5)

Testing Configuration

  • Test All Versions (.tav.yml): Split mongoose v8 and v9 into separate test entries
    • mongoose@8: Node.js >= 16.20.1
    • mongoose@9: Node.js >= 18.0.0 (mongoose@9 requires Node.js 18+)
  • Test Files: Renamed mongoose-v7-v8.test.tsmongoose-v7-v9.test.ts
  • Test Scripts: Updated test-v7-v8test-v7-v9 in package.json

TypeScript Compatibility

  • tsconfig.json: Added skipLibCheck: true to handle mongoose@9's excessively deep type instantiation issues (TS2589)
  • test/user.ts: Updated User model export with type assertion to work around mongoose@9 type complexity

Test Adjustments

  • mongoose-common.test.ts:
    • Simplified assertion for Document.prototype.updateOne() test - mongoose@9 returns empty objects for condition/updates/options in the serialized statement for document-level operations
    • Added as any type assertion to updateOne test to avoid TypeScript errors
    • Added explanatory comments for mongoose@9 behavioral changes

@Farhan-Abbas Farhan-Abbas reopened this Feb 1, 2026
@Farhan-Abbas Farhan-Abbas marked this pull request as ready for review February 1, 2026 20:25
@Farhan-Abbas Farhan-Abbas requested a review from a team as a code owner February 1, 2026 20:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[instrumentation-mongoose] add support for mongoose@9

2 participants