Skip to content

Commit 1b37576

Browse files
authored
fix: check if addIntegration method exists (#160)
1 parent f7183db commit 1b37576

File tree

2 files changed

+19
-3
lines changed

2 files changed

+19
-3
lines changed

.changeset/neat-hounds-try.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
---
2+
'@hyperdx/instrumentation-sentry-node': patch
3+
'@hyperdx/node-opentelemetry': patch
4+
---
5+
6+
fix: check if addIntegration method exists

packages/instrumentation-sentry-node/src/instrumentation.ts

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -35,9 +35,19 @@ export class SentryNodeInstrumentation extends InstrumentationBase {
3535
this._wrap(moduleExports, 'init', (original: any) => {
3636
return (...args: any[]) => {
3737
const result = original.apply(this, args);
38-
// WARNING: we need to add the integration once the SDK is initialized
39-
moduleExports.addIntegration(hyperdxIntegration());
40-
diag.debug('Added HyperDX Sentry integration.');
38+
try {
39+
if (moduleExports.addIntegration instanceof Function) {
40+
// WARNING: we need to add the integration once the SDK is initialized
41+
moduleExports.addIntegration(hyperdxIntegration());
42+
diag.debug('Added HyperDX Sentry integration');
43+
} else {
44+
diag.error(
45+
'Sentry SDK does not support addIntegration method',
46+
);
47+
}
48+
} catch (e) {
49+
diag.error('Error adding HyperDX Sentry integration', e);
50+
}
4151
return result;
4252
};
4353
});

0 commit comments

Comments
 (0)