Skip to content

Commit f25d2c8

Browse files
committed
fixes
1 parent 65893ba commit f25d2c8

4 files changed

Lines changed: 12 additions & 50 deletions

File tree

packages/opentelemetry/src/asyncLocalStorageContextManager.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -230,7 +230,7 @@ export class SentryAsyncLocalStorageContextManager implements ContextManager {
230230
* would classify plain objects like `{ on: true }` as emitters and later try to call a non-function.
231231
*/
232232
function isEventEmitter(target: unknown): target is EventEmitter {
233-
if (typeof target !== 'object' || target === null) {
233+
if (typeof target !== 'object' || !target) {
234234
return false;
235235
}
236236
const candidate = target as Partial<Record<'on' | 'emit', unknown>>;

packages/opentelemetry/src/nodeAsyncContextStrategy.ts

Lines changed: 9 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -4,37 +4,19 @@ import { AsyncLocalStorage } from 'node:async_hooks';
44
import { getRootSpan, spanIsIgnored, type TracingChannelBinding } from '@sentry/core';
55
import { SENTRY_TRACE_STATE_CHILD_IGNORED } from './constants';
66

7-
export function setNodeOpenTelemetryContextAsyncContextStrategy(options?: {
8-
asyncLocalStorage?: AsyncLocalStorage<api.Context>;
9-
}): void {
7+
export function setNodeOpenTelemetryContextAsyncContextStrategy(): void {
8+
const asyncLocalStorage = new AsyncLocalStorage<api.Context>();
9+
1010
setOpenTelemetryContextAsyncContextStrategy({
11-
getTracingChannelBinding: options?.asyncLocalStorage
12-
? getAsyncLocalStorageFactory(options.asyncLocalStorage)
13-
: getDefaultAsyncLocalStorageFactory(),
11+
getTracingChannelBinding: () => {
12+
return {
13+
asyncLocalStorage,
14+
getStoreWithActiveSpan,
15+
} satisfies TracingChannelBinding;
16+
},
1417
});
1518
}
1619

17-
/**
18-
* In the default case, we build the local storage instance ourselves here.
19-
* The default asyncLocalStorageContextManager will then use this internally.
20-
*/
21-
function getDefaultAsyncLocalStorageFactory(): () => TracingChannelBinding {
22-
const defaultAsyncLocalStorage = new AsyncLocalStorage<api.Context>();
23-
return getAsyncLocalStorageFactory(defaultAsyncLocalStorage);
24-
}
25-
26-
/**
27-
* Build the tracing channel binding factory for the given async local storage instance.
28-
*/
29-
function getAsyncLocalStorageFactory(asyncLocalStorage: AsyncLocalStorage<api.Context>): () => TracingChannelBinding {
30-
return () => {
31-
return {
32-
asyncLocalStorage,
33-
getStoreWithActiveSpan,
34-
} satisfies TracingChannelBinding;
35-
};
36-
}
37-
3820
function getStoreWithActiveSpan(span: Parameters<TracingChannelBinding['getStoreWithActiveSpan']>[0]): api.Context {
3921
const activeContext = api.context.active();
4022

packages/vercel-edge/src/async-local-storage.ts

Lines changed: 0 additions & 20 deletions
This file was deleted.

packages/vercel-edge/src/sdk.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,14 +22,14 @@ import {
2222
SentryAsyncLocalStorageContextManager,
2323
SentryPropagator,
2424
SentryTracerProvider,
25+
setOpenTelemetryContextAsyncContextStrategy,
2526
setupEventContextTrace,
2627
} from '@sentry/opentelemetry';
2728
import { VercelEdgeClient } from './client';
2829
import { winterCGFetchIntegration } from './integrations/wintercg-fetch';
2930
import { makeEdgeTransport } from './transports';
3031
import type { VercelEdgeOptions } from './types';
3132
import { getVercelEnv } from './utils/vercel';
32-
import { setVercelEdgeAsyncLocalStorageStrategy } from './async-local-storage';
3333

3434
declare const process: {
3535
env: Record<string, string>;
@@ -56,7 +56,7 @@ export function getDefaultIntegrations(_options: Options): Integration[] {
5656

5757
/** Inits the Sentry NextJS SDK on the Edge Runtime. */
5858
export function init(options: VercelEdgeOptions = {}): Client {
59-
setVercelEdgeAsyncLocalStorageStrategy();
59+
setOpenTelemetryContextAsyncContextStrategy();
6060

6161
const scope = getCurrentScope();
6262
scope.update(options.initialScope);

0 commit comments

Comments
 (0)