@@ -66,11 +66,12 @@ export class OpenTelemetryInboundInterceptor implements WorkflowInboundCallsInte
6666 const { getActivator, SdkFlags } = getSdkFlagsChecking ( ) ;
6767 const shouldInjectYield = getActivator ( ) . hasFlag ( SdkFlags . OpenTelemetryInterceptorInsertYield ) ;
6868 const context = extractContextFromHeaders ( input . headers ) ;
69+ if ( shouldInjectYield ) await Promise . resolve ( ) ;
6970 return await instrument ( {
7071 tracer : this . tracer ,
7172 spanName : `${ SpanName . WORKFLOW_EXECUTE } ${ SPAN_DELIMITER } ${ workflowInfo ( ) . workflowType } ` ,
7273 fn : ( ) => next ( input ) ,
73- context : shouldInjectYield ? await Promise . resolve ( context ) : context ,
74+ context,
7475 acceptableErrors : ( err ) => err instanceof ContinueAsNew ,
7576 } ) ;
7677 }
@@ -82,11 +83,12 @@ export class OpenTelemetryInboundInterceptor implements WorkflowInboundCallsInte
8283 const { getActivator, SdkFlags } = getSdkFlagsChecking ( ) ;
8384 const shouldInjectYield = getActivator ( ) . hasFlag ( SdkFlags . OpenTelemetryHandleSignalInterceptorInsertYield ) ;
8485 const context = extractContextFromHeaders ( input . headers ) ;
86+ if ( shouldInjectYield ) await Promise . resolve ( ) ;
8587 return await instrument ( {
8688 tracer : this . tracer ,
8789 spanName : `${ SpanName . WORKFLOW_SIGNAL } ${ SPAN_DELIMITER } ${ input . signalName } ` ,
8890 fn : ( ) => next ( input ) ,
89- context : shouldInjectYield ? await Promise . resolve ( context ) : context ,
91+ context,
9092 } ) ;
9193 }
9294}
@@ -109,11 +111,14 @@ export class OpenTelemetryOutboundInterceptor implements WorkflowOutboundCallsIn
109111 input : ActivityInput ,
110112 next : Next < WorkflowOutboundCallsInterceptor , 'scheduleActivity' >
111113 ) : Promise < unknown > {
114+ const { getActivator, SdkFlags } = getSdkFlagsChecking ( ) ;
115+ const shouldInjectYield = getActivator ( ) . hasFlag ( SdkFlags . OpenTelemetryInterceptorInsertYield ) ;
112116 return await instrument ( {
113117 tracer : this . tracer ,
114118 spanName : `${ SpanName . ACTIVITY_START } ${ SPAN_DELIMITER } ${ input . activityType } ` ,
115119 fn : async ( ) => {
116- const headers = await headersWithContext ( input . headers ) ;
120+ const headers = headersWithContext ( input . headers ) ;
121+ if ( shouldInjectYield ) await Promise . resolve ( ) ;
117122 return next ( {
118123 ...input ,
119124 headers,
@@ -126,11 +131,14 @@ export class OpenTelemetryOutboundInterceptor implements WorkflowOutboundCallsIn
126131 input : LocalActivityInput ,
127132 next : Next < WorkflowOutboundCallsInterceptor , 'scheduleLocalActivity' >
128133 ) : Promise < unknown > {
134+ const { getActivator, SdkFlags } = getSdkFlagsChecking ( ) ;
135+ const shouldInjectYield = getActivator ( ) . hasFlag ( SdkFlags . OpenTelemetryScheduleLocalActivityInterceptorInsertYield ) ;
129136 return await instrument ( {
130137 tracer : this . tracer ,
131138 spanName : `${ SpanName . ACTIVITY_START } ${ SPAN_DELIMITER } ${ input . activityType } ` ,
132139 fn : async ( ) => {
133- const headers = await headersWithContext ( input . headers ) ;
140+ const headers = headersWithContext ( input . headers ) ;
141+ if ( shouldInjectYield ) await Promise . resolve ( ) ;
134142 return next ( {
135143 ...input ,
136144 headers,
@@ -143,11 +151,14 @@ export class OpenTelemetryOutboundInterceptor implements WorkflowOutboundCallsIn
143151 input : StartChildWorkflowExecutionInput ,
144152 next : Next < WorkflowOutboundCallsInterceptor , 'startChildWorkflowExecution' >
145153 ) : Promise < [ Promise < string > , Promise < unknown > ] > {
154+ const { getActivator, SdkFlags } = getSdkFlagsChecking ( ) ;
155+ const shouldInjectYield = getActivator ( ) . hasFlag ( SdkFlags . OpenTelemetryInterceptorInsertYield ) ;
146156 return await instrument ( {
147157 tracer : this . tracer ,
148158 spanName : `${ SpanName . CHILD_WORKFLOW_START } ${ SPAN_DELIMITER } ${ input . workflowType } ` ,
149159 fn : async ( ) => {
150- const headers = await headersWithContext ( input . headers ) ;
160+ const headers = headersWithContext ( input . headers ) ;
161+ if ( shouldInjectYield ) await Promise . resolve ( ) ;
151162 return next ( {
152163 ...input ,
153164 headers,
@@ -161,11 +172,14 @@ export class OpenTelemetryOutboundInterceptor implements WorkflowOutboundCallsIn
161172 next : Next < WorkflowOutboundCallsInterceptor , 'continueAsNew' >
162173 ) : Promise < never > {
163174 const { ContinueAsNew } = getWorkflowModule ( ) ;
175+ const { getActivator, SdkFlags } = getSdkFlagsChecking ( ) ;
176+ const shouldInjectYield = getActivator ( ) . hasFlag ( SdkFlags . OpenTelemetryInterceptorInsertYield ) ;
164177 return await instrument ( {
165178 tracer : this . tracer ,
166179 spanName : `${ SpanName . CONTINUE_AS_NEW } ${ SPAN_DELIMITER } ${ input . options . workflowType } ` ,
167180 fn : async ( ) => {
168- const headers = await headersWithContext ( input . headers ) ;
181+ const headers = headersWithContext ( input . headers ) ;
182+ if ( shouldInjectYield ) await Promise . resolve ( ) ;
169183 return next ( {
170184 ...input ,
171185 headers,
@@ -179,11 +193,14 @@ export class OpenTelemetryOutboundInterceptor implements WorkflowOutboundCallsIn
179193 input : SignalWorkflowInput ,
180194 next : Next < WorkflowOutboundCallsInterceptor , 'signalWorkflow' >
181195 ) : Promise < void > {
196+ const { getActivator, SdkFlags } = getSdkFlagsChecking ( ) ;
197+ const shouldInjectYield = getActivator ( ) . hasFlag ( SdkFlags . OpenTelemetryInterceptorInsertYield ) ;
182198 return await instrument ( {
183199 tracer : this . tracer ,
184200 spanName : `${ SpanName . WORKFLOW_SIGNAL } ${ SPAN_DELIMITER } ${ input . signalName } ` ,
185201 fn : async ( ) => {
186- const headers = await headersWithContext ( input . headers ) ;
202+ const headers = headersWithContext ( input . headers ) ;
203+ if ( shouldInjectYield ) await Promise . resolve ( ) ;
187204 return next ( {
188205 ...input ,
189206 headers,
0 commit comments