@@ -842,16 +842,22 @@ def main():
842842 else None
843843 )
844844
845- if trace_id :
846- # Set trace metadata for later retrieval and filtering
847- Laminar .set_trace_metadata (
848- {
849- "pr_number" : pr_info ["number" ],
850- "repo_name" : pr_info ["repo_name" ],
851- "workflow_phase" : "review" ,
852- "review_style" : review_style ,
853- }
854- )
845+ if trace_id and laminar_span_context :
846+ # Set trace metadata within an active span context
847+ # Using start_as_current_span with parent_span_context to continue the trace
848+ with Laminar .start_as_current_span (
849+ name = "pr-review-metadata" ,
850+ parent_span_context = laminar_span_context ,
851+ ) as _ :
852+ # Set trace metadata within this active span context
853+ Laminar .set_trace_metadata (
854+ {
855+ "pr_number" : pr_info ["number" ],
856+ "repo_name" : pr_info ["repo_name" ],
857+ "workflow_phase" : "review" ,
858+ "review_style" : review_style ,
859+ }
860+ )
855861
856862 # Store trace context in file for GitHub artifact upload
857863 # This allows the evaluation workflow to add its span to this trace
0 commit comments