@@ -585,49 +585,37 @@ async def test_otel_standalone_activity_tracing(
585585 new_config ["plugins" ] = [OpenTelemetryPlugin (add_temporal_spans = True )]
586586 new_client = Client (** new_config )
587587
588+ activity_id = f"activity_{ uuid .uuid4 ()} "
588589 async with new_worker (
589590 new_client ,
590591 activities = [simple_no_context_activity ],
591592 ) as worker :
592593 handle = await new_client .start_activity (
593594 simple_no_context_activity ,
594- id = f"activity_ { uuid . uuid4 () } " ,
595+ id = activity_id ,
595596 task_queue = worker .task_queue ,
596597 schedule_to_close_timeout = timedelta (seconds = 10 ),
597598 )
598599 await handle .result ()
599600
600- # Use a queue with no worker so activities stay in SCHEDULED state,
601- # allowing describe/cancel/terminate to be called without a race.
602- no_worker_queue = f"task_queue_{ uuid .uuid4 ()} "
603-
604- cancel_handle = await new_client .start_activity (
605- simple_no_context_activity ,
606- id = f"activity_{ uuid .uuid4 ()} " ,
607- task_queue = no_worker_queue ,
608- schedule_to_close_timeout = timedelta (seconds = 30 ),
609- )
610- await cancel_handle .describe ()
611- await cancel_handle .cancel ()
612-
613- terminate_handle = await new_client .start_activity (
614- simple_no_context_activity ,
615- id = f"activity_{ uuid .uuid4 ()} " ,
616- task_queue = no_worker_queue ,
617- schedule_to_close_timeout = timedelta (seconds = 30 ),
618- )
619- await terminate_handle .terminate ()
620-
621- assert dump_spans (exporter .get_finished_spans (), with_attributes = False ) == [
601+ finished_spans = exporter .get_finished_spans ()
602+ assert dump_spans (finished_spans , with_attributes = False ) == [
622603 "StartActivity:simple_no_context_activity" ,
623604 " RunActivity:simple_no_context_activity" ,
624605 " Activity" ,
625- "StartActivity:simple_no_context_activity" ,
626- "DescribeActivity" ,
627- "CancelActivity" ,
628- "StartActivity:simple_no_context_activity" ,
629- "TerminateActivity" ,
630606 ]
607+ start_activity_span = next (
608+ s
609+ for s in finished_spans
610+ if s .name == "StartActivity:simple_no_context_activity"
611+ and s .attributes is not None
612+ and s .attributes .get ("temporalActivityID" ) == activity_id
613+ )
614+ assert start_activity_span .attributes is not None
615+ assert (
616+ start_activity_span .attributes ["temporalActivityType" ]
617+ == "simple_no_context_activity"
618+ )
631619
632620
633621def test_replay_safe_span_delegates_extra_attributes ():
0 commit comments