feat: align governance trace spans with OTEL contract#155
Merged
Conversation
There was a problem hiding this comment.
Pull request overview
Aligns the governance OpenTelemetry span emission (TracesAuditSink) with the BYO OTel contract by ensuring governance telemetry no longer looks like agent-run spans and by correctly stamping the uipath.source attribute. This keeps downstream BYO consumers from mis-grouping governance spans and avoids mislabeling the platform “Source” field.
Changes:
- Stop emitting HOOK_END “hook-summary” spans; only emit spans for RULE_EVALUATION events.
- Change span classification from
"agentRun"to"governance"and stampuipath.source = "Governance"on governance rule spans. - Update trace-severity tests to reflect HOOK_END being dropped and to adjust
spans_createdexpectations.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
src/uipath/runtime/governance/_audit/traces.py |
Updates governance span typing/source attributes and drops HOOK_END span emission. |
tests/test_traces_severity.py |
Updates tests to reflect HOOK_END span removal and adjusts span counter assertions. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Governance spans previously identified as agentRun spans (type/span_type) and defaulted the root Source to CodedAgents, which broke the BYO OpenTelemetry contract: consumers grouping by span_type=agentRun saw governance spans that carry none of the agentRun attribute shape. - Set uipath.source="Governance" so the platform exporter maps the root Source field to SpanSource.GOVERNANCE instead of CodedAgents. - Change type/span_type from "agentRun" to a dedicated "governance" value so governance spans no longer impersonate agent-run spans. - Remove the hook-summary span from TracesAuditSink; HOOK_END is now dropped by this sink (still emitted and consumed by track_events). - Add tests for the dropped HOOK_END span and the new span-type/source contract (asserts the tracer is never asked to start a HOOK_END span and that rule spans carry governance type/source). - Bump uipath-runtime version to 0.12.5. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
viswa-uipath
force-pushed
the
feat/governance-trace-source-spantype
branch
from
July 20, 2026 16:59
15eb102 to
fff0bc6
Compare
|
cristipufu
approved these changes
Jul 20, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.



Summary
Aligns the governance OpenTelemetry trace spans (
TracesAuditSink) with the BYO OpenTelemetry contract that end users consume.Previously, governance spans:
type/span_type = "agentRun", so they impersonated agent-run spans while carrying none of theagentRunattribute shape (noagentId, prompts, schemas, input/output). Any BYO consumer grouping/filtering byspan_type == "agentRun"saw polluted data.uipath.source, so the platform-side exporter defaulted the rootSourcefield toCodedAgents— a mislabel for governance spans.Changes
Sourcefield — setuipath.source = "Governance"on rule spans. The platform exporter (_span_utils.otel_span_to_uipath_span) maps this toSpanSource.GOVERNANCEinstead of theCodedAgentsdefault. Value is a constant (UIPATH_SOURCE), not hardcoded at the call site.type/span_typefrom"agentRun"to a dedicated"governance"value (SPAN_TYPE_GOVERNANCE) so governance spans no longer masquerade as agent runs.TracesAuditSinkno longer emits a span forHOOK_ENDevents (the span that carried only the hook name + summary).HOOK_ENDis still emitted by the evaluator and still consumed by thetrack_eventssink; only the traces sink stops reacting to it.Tests
test_traces_severity.pyupdated: replaced the (now-vacuous) hook-span severity test withtest_hook_end_emits_no_span, fixed thespans_createdcounter test, and refreshed docstrings.ruff check .clean.Note for reviewers
The
"governance"span-type string is a proposal. If the trace UI / backend expects governance to render under an existing lane (e.g.toolGuardrailEvaluation), the constant is the single place to change it. Worth a quick confirm with the platform/observability team on the canonical value.🤖 Generated with Claude Code
Development Package