Skip to content

Commit e77d345

Browse files
committed
review suggestions
1 parent 83419f4 commit e77d345

File tree

1 file changed

+9
-11
lines changed

1 file changed

+9
-11
lines changed

packages/nuxt/src/runtime/plugins/sentry.server.ts

+9-11
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
import {
22
GLOBAL_OBJ,
3-
consoleSandbox,
43
flush,
54
getClient,
65
getDefaultIsolationScope,
@@ -18,19 +17,18 @@ import { addSentryTracingMetaTags, extractErrorContext } from '../utils';
1817
export default defineNitroPlugin(nitroApp => {
1918
nitroApp.h3App.handler = new Proxy(nitroApp.h3App.handler, {
2019
async apply(handlerTarget, handlerThisArg, handlerArgs: Parameters<typeof nitroApp.h3App.handler>) {
21-
// In environments where we cannot make use of OTel httpInstrumentation, e.g. when just importing the Sentry server config at
22-
// the top level instead of `--import` or dynamic import like on Vercel, we still need to ensure requests are properly isolated
20+
// In environments where we cannot make use of OTel httpInstrumentation, we still need to ensure requests are properly isolated (e.g. when just importing the Sentry server config at the top level instead of `--import`).
21+
// If OTel httpInstrumentation works, requests will be already isolated by the SentryHttpInstrumentation.
22+
// We can identify this by comparing the current isolation scope to the default one. The requests are properly isolated if
23+
// the current isolation scope is different from the default one. If that is not the case, we fork the isolation scope here.
2324
const isolationScope = getIsolationScope();
2425
const newIsolationScope = isolationScope === getDefaultIsolationScope() ? isolationScope.clone() : isolationScope;
2526

26-
consoleSandbox(() => {
27-
// eslint-disable-next-line no-console
28-
console.log(
29-
`[Sentry] Patched h3 event handler. ${
30-
isolationScope === newIsolationScope ? 'Using existing' : 'Created new'
31-
} isolation scope.`,
32-
);
33-
});
27+
logger.log(
28+
`[Sentry] Patched h3 event handler. ${
29+
isolationScope === newIsolationScope ? 'Using existing' : 'Created new'
30+
} isolation scope.`,
31+
);
3432

3533
return withIsolationScope(newIsolationScope, async () => {
3634
try {

0 commit comments

Comments
 (0)