Skip to content

Commit

Permalink
fix: use context API to bind connection checkOut callback (open-telem…
Browse files Browse the repository at this point in the history
…etry#1766)

* fix: use context API to bind connection checkOut callback

* chore: fix lint

---------

Co-authored-by: Amir Blum <[email protected]>
  • Loading branch information
2 people authored and jmcdo29 committed Nov 13, 2023
1 parent 6186b8b commit 02c7cae
Showing 1 changed file with 1 addition and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,6 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import { AsyncResource } from 'async_hooks';

import {
context,
diag,
Expand Down Expand Up @@ -332,7 +330,7 @@ export class MongoDBInstrumentation extends InstrumentationBase {
private _getV4ConnectionPoolCheckOut() {
return (original: V4ConnectionPool['checkOut']) => {
return function patchedCheckout(this: unknown, callback: any) {
const patchedCallback = AsyncResource.bind(callback);
const patchedCallback = context.bind(context.active(), callback);
return original.call(this, patchedCallback);
};
};
Expand Down

0 comments on commit 02c7cae

Please sign in to comment.