[PR #22547] fix: correct tracing for workflows and chatflows for phoenix #29962

Closed
opened 2026-02-21 20:46:35 -05:00 by yindo · 0 comments
Owner

Original Pull Request: https://github.com/langgenius/dify/pull/22547

State: closed
Merged: Yes


Summary

This PR fixes the issue where workflows and chatflows cannot be traced by Phoenix.
This PR makes the following changes (see the corresponding commits for details):

  • Remove the guard logic from the workflow_trace method
    • In my environment, message_data is always None, which causes the method to return immediately.
    • By removing the guard logic (as done in Langfuse), workflows and chatflows can now be traced.
  • Use workflow_run_id as trace_id instead of message_id
    • message_id is empty for workflows, so using it as trace_id causes missing IDs for workflow traces.
    • By using workflow_run_id as trace_id (as in Langfuse traces), trace_id is always unique.
  • Use consistent context for each node execution
    • In the current implementation, node executions are traced without context. This causes each execution not to be grouped into a single span, losing relationships.
    • By adding the correct context for each node execution, a single span now contains all traces for each node execution.
  • Support input attributes for LLM node execution
    • The current implementation does not trace any prompts for LLM nodes.
    • Attributes for LLM nodes have been fixed, and prompts are now traced.

Closes #22504

Screenshots

Before After
image
imageimage

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 dev/reformat(backend) and cd web && npx lint-staged(frontend) to appease the lint gods
**Original Pull Request:** https://github.com/langgenius/dify/pull/22547 **State:** closed **Merged:** Yes --- ## Summary This PR fixes the issue where workflows and chatflows cannot be traced by Phoenix. This PR makes the following changes (see the corresponding commits for details): - Remove the guard logic from the `workflow_trace` method - In my environment, `message_data` is always None, which causes the method to return immediately. - By removing the guard logic (as done in Langfuse), workflows and chatflows can now be traced. - Use `workflow_run_id` as `trace_id` instead of `message_id` - `message_id` is empty for workflows, so using it as `trace_id` causes missing IDs for workflow traces. - By using `workflow_run_id` as `trace_id` (as in Langfuse traces), `trace_id` is always unique. - Use consistent context for each node execution - In the current implementation, node executions are traced without context. This causes each execution not to be grouped into a single span, losing relationships. - By adding the correct context for each node execution, a single span now contains all traces for each node execution. - Support input attributes for LLM node execution - The current implementation does not trace any prompts for LLM nodes. - Attributes for LLM nodes have been fixed, and prompts are now traced. Closes #22504 ## Screenshots | Before | After | |--------|-------| | ![](https://github.com/user-attachments/assets/fa42516c-4d10-4707-b6c2-e666bbdc3c07) | <img width="1175" height="1297" alt="image" src="https://github.com/user-attachments/assets/6baeca9a-43ca-4e66-971c-59164a1e238f" /><br><img width="1362" height="890" alt="image" src="https://github.com/user-attachments/assets/4982f836-8f90-4876-b4f0-8487c838ded9" /><img width="1411" height="645" alt="image" src="https://github.com/user-attachments/assets/e587609b-7d49-469a-a535-f7bdb7ed97fe" /> | ## Checklist - [ ] This change requires a documentation update, included: [Dify Document](https://github.com/langgenius/dify-docs) - [x] 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. - [x] I've updated the documentation accordingly. - [ ] I ran `dev/reformat`(backend) and `cd web && npx lint-staged`(frontend) to appease the lint gods
yindo added the pull-request label 2026-02-21 20:46:35 -05:00
yindo closed this issue 2026-02-21 20:46:35 -05:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: langgenius/dify#29962