Skip to content

Commit 9b675f6

Browse files
committed
Address review comments.
1 parent 117ba0b commit 9b675f6

File tree

1 file changed

+9
-7
lines changed

1 file changed

+9
-7
lines changed

plugins/node/instrumentation-dataloader/src/instrumentation.ts

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -139,7 +139,7 @@ export class DataloaderInstrumentation extends InstrumentationBase<DataloaderIns
139139
const instrumentation = this;
140140
const prototype = constructor.prototype;
141141

142-
if (!instrumentation.isEnabled() || !instrumentation.shouldCreateSpans()) {
142+
if (!instrumentation.isEnabled()) {
143143
return constructor;
144144
}
145145

@@ -149,13 +149,15 @@ export class DataloaderInstrumentation extends InstrumentationBase<DataloaderIns
149149
) {
150150
// BatchLoadFn is the first constructor argument
151151
// https://github.com/graphql/dataloader/blob/77c2cd7ca97e8795242018ebc212ce2487e729d2/src/index.js#L47
152-
if (isWrapped(args[0])) {
153-
instrumentation._unwrap(args, 0);
154-
}
152+
if (typeof args[0] === 'function') {
153+
if (isWrapped(args[0])) {
154+
instrumentation._unwrap(args, 0);
155+
}
155156

156-
args[0] = instrumentation._wrapBatchLoadFn(
157-
args[0]
158-
) as Dataloader.BatchLoadFn<unknown, unknown>;
157+
args[0] = instrumentation._wrapBatchLoadFn(
158+
args[0]
159+
) as Dataloader.BatchLoadFn<unknown, unknown>;
160+
}
159161

160162
return constructor.apply(this, args);
161163
}

0 commit comments

Comments
 (0)