|
1 |
| -import logging |
2 |
| -from typing import ( |
3 |
| - Any, |
4 |
| - Mapping, |
5 |
| - MutableMapping, |
6 |
| - Optional, |
7 |
| -) |
8 |
| - |
9 | 1 | from ._decorators import workflow_run_operation as workflow_run_operation
|
10 | 2 | from ._operation_context import Info as Info
|
11 | 3 | from ._operation_context import (
|
|
19 | 11 | )
|
20 | 12 | from ._operation_context import client as client
|
21 | 13 | from ._operation_context import info as info
|
| 14 | +from ._operation_context import logger as logger |
22 | 15 | from ._operation_handlers import cancel_operation as cancel_operation
|
23 | 16 | from ._token import WorkflowHandle as WorkflowHandle
|
24 | 17 |
|
25 | 18 |
|
26 |
| -class LoggerAdapter(logging.LoggerAdapter): |
27 |
| - def __init__(self, logger: logging.Logger, extra: Optional[Mapping[str, Any]]): |
28 |
| - super().__init__(logger, extra or {}) |
29 |
| - |
30 |
| - def process( |
31 |
| - self, msg: Any, kwargs: MutableMapping[str, Any] |
32 |
| - ) -> tuple[Any, MutableMapping[str, Any]]: |
33 |
| - extra = dict(self.extra or {}) |
34 |
| - if tctx := _temporal_operation_context.get(None): |
35 |
| - extra["service"] = tctx.nexus_operation_context.service |
36 |
| - extra["operation"] = tctx.nexus_operation_context.operation |
37 |
| - extra["task_queue"] = tctx.info().task_queue |
38 |
| - kwargs["extra"] = extra | kwargs.get("extra", {}) |
39 |
| - return msg, kwargs |
40 |
| - |
41 |
| - |
42 |
| -logger = LoggerAdapter(logging.getLogger(__name__), None) |
43 |
| -"""Logger that emits additional data describing the current Nexus operation.""" |
44 |
| - |
45 | 19 | # TODO(nexus-prerelease) WARN temporal_sdk_core::worker::nexus: Failed to parse nexus timeout header value '9.155416ms'
|
46 | 20 | # 2025-06-25T12:58:05.749589Z WARN temporal_sdk_core::worker::nexus: Failed to parse nexus timeout header value '9.155416ms'
|
47 | 21 | # 2025-06-25T12:58:05.763052Z WARN temporal_sdk_core::worker::nexus: Nexus task not found on completion. This may happen if the operation has already been cancelled but completed anyway. details=Status { code: NotFound, message: "Nexus task not found or already expired", details: b"\x08\x05\x12'Nexus task not found or already expired\x1aB\n@type.googleapis.com/temporal.api.errordetails.v1.NotFoundFailure", metadata: MetadataMap { headers: {"content-type": "application/grpc"} }, source: None }
|
0 commit comments