Skip to content

Commit

Permalink
feat: add try-catch
Browse files Browse the repository at this point in the history
  • Loading branch information
wrn14897 committed Jun 25, 2024
1 parent 6ea894f commit ec00037
Showing 1 changed file with 12 additions and 6 deletions.
18 changes: 12 additions & 6 deletions packages/instrumentation-sentry-node/src/instrumentation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,12 +35,18 @@ export class SentryNodeInstrumentation extends InstrumentationBase {
this._wrap(moduleExports, 'init', (original: any) => {
return (...args: any[]) => {
const result = original.apply(this, args);
if (moduleExports.addIntegration instanceof Function) {
// WARNING: we need to add the integration once the SDK is initialized
moduleExports.addIntegration(hyperdxIntegration());
diag.debug('Added HyperDX Sentry integration.');
} else {
diag.error('Could not add HyperDX Sentry integration');
try {
if (moduleExports.addIntegration instanceof Function) {
// WARNING: we need to add the integration once the SDK is initialized
moduleExports.addIntegration(hyperdxIntegration());
diag.debug('Added HyperDX Sentry integration');
} else {
diag.error(
'Sentry SDK does not support addIntegration method',
);
}
} catch (e) {
diag.error('Error adding HyperDX Sentry integration', e);
}
return result;
};
Expand Down

0 comments on commit ec00037

Please sign in to comment.