Skip to content

Commit

Permalink
create isNoop method on scope
Browse files Browse the repository at this point in the history
  • Loading branch information
bengl committed Oct 28, 2024
1 parent 83468b8 commit dfb235e
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 4 deletions.
4 changes: 4 additions & 0 deletions packages/dd-trace/src/scope.js
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,10 @@ class Scope {
_isPromise (promise) {
return promise && typeof promise.then === 'function'
}

isNoop () {
return storage.getStore()?.noop
}
}

module.exports = Scope
5 changes: 1 addition & 4 deletions packages/dd-trace/src/tracer.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
const Tracer = require('./opentracing/tracer')
const tags = require('../../../ext/tags')
const Scope = require('./scope')
const { storage } = require('../../datadog-core')
const { isError } = require('./util')
const { setStartupLogConfig } = require('./startup-log')
const { ERROR_MESSAGE, ERROR_TYPE, ERROR_STACK } = require('../../dd-trace/src/constants')
Expand Down Expand Up @@ -106,9 +105,7 @@ class DatadogTracer extends Tracer {
const tracer = this

return function () {
const store = storage.getStore()

if (store && store.noop) return fn.apply(this, arguments)
if (tracer.scope().isNoop()) return fn.apply(this, arguments)

let optionsObj = options
if (typeof optionsObj === 'function' && typeof fn === 'function') {
Expand Down

0 comments on commit dfb235e

Please sign in to comment.