@@ -12,7 +12,7 @@ import { BasicTracerProvider, InMemorySpanExporter, SimpleSpanProcessor } from '
1212import { SemanticResourceAttributes } from '@opentelemetry/semantic-conventions' ;
1313import test from 'ava' ;
1414import { v4 as uuid4 } from 'uuid' ;
15- import { WorkflowClient } from '@temporalio/client' ;
15+ import { WorkflowClient , WithStartWorkflowOperation } from '@temporalio/client' ;
1616import { OpenTelemetryWorkflowClientInterceptor } from '@temporalio/interceptors-opentelemetry/lib/client' ;
1717import { OpenTelemetryWorkflowClientCallsInterceptor } from '@temporalio/interceptors-opentelemetry' ;
1818import { instrument } from '@temporalio/interceptors-opentelemetry/lib/instrumentation' ;
@@ -510,6 +510,61 @@ if (RUN_INTEGRATION_TESTS) {
510510 t . is ( spans [ 1 ] . status . message , 'benign' ) ;
511511 t . is ( spans [ 2 ] . status . code , SpanStatusCode . OK ) ;
512512 } ) ;
513+
514+ test ( 'executeUpdateWithStart works correctly with OTEL interceptors' , async ( t ) => {
515+ const staticResource = new opentelemetry . resources . Resource ( {
516+ [ SemanticResourceAttributes . SERVICE_NAME ] : 'ts-test-otel-worker' ,
517+ } ) ;
518+ const traceExporter : opentelemetry . tracing . SpanExporter = {
519+ export ( _spans , resultCallback ) {
520+ resultCallback ( { code : ExportResultCode . SUCCESS } ) ;
521+ } ,
522+ async shutdown ( ) { } ,
523+ } ;
524+
525+ const sinks : InjectedSinks < OpenTelemetrySinks > = {
526+ exporter : makeWorkflowExporter ( traceExporter , staticResource ) ,
527+ } ;
528+
529+ const worker = await Worker . create ( {
530+ workflowBundle : await createTestWorkflowBundle ( {
531+ workflowsPath : require . resolve ( './workflows' ) ,
532+ workflowInterceptorModules : [ require . resolve ( './workflows/otel-interceptors' ) ] ,
533+ } ) ,
534+ activities,
535+ taskQueue : 'test-otel-update-start' ,
536+ interceptors : {
537+ client : {
538+ workflow : [ new OpenTelemetryWorkflowClientCallsInterceptor ( ) ] ,
539+ } ,
540+ workflowModules : [ require . resolve ( './workflows/otel-interceptors' ) ] ,
541+ } ,
542+ sinks,
543+ } ) ;
544+
545+ const client = new WorkflowClient ( ) ;
546+
547+ const startWorkflowOperation = new WithStartWorkflowOperation ( workflows . updateStartOtel , {
548+ workflowId : uuid4 ( ) ,
549+ taskQueue : 'test-otel-update-start' ,
550+ workflowIdConflictPolicy : 'FAIL' ,
551+ } ) ;
552+
553+ const { updateResult, workflowResult } = await worker . runUntil ( async ( ) => {
554+ const updateResult = await client . executeUpdateWithStart ( workflows . otelUpdate , {
555+ args : [ true ] ,
556+ startWorkflowOperation,
557+ } ) ;
558+
559+ const handle = await startWorkflowOperation . workflowHandle ( ) ;
560+ const workflowResult = await handle . result ( ) ;
561+
562+ return { updateResult, workflowResult } ;
563+ } ) ;
564+
565+ t . is ( updateResult , true ) ;
566+ t . is ( workflowResult , true ) ;
567+ } ) ;
513568}
514569
515570test ( 'Can replay otel history from 1.11.3' , async ( t ) => {
0 commit comments