Skip to content

Commit b0dfaef

Browse files
authored
Evolve observability documentation (#797)
1 parent 49ca10e commit b0dfaef

File tree

4 files changed

+49
-11
lines changed

4 files changed

+49
-11
lines changed

Diff for: .github/workflows/ci.yml

+1-2
Original file line numberDiff line numberDiff line change
@@ -109,9 +109,8 @@ jobs:
109109
110110
# Runs the sdk features repo tests with this repo's current SDK code
111111
features-tests:
112-
uses: temporalio/features/.github/workflows/python.yaml@uv
112+
uses: temporalio/features/.github/workflows/python.yaml@main
113113
with:
114114
python-repo-path: ${{github.event.pull_request.head.repo.full_name}}
115115
version: ${{github.event.pull_request.head.ref}}
116116
version-is-repo-ref: true
117-
features-repo-ref: uv

Diff for: README.md

+26-4
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,9 @@ informal introduction to the features and their implementation.
9797
- [Worker Shutdown](#worker-shutdown)
9898
- [Testing](#testing-1)
9999
- [Workflow Replay](#workflow-replay)
100-
- [OpenTelemetry Support](#opentelemetry-support)
100+
- [Observability](#observability)
101+
- [Metrics](#metrics)
102+
- [OpenTelemetry Tracing](#opentelemetry-tracing)
101103
- [Protobuf 3.x vs 4.x](#protobuf-3x-vs-4x)
102104
- [Known Compatibility Issues](#known-compatibility-issues)
103105
- [gevent Patching](#gevent-patching)
@@ -1344,10 +1346,30 @@ async def check_past_histories(my_client: Client):
13441346
)
13451347
```
13461348

1347-
### OpenTelemetry Support
1349+
### Observability
13481350

1349-
OpenTelemetry support requires the optional `opentelemetry` dependencies which are part of the `opentelemetry` extra.
1350-
When using `pip`, running
1351+
See https://github.com/temporalio/samples-python/tree/main/open_telemetry for a sample demonstrating collection of
1352+
metrics and tracing data emitted by the SDK.
1353+
1354+
#### Metrics
1355+
1356+
The SDK emits various metrics by default: see https://docs.temporal.io/references/sdk-metrics. To configure additional
1357+
attributes to be emitted with all metrics, pass
1358+
[global_tags](https://python.temporal.io/temporalio.runtime.TelemetryConfig.html#global_tags) when creating the
1359+
[TelemetryConfig](https://python.temporal.io/temporalio.runtime.TelemetryConfig.html).
1360+
1361+
For emitting custom metrics, the SDK makes a metric meter available:
1362+
- In Workflow code, use https://python.temporal.io/temporalio.workflow.html#metric_meter
1363+
- In Activity code, use https://python.temporal.io/temporalio.activity.html#metric_meter
1364+
- In normal application code, use https://python.temporal.io/temporalio.runtime.Runtime.html#metric_meter
1365+
1366+
The attributes emitted by these default to `namespace`, `task_queue`, and `workflow_type`/`activity_type`; use
1367+
`with_additional_attributes` to create a meter emitting additional attributes.
1368+
1369+
#### OpenTelemetry Tracing
1370+
1371+
Tracing support requires the optional `opentelemetry` dependencies which are part of the `opentelemetry` extra. When
1372+
using `pip`, running
13511373

13521374
pip install 'temporalio[opentelemetry]'
13531375

Diff for: tests/worker/test_activity.py

+21-4
Original file line numberDiff line numberDiff line change
@@ -611,7 +611,12 @@ async def some_activity(param1: SomeClass2, param2: str) -> str:
611611
assert activity_param1 == SomeClass2(foo="str1", bar=SomeClass1(foo=123))
612612

613613

614-
async def test_activity_heartbeat_details(client: Client, worker: ExternalWorker):
614+
async def test_activity_heartbeat_details(
615+
client: Client, worker: ExternalWorker, env: WorkflowEnvironment
616+
):
617+
if env.supports_time_skipping:
618+
pytest.skip("https://github.com/temporalio/sdk-java/issues/2459")
619+
615620
@activity.defn
616621
async def some_activity() -> str:
617622
info = activity.info()
@@ -698,8 +703,11 @@ def picklable_heartbeat_details_activity() -> str:
698703

699704

700705
async def test_sync_activity_thread_heartbeat_details(
701-
client: Client, worker: ExternalWorker
706+
client: Client, worker: ExternalWorker, env: WorkflowEnvironment
702707
):
708+
if env.supports_time_skipping:
709+
pytest.skip("https://github.com/temporalio/sdk-java/issues/2459")
710+
703711
with concurrent.futures.ThreadPoolExecutor(
704712
max_workers=default_max_concurrent_activities
705713
) as executor:
@@ -714,8 +722,11 @@ async def test_sync_activity_thread_heartbeat_details(
714722

715723

716724
async def test_sync_activity_process_heartbeat_details(
717-
client: Client, worker: ExternalWorker
725+
client: Client, worker: ExternalWorker, env: WorkflowEnvironment
718726
):
727+
if env.supports_time_skipping:
728+
pytest.skip("https://github.com/temporalio/sdk-java/issues/2459")
729+
719730
with concurrent.futures.ProcessPoolExecutor() as executor:
720731
result = await _execute_workflow_with_activity(
721732
client,
@@ -1066,8 +1077,14 @@ async def test_activity_async_success(
10661077

10671078
@pytest.mark.parametrize("use_task_token", [True, False])
10681079
async def test_activity_async_heartbeat_and_fail(
1069-
client: Client, worker: ExternalWorker, use_task_token: bool
1080+
client: Client,
1081+
worker: ExternalWorker,
1082+
env: WorkflowEnvironment,
1083+
use_task_token: bool,
10701084
):
1085+
if env.supports_time_skipping:
1086+
pytest.skip("https://github.com/temporalio/sdk-java/issues/2459")
1087+
10711088
wrapper = AsyncActivityWrapper()
10721089
# Start task w/ max attempts 2, wait for info, send heartbeat, fail
10731090
task = asyncio.create_task(

Diff for: tests/worker/test_workflow.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -222,7 +222,7 @@ async def test_workflow_info(client: Client, env: WorkflowEnvironment):
222222
assert info["retry_policy"] == json.loads(
223223
json.dumps(dataclasses.asdict(retry_policy), default=str)
224224
)
225-
assert uuid.UUID(info["run_id"]).version == 4
225+
assert uuid.UUID(info["run_id"]).version == 7
226226
assert info["run_timeout"] is None
227227
datetime.fromisoformat(info["start_time"])
228228
assert info["task_queue"] == worker.task_queue

0 commit comments

Comments
 (0)