Skip to content

Self-improving AI Employees for everyone

fix(temporal): keep the slow workflow task warning on SDK 1.34

trohitg4735ab00c0b7
diff --git a/docs-internal/TEMPORAL_ARCHITECTURE.md b/docs-internal/TEMPORAL_ARCHITECTURE.md
index a5f03c1f..cabdeb8e 100644
--- a/docs-internal/TEMPORAL_ARCHITECTURE.md
+++ b/docs-internal/TEMPORAL_ARCHITECTURE.md
@@ -991,11 +991,11 @@ workflow.start_activity("execute_node_activity", args=[context])
### Runtime Configuration
-Worker heartbeating is disabled to avoid warnings on older Temporal server versions:
+Worker heartbeating is disabled to avoid warnings on older Temporal server versions. Core, the SDK's Rust side, writes its own logs to stderr through `CORE_LOG_FILTER` (`services/temporal/client.py`, also used by `worker.create_runtime`). The filter passes errors, plus the `[TMPRL1104]` warning for a workflow task over 5 s, which blocks every workflow on the worker. SDK 1.34 moved that warning from Python logging into Core, so an ERROR-only filter would hide it (`tests/temporal/test_core_log_filter.py`):
```python
runtime = Runtime(
- telemetry=TelemetryConfig(),
+ telemetry=TelemetryConfig(logging=LoggingConfig(filter=CORE_LOG_FILTER)),
worker_heartbeat_interval=None, # Disable runtime heartbeating
)
client = await Client.connect(server_address, namespace=namespace, runtime=runtime)
diff --git a/server/services/temporal/client.py b/server/services/temporal/client.py
index d5a77dc7..6a382b91 100644
--- a/server/services/temporal/client.py
+++ b/server/services/temporal/client.py
@@ -16,6 +16,12 @@ from core.logging import get_logger
logger = get_logger(__name__)
+# Core (the SDK's Rust side) writes its own logs to stderr: errors only, plus
+# the [TMPRL1104] warning for a workflow task over 5 s, which blocks every
+# workflow on the worker. SDK 1.34 moved that warning from Python into Core,
+# so an ERROR-only filter would hide it.
+CORE_LOG_FILTER = "ERROR,temporalio_sdk_core::worker::workflow::managed_run=WARN"
+
def _is_transient_visibility_error(exc: Exception) -> bool:
"""True if ``exc`` is a transient server-warmup/visibility error a
@@ -77,7 +83,7 @@ class TemporalClientWrapper:
if self._runtime is None:
self._runtime = Runtime(
telemetry=TelemetryConfig(
- logging=LoggingConfig(filter="ERROR"),
+ logging=LoggingConfig(filter=CORE_LOG_FILTER),
),
worker_heartbeat_interval=None,
)
diff --git a/server/services/temporal/worker.py b/server/services/temporal/worker.py
index 87f80427..ac2ec4f8 100644
--- a/server/services/temporal/worker.py
+++ b/server/services/temporal/worker.py
@@ -94,9 +94,11 @@ def create_runtime() -> Runtime:
Disables the runtime-level worker heartbeating feature to avoid
the warning on older Temporal server versions that don't support it.
"""
+ from services.temporal.client import CORE_LOG_FILTER
+
return Runtime(
telemetry=TelemetryConfig(
- logging=LoggingConfig(filter="ERROR"),
+ logging=LoggingConfig(filter=CORE_LOG_FILTER),
),
worker_heartbeat_interval=None, # Disable runtime heartbeating
)
diff --git a/server/tests/temporal/test_core_log_filter.py b/server/tests/temporal/test_core_log_filter.py
new file mode 100644
index 00000000..30ae67a4
--- /dev/null
+++ b/server/tests/temporal/test_core_log_filter.py
@@ -0,0 +1,54 @@
+"""Core's logs keep the slow workflow task warning.
+
+SDK 1.34 moved [TMPRL1104], a workflow task over 5 s, from Python logging
+into Core, which writes its own logs to stderr. Both of the app's runtimes
+filtered Core at ERROR, so the upgrade hid the warning. On the pinned dev
+server a 6 s workflow task printed it with ``CORE_LOG_FILTER`` and nothing
+with ERROR alone.
+"""
+
+from __future__ import annotations
+
+from unittest.mock import AsyncMock, MagicMock
+
+import pytest
+
+import services.temporal.client as client_mod
+import services.temporal.worker as worker_mod
+
+
+def _record_runtimes(monkeypatch, module) -> list:
+ """Replace the runtime constructors with recorders of the Core filter."""
+ built: list = []
+ monkeypatch.setattr(module, "LoggingConfig", lambda filter: filter)
+ monkeypatch.setattr(module, "TelemetryConfig", lambda logging: logging)
+ monkeypatch.setattr(
+ module,
+ "Runtime",
+ lambda telemetry, worker_heartbeat_interval: built.append(telemetry) or MagicMock(),
+ )
+ return built
+
+
+def test_the_filter_keeps_core_errors_and_the_slow_task_warning():
+ directives = client_mod.CORE_LOG_FILTER.split(",")
+ assert directives[0] == "ERROR"
+ assert "temporalio_sdk_core::worker::workflow::managed_run=WARN" in directives
+
+
+def test_the_standalone_worker_runtime_uses_the_filter(monkeypatch):
+ built = _record_runtimes(monkeypatch, worker_mod)
+ worker_mod.create_runtime()
+ assert built == [client_mod.CORE_LOG_FILTER]
+
+
+async def test_the_client_runtime_uses_the_filter(monkeypatch):
+ built = _record_runtimes(monkeypatch, client_mod)
+ fake_client_class = MagicMock()
+ fake_client_class.connect = AsyncMock(side_effect=RuntimeError("no server"))
+ monkeypatch.setattr(client_mod, "Client", fake_client_class)
+
+ wrapper = client_mod.TemporalClientWrapper("localhost:5681", "default")
+ assert await wrapper.connect(retries=1, delay=0) is None
+ assert built == [client_mod.CORE_LOG_FILTER]