Skip to content

feat(governance): stamp trace_id on governance customEvents - #162

Open
aditik0303 wants to merge 1 commit into
mainfrom
feat/govern-customevent-trace-id
Open

feat(governance): stamp trace_id on governance customEvents#162
aditik0303 wants to merge 1 commit into
mainfrom
feat/govern-customevent-trace-id

Conversation

@aditik0303

@aditik0303 aditik0303 commented Aug 19, 2026

Copy link
Copy Markdown
Contributor

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 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 (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

Copilot AI lite review requested due to automatic review settings August 19, 2026 16:52
@aditik0303
aditik0303 requested review from a team and cristipufu as code owners August 19, 2026 16:52

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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_id into 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>
@aditik0303
aditik0303 force-pushed the feat/govern-customevent-trace-id branch from 68fafc9 to cd11a25 Compare August 19, 2026 17:15
@sonarqubecloud

Copy link
Copy Markdown

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants