Skip to content

feat: align governance trace spans with OTEL contract#155

Merged
viswa-uipath merged 1 commit into
mainfrom
feat/governance-trace-source-spantype
Jul 21, 2026
Merged

feat: align governance trace spans with OTEL contract#155
viswa-uipath merged 1 commit into
mainfrom
feat/governance-trace-source-spantype

Conversation

@viswa-uipath

@viswa-uipath viswa-uipath commented Jul 20, 2026

Copy link
Copy Markdown
Contributor

Summary

Aligns the governance OpenTelemetry trace spans (TracesAuditSink) with the BYO OpenTelemetry contract that end users consume.

Previously, governance spans:

  • were tagged type / span_type = "agentRun", so they impersonated agent-run spans while carrying none of the agentRun attribute shape (no agentId, prompts, schemas, input/output). Any BYO consumer grouping/filtering by span_type == "agentRun" saw polluted data.
  • never set uipath.source, so the platform-side exporter defaulted the root Source field to CodedAgents — a mislabel for governance spans.

Changes

  • Root Source field — set uipath.source = "Governance" on rule spans. The platform exporter (_span_utils.otel_span_to_uipath_span) maps this to SpanSource.GOVERNANCE instead of the CodedAgents default. Value is a constant (UIPATH_SOURCE), not hardcoded at the call site.
  • Span type — changed type / span_type from "agentRun" to a dedicated "governance" value (SPAN_TYPE_GOVERNANCE) so governance spans no longer masquerade as agent runs.
  • Hook-summary span removedTracesAuditSink no longer emits a span for HOOK_END events (the span that carried only the hook name + summary). HOOK_END is still emitted by the evaluator and still consumed by the track_events sink; only the traces sink stops reacting to it.

Tests

  • test_traces_severity.py updated: replaced the (now-vacuous) hook-span severity test with test_hook_end_emits_no_span, fixed the spans_created counter test, and refreshed docstrings.
  • Full suite: 379 passed, 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

  • Add this package as a dependency in your pyproject.toml:
[project]
dependencies = [
  # Exact version:
  "uipath-runtime==0.12.5.dev1001550671",

  # Any version from PR
  "uipath-runtime>=0.12.5.dev1001550000,<0.12.5.dev1001560000"
]

[[tool.uv.index]]
name = "testpypi"
url = "https://test.pypi.org/simple/"
publish-url = "https://test.pypi.org/legacy/"
explicit = true

[tool.uv.sources]
uipath-runtime = { index = "testpypi" }

Copilot AI review requested due to automatic review settings July 20, 2026 15:53
@viswa-uipath
viswa-uipath requested a review from a team as a code owner July 20, 2026 15:53

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

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 stamp uipath.source = "Governance" on governance rule spans.
  • Update trace-severity tests to reflect HOOK_END being dropped and to adjust spans_created expectations.

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.

Comment thread tests/test_traces_severity.py
Comment thread tests/test_traces_severity.py
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
viswa-uipath force-pushed the feat/governance-trace-source-spantype branch from 15eb102 to fff0bc6 Compare July 20, 2026 16:59
@sonarqubecloud

Copy link
Copy Markdown

@viswa-uipath
viswa-uipath merged commit 47510eb into main Jul 21, 2026
95 checks passed
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.

3 participants