Skip to content

Commit 985f4ba

Browse files
committed
Add rationale comment for globalThis double-cast
1 parent 57ef2f2 commit 985f4ba

1 file changed

Lines changed: 2 additions & 0 deletions

File tree

packages/node/src/sdk/initOtel.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,8 @@ function registerGlobalTracerProvider(provider: TracerProvider): boolean {
4848
return true;
4949
}
5050

51+
// @opentelemetry/api stores the registry under a `Symbol.for` key that no public type
52+
// describes, so `typeof globalThis` can only be narrowed to it by casting through `unknown`.
5153
const otelGlobal = globalThis as unknown as Record<symbol, { trace?: unknown } | undefined>;
5254
const registry = otelGlobal[OTEL_API_GLOBAL_KEY];
5355
if (registry && !registry.trace) {

0 commit comments

Comments
 (0)