File tree Expand file tree Collapse file tree 3 files changed +23
-5
lines changed
packages/plugins/opentelemetry Expand file tree Collapse file tree 3 files changed +23
-5
lines changed Original file line number Diff line number Diff line change @@ -218,6 +218,11 @@ export type OpenTelemetryContextExtension = {
218
218
openTelemetry : {
219
219
tracer : Tracer ;
220
220
activeContext : ( ) => Context ;
221
+ httpContext : ( request ?: Request ) => Context | undefined ;
222
+ operationContext : ( context ?: unknown ) => Context | undefined ;
223
+ executionRequestContext : (
224
+ ExecutionRequest : ExecutionRequest ,
225
+ ) => Context | undefined ;
221
226
} ;
222
227
} ;
223
228
@@ -706,7 +711,20 @@ export function useOpenTelemetry(
706
711
extendContext ( {
707
712
openTelemetry : {
708
713
tracer,
709
- activeContext : ( ) => getContext ( state ) ,
714
+ httpContext : ( request ) => {
715
+ const { forRequest } = request ? getState ( { request } ) : state ;
716
+ return forRequest . otel ?. root ;
717
+ } ,
718
+ operationContext : ( context ) => {
719
+ const { forOperation } = context ? getState ( { context } ) : state ;
720
+ return forOperation . otel ?. root ;
721
+ } ,
722
+ executionRequestContext : ( executionRequest ) => {
723
+ return getState ( { executionRequest } ) . forSubgraphExecution . otel
724
+ ?. root ;
725
+ } ,
726
+ activeContext : ( contextMatcher ?: Parameters < typeof getState > [ 0 ] ) =>
727
+ getContext ( contextMatcher ? getState ( contextMatcher ) : state ) ,
710
728
} ,
711
729
} ) ;
712
730
} ,
Original file line number Diff line number Diff line change @@ -481,11 +481,11 @@ describe('useOpenTelemetry', () => {
481
481
const createSpan =
482
482
( name : string ) =>
483
483
(
484
- matcher : Parameters < ( typeof otelPlugin ) [ 'getOtelContext ' ] > [ 0 ] ,
484
+ matcher : Parameters < ( typeof otelPlugin ) [ 'getActiveContext ' ] > [ 0 ] ,
485
485
) =>
486
486
otelPlugin
487
487
. getTracer ( )
488
- . startSpan ( name , { } , otelPlugin . getOtelContext ( matcher ) )
488
+ . startSpan ( name , { } , otelPlugin . getActiveContext ( matcher ) )
489
489
. end ( ) ;
490
490
491
491
return [
Original file line number Diff line number Diff line change @@ -114,11 +114,11 @@ describe('useOpenTelemetry', () => {
114
114
const createSpan =
115
115
( name : string ) =>
116
116
(
117
- matcher : Parameters < ( typeof otelPlugin ) [ 'getOtelContext ' ] > [ 0 ] ,
117
+ matcher : Parameters < ( typeof otelPlugin ) [ 'getActiveContext ' ] > [ 0 ] ,
118
118
) =>
119
119
otelPlugin
120
120
. getTracer ( )
121
- . startSpan ( name , { } , otelPlugin . getOtelContext ( matcher ) )
121
+ . startSpan ( name , { } , otelPlugin . getActiveContext ( matcher ) )
122
122
. end ( ) ;
123
123
124
124
return [
You can’t perform that action at this time.
0 commit comments