Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 14 additions & 12 deletions packages/vercel-edge/src/sdk.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import type { Client, Integration, Options } from '@sentry/core';
import {
consoleIntegration,
createStackParser,
debug,
dedupeIntegration,
functionToStringIntegration,
getCurrentScope,
Expand All @@ -18,7 +19,6 @@ import {
hasSpansEnabled,
inboundFiltersIntegration,
linkedErrorsIntegration,
logger,
nodeStackLineParser,
requestDataIntegration,
SDK_VERSION,
Expand Down Expand Up @@ -135,14 +135,14 @@ function validateOpenTelemetrySetup(): void {

for (const k of required) {
if (!setup.includes(k)) {
logger.error(
debug.error(
`You have to set up the ${k}. Without this, the OpenTelemetry & Sentry integration will not work properly.`,
);
}
}

if (!setup.includes('SentrySampler')) {
logger.warn(
debug.warn(
'You have to set up the SentrySampler. Without this, the OpenTelemetry & Sentry integration may still work, but sample rates set for the Sentry SDK will not be respected. If you use a custom sampler, make sure to use `wrapSamplingDecision`.',
);
}
Expand Down Expand Up @@ -182,19 +182,21 @@ export function setupOtel(client: VercelEdgeClient): void {
}

/**
* Setup the OTEL logger to use our own logger.
* Setup the OTEL logger to use our own debug logger.
*/
function setupOpenTelemetryLogger(): void {
const otelLogger = new Proxy(logger as typeof logger & { verbose: (typeof logger)['debug'] }, {
get(target, prop, receiver) {
const actualProp = prop === 'verbose' ? 'debug' : prop;
return Reflect.get(target, actualProp, receiver);
},
});

// Disable diag, to ensure this works even if called multiple times
diag.disable();
diag.setLogger(otelLogger, DiagLogLevel.DEBUG);
diag.setLogger(
{
error: debug.error,
warn: debug.warn,
info: debug.log,
debug: debug.log,
verbose: debug.log,
},
DiagLogLevel.DEBUG,
);
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@

import type { Context } from '@opentelemetry/api';
import { ROOT_CONTEXT } from '@opentelemetry/api';
import { GLOBAL_OBJ, logger } from '@sentry/core';
import { debug, GLOBAL_OBJ } from '@sentry/core';
import type { AsyncLocalStorage } from 'async_hooks';
import { DEBUG_BUILD } from '../debug-build';
import { AbstractAsyncHooksContextManager } from './abstract-async-hooks-context-manager';
Expand All @@ -42,7 +42,7 @@ export class AsyncLocalStorageContextManager extends AbstractAsyncHooksContextMa

if (!MaybeGlobalAsyncLocalStorageConstructor) {
DEBUG_BUILD &&
logger.warn(
debug.warn(
"Tried to register AsyncLocalStorage async context strategy in a runtime that doesn't support AsyncLocalStorage.",
);

Expand Down
Loading