Skip to content

Commit a7cdf87

Browse files
committed
made operation name immutable and added test
1 parent 733b5ef commit a7cdf87

2 files changed

Lines changed: 7 additions & 0 deletions

File tree

util/opentelemetry-util-genai/src/opentelemetry/util/genai/types.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -285,6 +285,9 @@ class WorkflowInvocation(GenAIInvocation):
285285
default_factory=_new_output_messages
286286
)
287287

288+
def __post_init__(self) -> None:
289+
self.operation_name = "invoke_workflow"
290+
288291

289292
@dataclass
290293
class LLMInvocation(GenAIInvocation):

util/opentelemetry-util-genai/tests/test_handler_workflow.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,10 @@ class TelemetryHandlerWorkflowTest(_WorkflowTestBase):
4747
# start_workflow
4848
# ------------------------------------------------------------------
4949

50+
def test_operation_name_is_immutable(self) -> None:
51+
invocation = WorkflowInvocation(name="wf", operation_name="custom_op")
52+
self.assertEqual(invocation.operation_name, "invoke_workflow")
53+
5054
def test_start_workflow_creates_span(self) -> None:
5155
invocation = WorkflowInvocation(name="my_workflow")
5256
self.handler.start(invocation)

0 commit comments

Comments
 (0)