feat: add support for serializing WorkflowSpan input and output#472
Open
feat: add support for serializing WorkflowSpan input and output#472
Conversation
e89351e to
45d9ed1
Compare
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #472 +/- ##
==========================================
+ Coverage 82.61% 82.74% +0.12%
==========================================
Files 96 96
Lines 9147 9168 +21
==========================================
+ Hits 7557 7586 +29
+ Misses 1590 1582 -8 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
Focadecombate
approved these changes
Feb 17, 2026
This change adds support for properly serializing the input and output of a WorkflowSpan in the OpenTelemetry instrumentation. It handles both string and Message object formats, as well as sequences of Documents in the output. The changes ensure that the full context of the workflow is captured in the OpenTelemetry spans, which is crucial for understanding the flow and debugging issues. Additionally, the start_galileo_span context manager was updated to correctly handle WorkflowSpan instances.
- Uses the `model_construct` method to bypass a validator bug in `galileo_core` - Leverages the `document_adapter` utility for consistent serialization of the output documents
1c994c8 to
d56204e
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Shortcut:
Description:
This change adds support for properly serializing the input and output of a WorkflowSpan in the OpenTelemetry instrumentation. It handles both string and Message object formats, as well as sequences of Documents in the output.
The changes ensure that the full context of the workflow is captured in the OpenTelemetry spans, which is crucial for understanding the flow and debugging issues.
Additionally, the start_galileo_span context manager was updated to correctly handle WorkflowSpan instances.
Tests:
Generated description
Below is a concise technical summary of changes proposed in this PR:
This pull request adds support for
WorkflowSpanOpenTelemetry attribute mapping in thestart_galileo_span()function. Previously, when aWorkflowSpanwas passed tostart_galileo_span(), no type-specific attributes were set, resulting in incomplete telemetry data. The implementation follows the existing pattern established by_set_retriever_span_attributes()and properly handles the polymorphic input and output types defined forWorkflowSpan.WorkflowSpaninstances instart_galileo_span(). The implementation includes a new helper function_set_workflow_span_attributes()that correctly serializes polymorphic input types (Union[str, Sequence[Message]]) and output types (Union[str, Message, Sequence[Document], None]) into OpenTelemetry'sgen_ai.input.messagesandgen_ai.output.messagesattributes. String values are wrapped in appropriate message objects with role metadata, Message objects are serialized usingmodel_dump(exclude_none=True), and Document sequences are nested within an assistant message. None values for output are handled gracefully by skipping the attribute.Modified files (2)
Latest Contributors(0)
Evidences
I've created a demo script callled workflow_span_demo.py to test this changes. To run this script we need to export a couple of credentials:
Inside the galileo-python directory I've started a new
virtualenvso we can install the project locally:Then I installed the dependencies:
After all this, I've ran the
workflow_span_demo.pyPython script and got this as a result:What it demonstrates:
The demo script tests all polymorphic input/output types for
WorkflowSpan:Demo 1: String Input/Output
"What is the capital of France?"→{"role": "user", "content": "..."}"The capital of France is Paris."→{"role": "assistant", "content": "..."}Demo 2: Message Input/Output
Messageobjects for input and outputmodel_dump(exclude_none=True)to preserve all propertiesDemo 3: Document Sequence Output
Documentobjects with metadata as output{"role": "assistant", "content": {"documents": [...]}}Demo 4: None Output (Edge Case)
Nonegen_ai.input.messagesattribute is setgen_ai.output.messagesattribute is skipped entirelyDemo 5: Nested Workflow Spans (Real-world RAG)