Skip to content

Commit 3b311d2

Browse files
baywetCopilot
andcommitted
Python: align workflow name telemetry attribute with OpenTelemetry
Rename workflow.name to gen_ai.workflow.name and cover graph and functional workflows in streaming and non-streaming runs. Co-authored-by: Copilot <[email protected]> Copilot-Session: aa4dae7a-fdbd-475c-8ec6-fa8333e77cc4
1 parent c4c2dd5 commit 3b311d2

2 files changed

Lines changed: 13 additions & 6 deletions

File tree

‎python/packages/core/agent_framework/observability.py‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -295,7 +295,7 @@ class OtelAttr(str, Enum):
295295
WORKFLOW_ID = "workflow.id"
296296
WORKFLOW_BUILDER_NAME = "workflow_builder.name"
297297
WORKFLOW_BUILDER_DESCRIPTION = "workflow_builder.description"
298-
WORKFLOW_NAME = "workflow.name"
298+
WORKFLOW_NAME = "gen_ai.workflow.name"
299299
WORKFLOW_DESCRIPTION = "workflow.description"
300300
WORKFLOW_DEFINITION = "workflow.definition"
301301
WORKFLOW_BUILD_SPAN = "workflow.build"

‎python/packages/core/tests/workflow/test_workflow_observability.py‎

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -121,21 +121,24 @@ def processed_messages(self) -> list[Any]:
121121

122122

123123
@pytest.mark.parametrize("streaming", [False, True])
124-
@pytest.mark.parametrize("functional", [False, True])
124+
@pytest.mark.parametrize(
125+
("functional", "workflow_name"),
126+
[(False, "customer_support_pipeline"), (True, "customer_support_pipeline"), (True, None)],
127+
)
125128
async def test_workflow_run_span_uses_semantic_convention_name(
126-
span_exporter: InMemorySpanExporter, streaming: bool, functional: bool
129+
span_exporter: InMemorySpanExporter, streaming: bool, functional: bool, workflow_name: str | None
127130
) -> None:
128-
"""Graph and functional workflow invocations use the standard span name."""
131+
"""Graph and functional workflow invocations use standard span and workflow attribute names."""
129132
workflow_instance: Workflow | FunctionalWorkflow
130133
if functional:
131134

132-
@workflow
135+
@workflow(name=workflow_name)
133136
async def simple_workflow(message: str) -> str:
134137
return message
135138

136139
workflow_instance = simple_workflow.build()
137140
else:
138-
workflow_instance = WorkflowBuilder(start_executor=MockExecutor()).build()
141+
workflow_instance = WorkflowBuilder(start_executor=MockExecutor(), name=workflow_name).build()
139142

140143
span_exporter.clear()
141144
if streaming:
@@ -151,6 +154,10 @@ async def simple_workflow(message: str) -> str:
151154
]
152155
assert len(run_spans) == 1
153156
assert run_spans[0].name == "invoke_workflow"
157+
attributes = run_spans[0].attributes
158+
assert attributes is not None
159+
assert "workflow.name" not in attributes
160+
assert attributes["gen_ai.workflow.name"] == (workflow_name or "simple_workflow")
154161

155162

156163
async def test_span_creation_and_attributes(span_exporter: InMemorySpanExporter) -> None:

0 commit comments

Comments
 (0)