Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 5 additions & 4 deletions guardrails/telemetry/guard_tracing.py
Original file line number Diff line number Diff line change
Expand Up @@ -179,10 +179,11 @@ def trace_guard_execution(
if isinstance(result, Iterator) and not isinstance(
result, ValidationOutcome
):
return trace_stream_guard(guard_span, result, history)
add_guard_attributes(guard_span, history, result)
add_user_attributes(guard_span)
return result
for res in trace_stream_guard(guard_span, result, history):
yield res
else:
add_guard_attributes(guard_span, history, result)
add_user_attributes(guard_span)
except Exception as e:
guard_span.set_status(status=StatusCode.ERROR, description=str(e))
raise e
Expand Down
5 changes: 5 additions & 0 deletions guardrails/telemetry/runner_tracing.py
Original file line number Diff line number Diff line change
Expand Up @@ -265,6 +265,11 @@ def trace_call_wrapper(*args, **kwargs):
) as call_span:
try:
response = fn(*args, **kwargs)
if isinstance(response, LLMResponse) and (
response.async_stream_output or response.stream_output
):
# TODO: Iterate, add a call attr each time
return response
add_call_attributes(call_span, response, *args, **kwargs)
return response
except Exception as e:
Expand Down
Loading