Skip to content

Commit 1291bb0

Browse files
gustavocidornelaswhoseoyster
authored andcommitted
chore(closes OPEN-10613): assign step type in trace decorator
1 parent 42f20f4 commit 1291bb0

1 file changed

Lines changed: 17 additions & 2 deletions

File tree

src/openlayer/lib/tracing/tracer.py

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -593,6 +593,12 @@ def decorator(func):
593593
step_kwargs["name"] = func.__name__
594594
step_name = step_kwargs["name"]
595595

596+
_raw_step_type = step_kwargs.get("step_type", enums.StepType.USER_CALL)
597+
if isinstance(_raw_step_type, str):
598+
_raw_step_type = enums.StepType(_raw_step_type)
599+
step_type = _raw_step_type
600+
step_kwargs["step_type"] = step_type
601+
596602
# Check if it's a generator function
597603
if inspect.isgeneratorfunction(func):
598604
# For sync generators, use class-based approach to delay trace creation
@@ -622,7 +628,7 @@ def __next__(self):
622628
self._step, self._is_root_step, self._token = (
623629
_create_and_initialize_step(
624630
step_name=step_name,
625-
step_type=enums.StepType.USER_CALL,
631+
step_type=step_type,
626632
inputs=None,
627633
output=None,
628634
metadata=None,
@@ -906,6 +912,12 @@ def decorator(func):
906912
step_kwargs["name"] = func.__name__
907913
step_name = step_kwargs["name"]
908914

915+
_raw_step_type = step_kwargs.get("step_type", enums.StepType.USER_CALL)
916+
if isinstance(_raw_step_type, str):
917+
_raw_step_type = enums.StepType(_raw_step_type)
918+
step_type = _raw_step_type
919+
step_kwargs["step_type"] = step_type
920+
909921
if asyncio.iscoroutinefunction(func) or inspect.isasyncgenfunction(func):
910922
# Check if it's specifically an async generator function
911923
if inspect.isasyncgenfunction(func):
@@ -933,7 +945,7 @@ async def __anext__(self):
933945
self._step, self._is_root_step, self._token = (
934946
_create_and_initialize_step(
935947
step_name=step_name,
936-
step_type=enums.StepType.USER_CALL,
948+
step_type=step_type,
937949
inputs=None,
938950
output=None,
939951
metadata=None,
@@ -1867,6 +1879,9 @@ def _process_wrapper_inputs_and_outputs(
18671879
context_kwarg=context_kwarg,
18681880
question_kwarg=question_kwarg,
18691881
)
1882+
if isinstance(step, steps.ToolStep):
1883+
step.function_name = step.name
1884+
step.arguments = inputs
18701885
_finalize_step_logging(
18711886
step=step,
18721887
inputs=inputs,

0 commit comments

Comments
 (0)