-
Notifications
You must be signed in to change notification settings - Fork 95
Expand file tree
/
Copy pathstarter.py
More file actions
34 lines (26 loc) · 912 Bytes
/
starter.py
File metadata and controls
34 lines (26 loc) · 912 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
import asyncio
from temporalio.client import Client
from temporalio.contrib.opentelemetry import TracingInterceptor
from temporalio.envconfig import ClientConfig
from open_telemetry.worker import GreetingWorkflow, init_runtime_with_telemetry
async def main():
runtime = init_runtime_with_telemetry()
config = ClientConfig.load_client_connect_config()
config.setdefault("target_host", "localhost:7233")
# Connect client
client = await Client.connect(
**config,
# Use OpenTelemetry interceptor
interceptors=[TracingInterceptor()],
runtime=runtime,
)
# Run workflow
result = await client.execute_workflow(
GreetingWorkflow.run,
"Temporal",
id=f"open_telemetry-workflow-id",
task_queue="open_telemetry-task-queue",
)
print(f"Workflow result: {result}")
if __name__ == "__main__":
asyncio.run(main())