File tree Expand file tree Collapse file tree 1 file changed +23
-1
lines changed
src/openlayer/lib/tracing Expand file tree Collapse file tree 1 file changed +23
-1
lines changed Original file line number Diff line number Diff line change @@ -371,6 +371,23 @@ def sync_wrapper(*func_args, **func_kwargs):
371
371
return decorator
372
372
373
373
374
+ def log_output (output : Any ) -> None :
375
+ """Logs output information to the current step of the trace.
376
+
377
+ This will overwrite the output of the currently active step instead of
378
+ relying on the returned object from the traced function.
379
+
380
+ Args:
381
+ output: The output value to log to the current step.
382
+ """
383
+ current_step = get_current_step ()
384
+ if current_step :
385
+ logger .debug ("Logging output to current step: %s" , output )
386
+ current_step .log (output = output , metadata = {"manual_output_logged" : True })
387
+ else :
388
+ logger .warning ("No current step found to log output." )
389
+
390
+
374
391
def log_context (context : List [str ]) -> None :
375
392
"""Logs context information to the current step of the trace.
376
393
@@ -562,9 +579,14 @@ def _finalize_step_logging(
562
579
if step .latency is None :
563
580
step .latency = (step .end_time - start_time ) * 1000 # in ms
564
581
582
+ # Check if manual output was logged
583
+ if step .metadata .get ("manual_output_logged" ):
584
+ logger .debug ("Using manually logged output for step: %s" , step .name )
585
+ else :
586
+ step .log (output = output )
587
+
565
588
step .log (
566
589
inputs = inputs ,
567
- output = output ,
568
590
end_time = step .end_time ,
569
591
latency = step .latency ,
570
592
)
You can’t perform that action at this time.
0 commit comments