From 8cb3cecf3408b96e718b9e2f00d13697997a1b75 Mon Sep 17 00:00:00 2001 From: Vladimir Blagojevic Date: Mon, 29 Apr 2024 17:29:27 +0200 Subject: [PATCH] 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 Co-authored-by: Silvano Cerza <3314350+silvanocerza@users.noreply.github.com> --- haystack/core/pipeline/pipeline.py | 8 +++++--- .../improve-pipeline-run-tracing-1d80aa7810df4205.yaml | 4 ++++ test/core/pipeline/test_tracing.py | 4 ++++ 3 files changed, 13 insertions(+), 3 deletions(-) create mode 100644 releasenotes/notes/improve-pipeline-run-tracing-1d80aa7810df4205.yaml diff --git a/haystack/core/pipeline/pipeline.py b/haystack/core/pipeline/pipeline.py index ae09add8c..7fd4f4f0e 100644 --- a/haystack/core/pipeline/pipeline.py +++ b/haystack/core/pipeline/pipeline.py @@ -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] = {} diff --git a/releasenotes/notes/improve-pipeline-run-tracing-1d80aa7810df4205.yaml b/releasenotes/notes/improve-pipeline-run-tracing-1d80aa7810df4205.yaml new file mode 100644 index 000000000..c25257fd3 --- /dev/null +++ b/releasenotes/notes/improve-pipeline-run-tracing-1d80aa7810df4205.yaml @@ -0,0 +1,4 @@ +--- +enhancements: + - | + Improved pipeline run tracing to include pipeline input/output data. diff --git a/test/core/pipeline/test_tracing.py b/test/core/pipeline/test_tracing.py index a39eddb99..babb9b315 100644 --- a/test/core/pipeline/test_tracing.py +++ b/test/core/pipeline/test_tracing.py @@ -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,