@sentry/node
Version:
Sentry Node SDK using OpenTelemetry for performance instrumentation
35 lines (31 loc) • 1.31 kB
JavaScript
import { isWrapped } from '@opentelemetry/core';
import { isEnabled, hasTracingEnabled, getGlobalScope } from '@sentry/core';
import { consoleSandbox } from '@sentry/utils';
import { isCjs } from './commonjs.js';
import { createMissingInstrumentationContext } from './createMissingInstrumentationContext.js';
/**
* Checks and warns if a framework isn't wrapped by opentelemetry.
*/
function ensureIsWrapped(
maybeWrappedModule,
name,
) {
if (!isWrapped(maybeWrappedModule) && isEnabled() && hasTracingEnabled()) {
consoleSandbox(() => {
if (isCjs()) {
// eslint-disable-next-line no-console
console.warn(
`[Sentry] ${name} is not instrumented. This is likely because you required/imported ${name} before calling \`Sentry.init()\`.`,
);
} else {
// eslint-disable-next-line no-console
console.warn(
`[Sentry] ${name} is not instrumented. Please make sure to initialize Sentry in a separate file that you \`--import\` when running node, see: https://docs.sentry.io/platforms/javascript/guides/${name}/install/esm/.`,
);
}
});
getGlobalScope().setContext('missing_instrumentation', createMissingInstrumentationContext(name));
}
}
export { ensureIsWrapped };
//# sourceMappingURL=ensureIsWrapped.js.map