feat: Trace pipeline run input/output data (#7590)

* Trace pipeline run

* Add reno note

* Update tracing tests to check input_data and output_data

* empty

---------

Co-authored-by: anakin87 <stefanofiorucci@gmail.com>
Co-authored-by: Silvano Cerza <3314350+silvanocerza@users.noreply.github.com>
This commit is contained in:
Vladimir Blagojevic 2024-04-29 17:29:27 +02:00 committed by GitHub
parent 451fae880e
commit 8cb3cecf34
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 13 additions and 3 deletions

View File

@ -796,17 +796,19 @@ class Pipeline:
include_outputs_from = set() if include_outputs_from is None else include_outputs_from
# This is what we'll return at the end
final_outputs: Dict[Any, Any] = {}
with tracing.tracer.trace(
"haystack.pipeline.run",
tags={
"haystack.pipeline.input_data": data,
"haystack.pipeline.output_data": final_outputs,
"haystack.pipeline.debug": debug,
"haystack.pipeline.metadata": self.metadata,
"haystack.pipeline.max_loops_allowed": self.max_loops_allowed,
},
):
# This is what we'll return at the end
final_outputs: Dict[Any, Any] = {}
# Cache for extra outputs, if enabled.
extra_outputs: Dict[Any, Any] = {}

View File

@ -0,0 +1,4 @@
---
enhancements:
- |
Improved pipeline run tracing to include pipeline input/output data.

View File

@ -39,6 +39,8 @@ class TestTracing:
SpyingSpan(
operation_name="haystack.pipeline.run",
tags={
"haystack.pipeline.input_data": {"hello": {"word": "world"}},
"haystack.pipeline.output_data": {"hello2": {"output": "Hello, Hello, world!!"}},
"haystack.pipeline.debug": False,
"haystack.pipeline.metadata": {},
"haystack.pipeline.max_loops_allowed": 100,
@ -97,6 +99,8 @@ class TestTracing:
"haystack.pipeline.debug": False,
"haystack.pipeline.metadata": {},
"haystack.pipeline.max_loops_allowed": 100,
"haystack.pipeline.input_data": {"hello": {"word": "world"}},
"haystack.pipeline.output_data": {"hello2": {"output": "Hello, Hello, world!!"}},
},
trace_id=ANY,
span_id=ANY,