feat(governance): stamp trace_id on governance customEvents - #162
feat(governance): stamp trace_id on governance customEvents#162aditik0303 wants to merge 1 commit into
Conversation
There was a problem hiding this comment.
Pull request overview
This PR adds a trace_id field to governance TrackEvent custom event payloads so downstream systems can correlate governance.rule.denied and governance.hook.summary events with the same trace identifier used by LLMOps span storage. The trace id is resolved synchronously on the hook/caller thread (preferring UIPATH_TRACE_ID, falling back to the current OTel span) and formatted as a dashed GUID.
Changes:
- Add
_resolve_trace_id()to resolve and validate a 32-hex trace id and format it as a dashed GUID. - Stamp
trace_idinto the shared governance TrackEvent payload when available (omitted when unavailable). - Add tests covering env-preferred trace id, OTel-span fallback, and omission behavior.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
src/uipath/runtime/governance/_audit/track_events.py |
Resolves and stamps trace_id into the common payload for governance TrackEvent custom events. |
tests/test_track_events_sink.py |
Adds test coverage validating trace_id selection, formatting, and omission semantics. |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
Resolve the run's trace id (UIPATH_TRACE_ID, else the live OTel span) as a dashed GUID on the hook thread and stamp it on governance.rule.denied and governance.hook.summary, so each event carries the id its LLMOps spans are stored under. Resolved synchronously before the background telemetry dispatch so it survives the trace-context header being dropped on that thread. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
68fafc9 to
cd11a25
Compare
|



Resolves the run's trace id (
UIPATH_TRACE_ID, else the live OTel span) as a dashed GUID on the hook thread and stamps it ongovernance.rule.deniedandgovernance.hook.summary, so each event carries the id its LLMOps spans are stored under.Resolved synchronously before the background telemetry dispatch, so it survives the trace-context header being dropped on that thread (which is why it must live in the event body, not a header).Pairs with uipath-governance-server #154, which stamps the same id on the compensating govern events.
🤖 Generated with Claude Code