Some checks failed
Build & Deploy / 🔍 Prepare (push) Successful in 20s
Build & Deploy / 🧪 QA (push) Failing after 34s
Build & Deploy / 🏗️ Build (push) Has started running
Build & Deploy / 🚀 Deploy (push) Has been cancelled
Build & Deploy / 🧪 Smoke Test (push) Has been cancelled
Build & Deploy / ⚡ Lighthouse (push) Has been cancelled
Build & Deploy / 🔔 Notify (push) Has been cancelled
40 lines
1.4 KiB
Plaintext
40 lines
1.4 KiB
Plaintext
import { isWrapped } from '@opentelemetry/instrumentation';
|
|
import { getClient, isEnabled, hasSpansEnabled, consoleSandbox, getGlobalScope } from '@sentry/core';
|
|
import { createMissingInstrumentationContext } from './createMissingInstrumentationContext.js';
|
|
import { isCjs } from './detection.js';
|
|
|
|
/**
|
|
* Checks and warns if a framework isn't wrapped by opentelemetry.
|
|
*/
|
|
function ensureIsWrapped(
|
|
maybeWrappedFunction,
|
|
name,
|
|
) {
|
|
const clientOptions = getClient()?.getOptions();
|
|
if (
|
|
!clientOptions?.disableInstrumentationWarnings &&
|
|
!isWrapped(maybeWrappedFunction) &&
|
|
isEnabled() &&
|
|
hasSpansEnabled(clientOptions)
|
|
) {
|
|
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
|