Skip to content

Commit ad488ba

Browse files
rochdevtlhunter
authored andcommitted
fix error when using pubsub while plugin is disabled (#2966)
1 parent 861f3cd commit ad488ba

File tree

2 files changed

+15
-1
lines changed

2 files changed

+15
-1
lines changed

packages/datadog-instrumentations/src/google-cloud-pubsub.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ function wrapMethod (method) {
6363
const api = method.name
6464

6565
return function (request) {
66-
if (!requestStartCh.hasSubscribers) return request.apply(this, arguments)
66+
if (!requestStartCh.hasSubscribers) return method.apply(this, arguments)
6767

6868
const innerAsyncResource = new AsyncResource('bound-anonymous-fn')
6969

packages/datadog-plugin-google-cloud-pubsub/test/index.spec.js

+14
Original file line numberDiff line numberDiff line change
@@ -219,6 +219,20 @@ describe('Plugin', () => {
219219
return expectedSpanPromise
220220
})
221221
})
222+
223+
describe('when disabled', () => {
224+
beforeEach(() => {
225+
tracer.use('google-cloud-pubsub', false)
226+
})
227+
228+
afterEach(() => {
229+
tracer.use('google-cloud-pubsub', true)
230+
})
231+
232+
it('should work normally', async () => {
233+
await pubsub.createTopic(topicName)
234+
})
235+
})
222236
})
223237

224238
describe('with configuration', () => {

0 commit comments

Comments
 (0)