whatap 0.5.13 → 0.5.14

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -475,10 +475,12 @@ OracleObserver.prototype.inject = function (mod, moduleName) {
475
475
  args[callbackIndex] = function wrappedCallback(err, pool) {
476
476
  if (pool) {
477
477
  poolAttributes.set(pool, poolAttrs);
478
- // Wrap Pool's getConnection method after pool is created
479
- shimmer.wrap(pool, 'getConnection', function(originalGetConn) {
480
- return self._wrapPoolGetConnection(originalGetConn, poolAttrs);
481
- });
478
+ if (!pool.__whatap_getconn_wrapped) {
479
+ pool.__whatap_getconn_wrapped = true;
480
+ shimmer.wrap(pool, 'getConnection', function(originalGetConn) {
481
+ return self._wrapPoolGetConnection(originalGetConn, poolAttrs);
482
+ });
483
+ }
482
484
  }
483
485
 
484
486
  return originalCallback.apply(this, arguments);
@@ -490,9 +492,12 @@ OracleObserver.prototype.inject = function (mod, moduleName) {
490
492
  .then(function(pool) {
491
493
  if (pool) {
492
494
  poolAttributes.set(pool, poolAttrs);
493
- shimmer.wrap(pool, 'getConnection', function(originalGetConn) {
494
- return self._wrapPoolGetConnection(originalGetConn, poolAttrs);
495
- });
495
+ if (!pool.__whatap_getconn_wrapped) {
496
+ pool.__whatap_getconn_wrapped = true;
497
+ shimmer.wrap(pool, 'getConnection', function(originalGetConn) {
498
+ return self._wrapPoolGetConnection(originalGetConn, poolAttrs);
499
+ });
500
+ }
496
501
  }
497
502
  return pool;
498
503
  });
@@ -500,17 +505,23 @@ OracleObserver.prototype.inject = function (mod, moduleName) {
500
505
  };
501
506
  });
502
507
 
503
- if (mod.Pool && mod.Pool.prototype) {
508
+ if (mod.Pool && mod.Pool.prototype && !mod.Pool.prototype.__whatap_getconn_wrapped) {
509
+ mod.Pool.prototype.__whatap_getconn_wrapped = true;
504
510
  shimmer.wrap(mod.Pool.prototype, 'getConnection', function(original) {
505
511
  return self._wrapPoolGetConnection(original);
506
512
  });
507
513
  }
508
514
  };
509
515
 
516
+ // Helper function to wrap a pool's getConnection method
510
517
  OracleObserver.prototype._wrapPoolGetConnection = function(originalGetConn, poolAttrs) {
511
518
  var self = this;
512
519
 
513
- return function wrappedGetConnection() {
520
+ if (originalGetConn.__whatap_wrapped) {
521
+ return originalGetConn;
522
+ }
523
+
524
+ function wrappedGetConnection() {
514
525
  var args = Array.from(arguments);
515
526
  var ctx = TraceContextManager.getCurrentContext();
516
527
 
@@ -607,6 +618,9 @@ OracleObserver.prototype._wrapPoolGetConnection = function(originalGetConn, pool
607
618
  });
608
619
  }
609
620
  };
621
+
622
+ wrappedGetConnection.__whatap_wrapped = true;
623
+ return wrappedGetConnection;
610
624
  };
611
625
 
612
626
  var checkedSql = new IntKeyMap(2000).setMax(2000);
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "whatap",
3
3
  "homepage": "http://www.whatap.io",
4
- "version": "0.5.13",
4
+ "version": "0.5.14",
5
5
  "releaseDate": "20250404",
6
6
  "description": "Monitoring and Profiling Service",
7
7
  "main": "index.js",