@@ -143,6 +143,7 @@ def trace(
143143 tracer_and_exporter : init_tracer_and_exporter ,
144144 always_create_workflow_spans : false ,
145145 check_root : true ,
146+ append_finished_spans_to : nil ,
146147 &
147148 )
148149 tracer , exporter = tracer_and_exporter
@@ -160,6 +161,7 @@ def trace(
160161 end
161162
162163 # Convert spans, confirm there is only the outer, and return children
164+ append_finished_spans_to &.append ( *exporter . finished_spans )
163165 spans = ExpectedSpan . from_span_data ( exporter . finished_spans )
164166 if check_root
165167 assert_equal 1 , spans . size
@@ -174,9 +176,10 @@ def trace_workflow(
174176 start_with_untraced_client : false ,
175177 always_create_workflow_spans : false ,
176178 check_root : true ,
179+ append_finished_spans_to : nil ,
177180 &
178181 )
179- trace ( tracer_and_exporter :, always_create_workflow_spans :, check_root :) do |client |
182+ trace ( tracer_and_exporter :, always_create_workflow_spans :, check_root :, append_finished_spans_to : ) do |client |
180183 # Must capture and attach outer context
181184 outer_context = OpenTelemetry ::Context . current
182185 attach_token = nil
@@ -318,7 +321,8 @@ def test_handler_failures
318321
319322 def test_activity
320323 exp_root = ExpectedSpan . new ( name : 'root' )
321- act_root = trace_workflow ( :wait_on_signal ) do |handle |
324+ raw_finished_spans = [ ]
325+ act_root = trace_workflow ( :wait_on_signal , append_finished_spans_to : raw_finished_spans ) do |handle |
322326 exp_cl_attrs = { 'temporalWorkflowID' => handle . id }
323327 exp_run_attrs = exp_cl_attrs . merge ( { 'temporalRunID' => handle . result_run_id } )
324328 exp_start_wf = exp_root . add_child ( name : 'StartWorkflow:TestWorkflow' , attributes : exp_cl_attrs )
@@ -375,6 +379,11 @@ def test_activity
375379 handle . execute_update ( TestWorkflow . update , :call_local_activity , id : 'my-update-id2' )
376380 end
377381 assert_equal exp_root . to_s_indented , act_root . to_s_indented
382+
383+ # Confirm the custom in-workflow span time is within 5m of the given time
384+ custom_span = raw_finished_spans . find { |span | span . name == 'custom-workflow-span' } || raise
385+ assert_equal custom_span . start_timestamp , custom_span . end_timestamp
386+ assert_in_delta Time . now , Time . at ( 0 , custom_span . start_timestamp , :nanosecond ) , 5 * 60.0
378387 end
379388
380389 def test_client_fail
0 commit comments