Skip to content

Commit 689be49

Browse files
committed
rename context stack file
1 parent 4b74e37 commit 689be49

File tree

2 files changed

+8
-5
lines changed

2 files changed

+8
-5
lines changed
File renamed without changes.

packages/plugins/opentelemetry/src/plugin.ts

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ import { DisposableSymbols } from '@whatwg-node/disposablestack';
3333
import { type OnRequestEventPayload } from '@whatwg-node/server';
3434
import type { OnParamsEventPayload, YogaInitialContext } from 'graphql-yoga';
3535
import { ATTR_SERVICE_VERSION, SEMRESATTRS_SERVICE_NAME } from './attributes';
36-
import { OtelContextStack } from './contextManager';
36+
import { OtelContextStack } from './context-stack';
3737
import {
3838
getMostSpecificState,
3939
withState,
@@ -471,7 +471,7 @@ export function useOpenTelemetry(
471471
return;
472472
}
473473

474-
// Here it is possible that otelCtx is not present, because this hook can be triggered by
474+
// Here it is possible that context is not present, because this hook can be triggered by
475475
// internal introspection queries, which are not linked to any client request, but should
476476
// still be traced and monitored.
477477

@@ -502,15 +502,18 @@ export function useOpenTelemetry(
502502
return;
503503
}
504504

505-
// Here it is possible that otelCtx is not present, because this hook can be triggered by
506-
// internal introspection queries, which are not linked to any client request, but should
507-
// still be traced and monitored.
505+
// Here it is possible that request, context and executionRequest are not present, because
506+
// this hook can be triggered by any fetch call, which are not linked to any client request,
507+
// but should still be traced and monitored.
508508

509509
let { fetchFn } = onFetchPayload;
510510
const originalFetch = fetchFn;
511511
let onDone: OnFetchHookDone | undefined = void 0;
512512

513513
if (propagateContext) {
514+
// We need to set the fetcher function instead of using `setOptions` because `getContext`
515+
// because we want to use the otel context at fetch time, in case a custom span has been
516+
// started by user.
514517
fetchFn = (url, options, ...args) => {
515518
const reqHeaders = getHeadersObj(options?.headers || {});
516519
propagation.inject(getContext(state), reqHeaders);

0 commit comments

Comments
 (0)