feat: add GraphEngine layer node execution hooks
[!IMPORTANT]
- Make sure you have read our contribution guidelines
- Ensure there is an associated issue and you have been assigned to it
- Use the correct syntax to link this PR:
Fixes #<issue number>.
Summary
part of https://github.com/langgenius/dify/issues/28446
Extend the graph layer to inject OTel context
Screenshots
Checklist
- [ ] This change requires a documentation update, included: Dify Document
- [x] I understand that this PR may be closed in case there was no previous discussion or issues. (This doesn't apply to typos!)
- [x] 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.
- [x] I ran
dev/reformat(backend) andcd web && npx lint-staged(frontend) to appease the lint gods
python style check failed, you can
class Node:
@property
def execution_id(self) -> str:
return self._node_execution_id
def ensure_execution_id(self) -> str:
if not self._node_execution_id:
self._node_execution_id = str(uuid4())
return self._node_execution_id
add unittest:
Hook/event order: on_node_run_start -> NodeRunStartedEvent -> … -> NodeRunSucceeded/Failed -> on_node_run_end.
hi @fatelei This PR is ready for review, fixed Python style issues and adds unit tests for the Observability layer.
the "hook/event order" you mentioned: events appear to be handled asynchronously.But hooks are executed synchronously in the sequence on_node_run_start → node_execute → on_node_run_end. I believe this ordering is sufficient for the Observability layer.
hi @fatelei This PR is ready for review, fixed Python style issues and adds unit tests for the Observability layer.
the "hook/event order" you mentioned: events appear to be handled asynchronously.But hooks are executed synchronously in the sequence on_node_run_start → node_execute → on_node_run_end. I believe this ordering is sufficient for the Observability layer.
ok
git commit squash