@@ -144,6 +144,7 @@ def trace(
144144 tracer_and_exporter : init_tracer_and_exporter ,
145145 always_create_workflow_spans : false ,
146146 check_root : true ,
147+ append_finished_spans_to : nil ,
147148 &
148149 )
149150 tracer , exporter = tracer_and_exporter
@@ -161,6 +162,7 @@ def trace(
161162 end
162163
163164 # Convert spans, confirm there is only the outer, and return children
165+ append_finished_spans_to &.append ( *exporter . finished_spans )
164166 spans = ExpectedSpan . from_span_data ( exporter . finished_spans )
165167 if check_root
166168 assert_equal 1 , spans . size
@@ -175,9 +177,10 @@ def trace_workflow(
175177 start_with_untraced_client : false ,
176178 always_create_workflow_spans : false ,
177179 check_root : true ,
180+ append_finished_spans_to : nil ,
178181 &
179182 )
180- trace ( tracer_and_exporter :, always_create_workflow_spans :, check_root :) do |client |
183+ trace ( tracer_and_exporter :, always_create_workflow_spans :, check_root :, append_finished_spans_to : ) do |client |
181184 # Must capture and attach outer context
182185 outer_context = OpenTelemetry ::Context . current
183186 attach_token = nil
@@ -319,7 +322,8 @@ def test_handler_failures
319322
320323 def test_activity
321324 exp_root = ExpectedSpan . new ( name : 'root' )
322- act_root = trace_workflow ( :wait_on_signal ) do |handle |
325+ raw_finished_spans = [ ]
326+ act_root = trace_workflow ( :wait_on_signal , append_finished_spans_to : raw_finished_spans ) do |handle |
323327 exp_cl_attrs = { 'temporalWorkflowID' => handle . id }
324328 exp_run_attrs = exp_cl_attrs . merge ( { 'temporalRunID' => handle . result_run_id } )
325329 exp_start_wf = exp_root . add_child ( name : 'StartWorkflow:TestWorkflow' , attributes : exp_cl_attrs )
@@ -376,6 +380,11 @@ def test_activity
376380 handle . execute_update ( TestWorkflow . update , :call_local_activity , id : 'my-update-id2' )
377381 end
378382 assert_equal exp_root . to_s_indented , act_root . to_s_indented
383+
384+ # Confirm the custom in-workflow span time is within 5m of the given time
385+ custom_span = raw_finished_spans . find { |span | span . name == 'custom-workflow-span' } || raise
386+ assert_equal custom_span . start_timestamp , custom_span . end_timestamp
387+ assert_in_delta Time . now , Time . at ( 0 , custom_span . start_timestamp , :nanosecond ) , 5 * 60.0
379388 end
380389
381390 def test_client_fail
0 commit comments