Skip to content

Commit

Permalink
remove flag detection
Browse files Browse the repository at this point in the history
  • Loading branch information
bengl committed Oct 4, 2024
1 parent 3c7db0f commit 148f6e1
Showing 1 changed file with 8 additions and 10 deletions.
18 changes: 8 additions & 10 deletions packages/dd-trace/src/profiling/profilers/wall.js
Original file line number Diff line number Diff line change
Expand Up @@ -85,25 +85,23 @@ function ensureChannelsActivated () {

createHook({ before: () => beforeCh.publish() }).enable()

let inRun = false
shimmer.wrap(AsyncLocalStorage.prototype, 'enterWith', function (original) {
return function (...args) {
const retVal = original.apply(this, args)
enterCh.publish()
if (!inRun) enterCh.publish()
return retVal
}
})

// TODO this will change in the future. It won't be experimental forever.
const needsWrappedCb =
!process.execArgv.includes('--experimental-async-context-frame')
shimmer.wrap(AsyncLocalStorage.prototype, 'run', function (original) {
return function (store, callback, ...args) {
const wrappedCb = needsWrappedCb
? shimmer.wrapFunction(callback, cb => function (...args) {
enterCh.publish()
return cb.apply(this, args)
})
: callback
const wrappedCb = shimmer.wrapFunction(callback, cb => function (...args) {
inRun = false
enterCh.publish()
return cb.apply(this, args)
})
inRun = true
const retVal = original.call(this, store, wrappedCb, ...args)
enterCh.publish()
return retVal
Expand Down

0 comments on commit 148f6e1

Please sign in to comment.