Skip to content

Commit 91c56f3

Browse files
committed
Use xray
1 parent 024b174 commit 91c56f3

2 files changed

Lines changed: 9 additions & 0 deletions

File tree

hello_nexus/caller/workflows.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
from datetime import timedelta
22

3+
import xray
34
from temporalio import workflow
45
from temporalio.exceptions import FailureError
56
from temporalio.workflow import NexusClient
@@ -24,6 +25,7 @@ def __init__(self):
2425

2526
@workflow.defn
2627
class EchoCallerWorkflow(CallerWorkflowBase):
28+
@xray.start_as_current_workflow_method_span()
2729
@workflow.run
2830
async def run(self, message: str) -> EchoOutput:
2931
op_output = await self.nexus_client.execute_operation(
@@ -35,6 +37,7 @@ async def run(self, message: str) -> EchoOutput:
3537

3638
@workflow.defn
3739
class Echo2CallerWorkflow(CallerWorkflowBase):
40+
@xray.start_as_current_workflow_method_span()
3841
@workflow.run
3942
async def run(self, message: str) -> EchoOutput:
4043
op_output = await self.nexus_client.execute_operation(
@@ -46,6 +49,7 @@ async def run(self, message: str) -> EchoOutput:
4649

4750
@workflow.defn
4851
class Echo3CallerWorkflow(CallerWorkflowBase):
52+
@xray.start_as_current_workflow_method_span()
4953
@workflow.run
5054
async def run(self, message: str) -> EchoOutput:
5155
op_output = await self.nexus_client.execute_operation(
@@ -57,6 +61,7 @@ async def run(self, message: str) -> EchoOutput:
5761

5862
@workflow.defn
5963
class HelloCallerWorkflow(CallerWorkflowBase):
64+
@xray.start_as_current_workflow_method_span()
6065
@workflow.run
6166
async def run(self, name: str) -> HelloOutput:
6267
handle = await self.nexus_client.start_operation(
@@ -78,6 +83,7 @@ async def run(self, name: str) -> HelloOutput:
7883

7984
@workflow.defn
8085
class Hello2CallerWorkflow(CallerWorkflowBase):
86+
@xray.start_as_current_workflow_method_span()
8187
@workflow.run
8288
async def run(self, name: str) -> HelloOutput:
8389
handle = await self.nexus_client.start_operation(
@@ -89,6 +95,7 @@ async def run(self, name: str) -> HelloOutput:
8995

9096
@workflow.defn
9197
class Hello3CallerWorkflow(CallerWorkflowBase):
98+
@xray.start_as_current_workflow_method_span()
9299
@workflow.run
93100
async def run(self, name: str) -> HelloOutput:
94101
handle = await self.nexus_client.start_operation(

hello_nexus/handler/workflows.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import asyncio
22

3+
import xray
34
from temporalio import workflow
45

56
from hello_nexus.service.interface import (
@@ -14,6 +15,7 @@ class HelloWorkflow:
1415
Workflow that backs the `hello` operation.
1516
"""
1617

18+
@xray.start_as_current_workflow_method_span()
1719
@workflow.run
1820
async def run(self, input: HelloInput) -> HelloOutput:
1921
await asyncio.sleep(1) # so that it can be cancelled

0 commit comments

Comments
 (0)