|
42 | 42 | cast,
|
43 | 43 | )
|
44 | 44 |
|
| 45 | +from google.protobuf.json_format import MessageToJson |
| 46 | +from opentelemetry import trace |
45 | 47 | from typing_extensions import Self, TypeAlias, TypedDict
|
46 | 48 |
|
47 | 49 | import temporalio.activity
|
|
75 | 77 | )
|
76 | 78 |
|
77 | 79 | logger = logging.getLogger(__name__)
|
| 80 | +tracer = trace.get_tracer(__name__) |
78 | 81 |
|
79 | 82 | # Set to true to log all cases where we're ignoring things during delete
|
80 | 83 | LOG_IGNORE_DURING_DELETE = False
|
@@ -325,6 +328,21 @@ def get_thread_id(self) -> Optional[int]:
|
325 | 328 |
|
326 | 329 | def activate(
|
327 | 330 | self, act: temporalio.bridge.proto.workflow_activation.WorkflowActivation
|
| 331 | + ) -> temporalio.bridge.proto.workflow_completion.WorkflowActivationCompletion: |
| 332 | + with tracer.start_as_current_span("HandleWorkflowActivation") as span: |
| 333 | + span.set_attribute("rpc.method", "WorkflowActivation") |
| 334 | + span.set_attribute("rpc.request.type", "WorkflowActivation") |
| 335 | + span.set_attribute("rpc.request.payload", MessageToJson(act)) |
| 336 | + span.set_attribute("temporalWorkflowID", self._info.workflow_id) |
| 337 | + span.set_attribute("temporal.worker", True) |
| 338 | + completion = self._activate(act) |
| 339 | + span.set_attribute("rpc.response.type", "WorkflowActivationCompletion") |
| 340 | + span.set_attribute("rpc.response.payload", MessageToJson(completion)) |
| 341 | + trace.get_tracer_provider().force_flush() # type: ignore |
| 342 | + return completion |
| 343 | + |
| 344 | + def _activate( |
| 345 | + self, act: temporalio.bridge.proto.workflow_activation.WorkflowActivation |
328 | 346 | ) -> temporalio.bridge.proto.workflow_completion.WorkflowActivationCompletion:
|
329 | 347 | # Reset current completion, time, and whether replaying
|
330 | 348 | self._current_completion = (
|
|
0 commit comments