Skip to content

fix: fallback phoenix parent trace when parent tracing disabled#36290

Merged
Blackoutta merged 5 commits into
langgenius:mainfrom
Blackoutta:bugfix/phoenix-carrier-fix-for-1.14.x
May 18, 2026
Merged

fix: fallback phoenix parent trace when parent tracing disabled#36290
Blackoutta merged 5 commits into
langgenius:mainfrom
Blackoutta:bugfix/phoenix-carrier-fix-for-1.14.x

Conversation

@Blackoutta
Copy link
Copy Markdown
Contributor

@Blackoutta Blackoutta commented May 18, 2026

Important

  1. Make sure you have read our contribution guidelines
  2. Ensure there is an associated issue and you have been assigned to it
  3. Use the correct syntax to link this PR: Fixes #<issue number>.

Summary

Fixes #36289

This PR ports the Phoenix parent trace fallback behavior described in the source-branch spec docs/superpowers/specs/2026-05-16-phoenix-parent-trace-fallback-design.md from commit f224813e63d33f582a79f5c76e573738620f28b0 into the current trace provider package layout.

Nested workflow traces can include a parent_trace_context so Phoenix/Arize can attach the child workflow under the parent workflow's tool node span. When the parent workflow has Phoenix/Arize tracing disabled, that parent span carrier can never be published to Redis. The current provider treats the missing carrier as pending and retries until the retry budget is exhausted.

The change keeps normal parent-carrier behavior for traceable parents, but falls back to a synthetic root keyed by parent_workflow_run_id when the parent app cannot publish Phoenix/Arize carrier data. Missing carriers remain retryable when the parent app can publish context, unknown parent workflow runs remain retryable, and malformed Redis carriers still fail as hard errors.

It also starts Phoenix synthetic root spans with an empty OpenTelemetry Context() so an ambient unsampled parent span cannot suppress or parent the synthetic root.

Screenshots

Before After
N/A N/A

Checklist

  • This change requires a documentation update, included: Dify Document
  • I understand that this PR may be closed in case there was no previous discussion or issues. (This doesn't apply to typos!)
  • I've added a test for each change that was introduced, and I tried as much as possible to make a single atomic change.
  • I've updated the documentation accordingly.
  • I ran make lint && make type-check (backend) and cd web && pnpm exec vp staged (frontend) to appease the lint gods

Validation run:

uv run --project api pytest api/providers/trace/trace-arize-phoenix/tests/unit_tests/arize_phoenix_trace/test_arize_phoenix_trace.py -q
uv run --project api pytest api/tests/unit_tests/tasks/test_ops_trace_task.py -q
uv run --project api ruff format --check api/providers/trace/trace-arize-phoenix/src/dify_trace_arize_phoenix/arize_phoenix_trace.py api/providers/trace/trace-arize-phoenix/tests/unit_tests/arize_phoenix_trace/test_arize_phoenix_trace.py
uv run --project api ruff check api/providers/trace/trace-arize-phoenix/src/dify_trace_arize_phoenix/arize_phoenix_trace.py api/providers/trace/trace-arize-phoenix/tests/unit_tests/arize_phoenix_trace/test_arize_phoenix_trace.py

@Blackoutta Blackoutta requested a review from QuantumGhost as a code owner May 18, 2026 03:26
@dosubot dosubot Bot added the size:M This PR changes 30-99 lines, ignoring generated files. label May 18, 2026
@Blackoutta Blackoutta enabled auto-merge May 18, 2026 03:27
@github-actions
Copy link
Copy Markdown
Contributor

Pyrefly Diff

base → PR
--- /tmp/pyrefly_base.txt	2026-05-18 03:27:52.286187295 +0000
+++ /tmp/pyrefly_pr.txt	2026-05-18 03:27:44.229106557 +0000
@@ -72,6 +72,10 @@
   --> extensions/storage/huawei_obs_storage.py:31:20
 ERROR Argument `Module[Crypto.Hash.SHA1] | Unknown` is not assignable to parameter with type `Hash | HashModule` [bad-argument-type]
   --> libs/gmpy2_pkcs10aep_cipher.py:73:49
+ERROR `opentelemetry.trace.Tracer` is not assignable to attribute `tracer` with type `opentelemetry.sdk.trace.Tracer` [bad-assignment]
+    --> providers/trace/trace-arize-phoenix/tests/unit_tests/arize_phoenix_trace/test_arize_phoenix_trace.py:1722:29
+ERROR Object of class `NoneType` has no attribute `trace_id` [missing-attribute]
+    --> providers/trace/trace-arize-phoenix/tests/unit_tests/arize_phoenix_trace/test_arize_phoenix_trace.py:1744:12
 ERROR Argument `SimpleNamespace` is not assignable to parameter `dataset` with type `Dataset` in function `dify_vdb_alibabacloud_mysql.alibabacloud_mysql_vector.AlibabaCloudMySQLVectorFactory.init_vector` [bad-argument-type]
   --> providers/vdb/vdb-alibabacloud-mysql/tests/unit_tests/test_alibabacloud_mysql_factory.py:42:38
 ERROR Argument `SimpleNamespace` is not assignable to parameter `dataset` with type `Dataset` in function `dify_vdb_alibabacloud_mysql.alibabacloud_mysql_vector.AlibabaCloudMySQLVectorFactory.init_vector` [bad-argument-type]

@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented May 18, 2026

Pyrefly Type Coverage

Metric Base PR Delta
Type coverage 0.00% 43.70% +43.70%
Strict coverage 0.00% 43.22% +43.22%
Typed symbols 0 22,156 +22,156
Untyped symbols 0 28,859 +28,859
Modules 0 2558 +2,558

@Blackoutta Blackoutta force-pushed the bugfix/phoenix-carrier-fix-for-1.14.x branch from dcc2126 to f45a58a Compare May 18, 2026 08:14
@github-actions github-actions Bot added the web This relates to changes on the web. label May 18, 2026
@Blackoutta Blackoutta added this pull request to the merge queue May 18, 2026
@dosubot dosubot Bot added the lgtm This PR has been approved by a maintainer label May 18, 2026
Merged via the queue into langgenius:main with commit f4c02e4 May 18, 2026
32 checks passed
@Blackoutta Blackoutta deleted the bugfix/phoenix-carrier-fix-for-1.14.x branch May 18, 2026 09:10
zhangtaodemama added a commit to zhangtaodemama/langgenius-dify-bfaadcb0c706 that referenced this pull request May 18, 2026
@Blackoutta Blackoutta restored the bugfix/phoenix-carrier-fix-for-1.14.x branch May 19, 2026 08:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

lgtm This PR has been approved by a maintainer size:M This PR changes 30-99 lines, ignoring generated files. web This relates to changes on the web.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Phoenix tracing retries when parent workflow tracing is disabled

2 participants