opentelemetry-js-contrib icon indicating copy to clipboard operation
opentelemetry-js-contrib copied to clipboard

feat(instrumentation-mongoose)!: add instrumentation of static methods

Open Vovcharaa opened this issue 9 months ago • 2 comments

Which problem is this PR solving?

Currently Mongoose instrumentation does not track static methods like insertMany and bulkWrite

Short description of the changes

Added patchModelStatic to allow instrumentation of static model methods.
Changed tested versions of mongoose because some older versions have weird timeouts with callbacks when suppressTracing is used in tests.

Related issues

Fixes #2488

Vovcharaa avatar Mar 09 '25 14:03 Vovcharaa

CLA Signed

The committers listed above are authorized under a signed CLA.

  • :white_check_mark: login: Vovcharaa / name: Nazar Vovk (eb21cd01514e0a63c42336d0b62eab76110d8170, 167682d42bab7dee9891b1b3ebf80b89c6c7c5e6, 7475099175c25d50cf92456c3511fdda6a6ae520, 7bd1296d45fe5bc92a4657f1a0e07f56537d6f17, e1f15c110478843a9a1ed1da41e165f25da82330)

Hi @blumamir, Is there any chance that you'll be able to review it soon?

Vovcharaa avatar Mar 17 '25 18:03 Vovcharaa

Hi. I'm also interested in this feature.

bimmerv avatar Mar 24 '25 13:03 bimmerv

Is there anyone who can review this? @pichlermarc

Vovcharaa avatar Mar 30 '25 12:03 Vovcharaa

Hi @Vovcharaa - @blumamir owns this component, they are the first contact point for reviews.

Regardless, a few things that stand out from a high-level perspective:

  • I don't think not testing certain versions is the way to go, as we'd not notice if we'd crash the end-user's app on certain versions of mongoose.
  • the PR is marked as breaking (! in the PR title), but the changes actually all seem non-breaking to me, what's the reason for that? 🤔

pichlermarc avatar Apr 29 '25 08:04 pichlermarc

Hi @pichlermarc I marked PR as breaking because I removed older versions from tests. I thought it is enough to mark them as not supported anymore.

Vovcharaa avatar Apr 29 '25 09:04 Vovcharaa

please also update the new version range:

blumamir avatar May 07 '25 13:05 blumamir

Codecov Report

Attention: Patch coverage is 86.48649% with 5 lines in your changes missing coverage. Please review.

Project coverage is 89.68%. Comparing base (11a2999) to head (e1f15c1). Report is 1 commits behind head on main.

Files with missing lines Patch % Lines
...gins/node/instrumentation-mongoose/src/mongoose.ts 85.71% 5 Missing :warning:
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #2748      +/-   ##
==========================================
- Coverage   89.69%   89.68%   -0.02%     
==========================================
  Files         184      184              
  Lines        8966     9003      +37     
  Branches     1835     1845      +10     
==========================================
+ Hits         8042     8074      +32     
- Misses        924      929       +5     
Files with missing lines Coverage Δ
plugins/node/instrumentation-mongoose/src/utils.ts 76.08% <100.00%> (+1.08%) :arrow_up:
...gins/node/instrumentation-mongoose/src/mongoose.ts 94.70% <85.71%> (-2.34%) :arrow_down:
:rocket: New features to boost your workflow:
  • :snowflake: Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • :package: JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

codecov[bot] avatar May 07 '25 13:05 codecov[bot]

@pichlermarc @blumamir Could you pls allow tests to run?

Vovcharaa avatar May 08 '25 13:05 Vovcharaa

@pichlermarc @blumamir, for some unknown reason, suppressTracing works weird with callback tests. It suppresses what it should not. I fixed it by enabling instrumentation after injecting test data into the database to avoid using suppressTracing in tests.

Vovcharaa avatar May 17 '25 14:05 Vovcharaa

@pichlermarc As I see @blumamir quite rarely reviews PRs in this repo, could you, please, approve tests and merge this PR in case everything is good? This PR already has component owner approval.

Vovcharaa avatar May 19 '25 14:05 Vovcharaa