diff --git a/CHANGELOG.md b/CHANGELOG.md index 1482fd93..e229a75c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -16,6 +16,9 @@ protobuf policies remain supported. See [ID reuse](docs/features.md#orchestratio FIXED +- Python SDK spans now use the `Microsoft.DurableTask` OpenTelemetry instrumentation +scope. Update queries, dashboards, and collector filters that use the previous +`durabletask` scope. - Activity and sub-orchestration `retry_timeout` decisions now use replay-safe orchestration time, preventing retries from expiring solely because history is replayed later. Retry calculations also accept timezone-aware timestamps. diff --git a/durabletask-azuremanaged/CHANGELOG.md b/durabletask-azuremanaged/CHANGELOG.md index 15dbdea2..75bf9caf 100644 --- a/durabletask-azuremanaged/CHANGELOG.md +++ b/durabletask-azuremanaged/CHANGELOG.md @@ -16,6 +16,9 @@ Core release and dependency minimum updates are coordinated in the dedicated rel FIXED +- With the corresponding core `durabletask` SDK update, Azure Managed spans use +the `Microsoft.DurableTask` OpenTelemetry instrumentation scope. Update queries, +dashboards, and collector filters that match the previous `durabletask` scope. - With the corresponding core SDK update, activity and sub-orchestration `retry_timeout` decisions use replay-safe orchestration time rather than wall-clock time. See the [core upgrade guidance](../CHANGELOG.md#unreleased) diff --git a/durabletask/internal/tracing.py b/durabletask/internal/tracing.py index 8420dc78..c86d53dd 100644 --- a/durabletask/internal/tracing.py +++ b/durabletask/internal/tracing.py @@ -85,7 +85,7 @@ class _StatusCodeStub: OTEL_AVAILABLE = _OTEL_AVAILABLE # The instrumentation scope name used when creating spans. -_TRACER_NAME = "durabletask" +_TRACER_NAME = "Microsoft.DurableTask" _SPAN_EMISSION_SUPPRESSED: ContextVar[bool] = ContextVar( "durabletask_span_emission_suppressed", default=False, diff --git a/tests/azure-functions-durable/e2e/_harness.py b/tests/azure-functions-durable/e2e/_harness.py index a19c5c7b..394de339 100644 --- a/tests/azure-functions-durable/e2e/_harness.py +++ b/tests/azure-functions-durable/e2e/_harness.py @@ -195,10 +195,11 @@ def get_spans(self) -> list[dict[str, Any]]: continue payload = json.loads(line) for resource_spans in payload.get("resourceSpans", []): + resource = resource_spans.get("resource", {}) for scope_spans in resource_spans.get("scopeSpans", []): scope_name = scope_spans.get("scope", {}).get("name", "") for span in scope_spans.get("spans", []): - spans.append({**span, "scopeName": scope_name}) + spans.append({**span, "scopeName": scope_name, "resource": resource}) return spans def get_logs(self) -> str: diff --git a/tests/azure-functions-durable/e2e/test_distributed_tracing_e2e.py b/tests/azure-functions-durable/e2e/test_distributed_tracing_e2e.py index 4787a709..4322fb72 100644 --- a/tests/azure-functions-durable/e2e/test_distributed_tracing_e2e.py +++ b/tests/azure-functions-durable/e2e/test_distributed_tracing_e2e.py @@ -61,6 +61,7 @@ def test_user_span_correlates_to_host_without_worker_lifecycle_duplicates( ( span.get("name"), span.get("scopeName"), + _attribute_value(span["resource"], "service.name"), span.get("traceId"), span.get("spanId"), span.get("parentSpanId"), @@ -70,12 +71,16 @@ def test_user_span_correlates_to_host_without_worker_lifecycle_duplicates( assert len(starter_spans) == 1, summary assert starter_spans[0].get("traceId") == user_span.get("traceId"), summary assert len(parent_spans) == 1, summary - assert parent_spans[0].get("scopeName") != "durabletask" + worker_service = _attribute_value(user_span["resource"], "service.name") + assert worker_service == "durable-functions-python-worker", summary + parent_service = _attribute_value(parent_spans[0]["resource"], "service.name") + assert parent_service != worker_service, summary assert parent_spans[0].get("spanId") != starter_spans[0].get("spanId"), summary python_lifecycle_spans = [ span for span in spans if span.get("traceId") == user_span.get("traceId") - if span.get("scopeName") == "durabletask" + if span.get("scopeName") == "Microsoft.DurableTask" + if _attribute_value(span["resource"], "service.name") == worker_service ] - assert python_lifecycle_spans == [] + assert python_lifecycle_spans == [], summary diff --git a/tests/durabletask/test_tracing.py b/tests/durabletask/test_tracing.py index 5c75e25a..d6bac267 100644 --- a/tests/durabletask/test_tracing.py +++ b/tests/durabletask/test_tracing.py @@ -147,6 +147,8 @@ def test_creates_span_without_parent(self, otel_setup: InMemorySpanExporter): spans = otel_setup.get_finished_spans() assert len(spans) == 1 assert spans[0].name == "test-span" + assert spans[0].instrumentation_scope is not None + assert spans[0].instrumentation_scope.name == "Microsoft.DurableTask" def test_creates_span_with_attributes(self, otel_setup: InMemorySpanExporter): """Should create a span with custom attributes.""" @@ -1719,6 +1721,8 @@ def test_emits_span_with_correct_attributes(self, otel_setup: InMemorySpanExport s = spans[0] assert s.name == "activity:SayHello" assert s.kind == trace.SpanKind.CLIENT + assert s.instrumentation_scope is not None + assert s.instrumentation_scope.name == "Microsoft.DurableTask" assert s.attributes is not None assert s.attributes[tracing.ATTR_TASK_TYPE] == "activity" assert s.attributes[tracing.ATTR_TASK_NAME] == "SayHello"