Skip to content

feat(datafabric): add OTEL span instrumentation for SQL query execution#964

Closed
UIPath-Harshit wants to merge 1 commit into
mainfrom
feat/datafabric-telemetry-spans
Closed

feat(datafabric): add OTEL span instrumentation for SQL query execution#964
UIPath-Harshit wants to merge 1 commit into
mainfrom
feat/datafabric-telemetry-spans

Conversation

@UIPath-Harshit

Copy link
Copy Markdown
Contributor

Summary

  • Wraps QueryExecutor.__call__ in a dedicated OTEL span ("Data Fabric SQL query") with structured attributes:
    • df.sql_query — the executed SQL
    • df.success, df.record_count — on success
    • df.error.code, df.error.category, df.error.message, df.error.trace_id — on error (parsed from DF server response via DataFabricError)
    • df.entity_count, df.native_entity_count, df.federated_entity_count, df.native_entities, df.federated_entities — entity type classification based on external_fields presence
  • Builds structured error messages for the inner LLM with error code and actionable hint (e.g. "Fix the SQL syntax and retry")
  • Gracefully degrades when DataFabricError is not available (older uipath-platform without the companion PR)

Motivation: DF query errors (400s and 500s) were previously swallowed by QueryExecutor with no span attributes — invisible in App Insights. This adds the telemetry needed to diagnose SQL generation failures and track native vs federated usage.

Companion PR: UiPath/uipath-python — adds DataFabricError classification consumed here.

Test plan

  • Verify import succeeds with and without DataFabricError in uipath-platform
  • Verify span attributes are emitted on success and error paths
  • Verify native/federated entity classification based on external_fields
  • Existing datafabric tests pass (uv run pytest -k "datafabric")

🤖 Generated with Claude Code

@UIPath-Harshit UIPath-Harshit marked this pull request as ready for review July 2, 2026 13:21
Copilot AI review requested due to automatic review settings July 2, 2026 13:21

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 OpenTelemetry span instrumentation around Data Fabric SQL execution to make query successes/failures observable (including structured error classification), and expands the Data Fabric subgraph state to surface the last error category/detail in termination messaging.

Changes:

  • Instrument QueryExecutor.__call__ with a dedicated OTEL span and structured attributes for success/error cases (with optional DataFabricError enrichment).
  • Track and propagate the last tool error category/detail through the subgraph state and termination message.
  • Add a comprehensive test suite for the Data Fabric subgraph behavior (routing/tool execution/OTEL paths) and relax the uipath dependency upper bound.

Reviewed changes

Copilot reviewed 3 out of 4 changed files in this pull request and generated 2 comments.

File Description
tests/agent/tools/test_datafabric_subgraph.py Adds tests covering QueryExecutor telemetry/error formatting and subgraph routing/tool/termination behavior.
src/uipath_langchain/agent/tools/datafabric_tool/datafabric_subgraph.py Adds OTEL span instrumentation for DF SQL execution; enriches error handling and propagates last error metadata through the graph.
pyproject.toml Relaxes the uipath dependency upper bound to allow newer versions.

Comment thread pyproject.toml
…ion for SQL queries

- Add OpenTelemetry span around Data Fabric SQL query execution with
  entity metadata, success/error attributes, and structured error codes
- Integrate DataFabricError classification from uipath-platform for
  richer error diagnostics (category, code, trace_id) on spans
- Propagate error category and detail to parent graph state for
  termination messaging
- Bump uipath upper bound to <2.13.0 and uipath-platform to 0.1.90
- Add comprehensive unit tests for datafabric_subgraph (98% coverage)

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@UIPath-Harshit UIPath-Harshit force-pushed the feat/datafabric-telemetry-spans branch from b53da63 to 7a1ba13 Compare July 2, 2026 13:38
@sonarqubecloud

sonarqubecloud Bot commented Jul 2, 2026

Copy link
Copy Markdown

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants