o11y(assisted-query): Track error outcomes and reasons for AI query analytics#115699
Open
aliu39 wants to merge 3 commits into
Open
o11y(assisted-query): Track error outcomes and reasons for AI query analytics#115699aliu39 wants to merge 3 commits into
aliu39 wants to merge 3 commits into
Conversation
Extend trackAiQueryOutcome to emit an `error_on_load` outcome (with an optional error_reason attribute) when a table result fails to load. Previously, errored queries were silently bucketed as `empty_results`, which conflated empty data with failures. Wire up the new `error` param from spans, logs, and metrics analytics hooks using the existing tableError values, boxed to avoid extra effect re-fires. Co-Authored-By: Claude <noreply@anthropic.com>
Extend trackAiQueryOutcome's `error` param to accept `Error` (in
addition to `string | boolean`). The util now centralizes reason
extraction: for `RequestError` it pulls `responseJSON.detail`
(handling both string and `{message}` shapes), otherwise it falls
back to `err.message`.
Wire this through in two places:
- Discover errors: add a second trackAiQueryOutcome call in
fetchTotalCount's catch block so failed total-count requests
emit an error_on_load outcome with the API reason.
- Explore (spans, traces, logs, metrics): pass the raw `Error`
object from the table result through useBox to the outcome
call instead of pre-extracting `error?.message`.
Co-Authored-By: Claude <noreply@anthropic.com>
Contributor
📊 Type Coverage Diff✅ No new type safety issues introduced. Coverage: 93.53% |
Contributor
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes and found 1 potential issue.
❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.
Reviewed by Cursor Bugbot for commit ea54c73. Configure here.
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
Extends
trackAiQueryOutcometo emit a newerror_on_loadoutcome (alongside the existinghas_results/empty_results) and capture anerror_reasonattribute when an AI-assisted query's table load fails. Previously, errored queries were silently bucketed asempty_results, conflating empty data with failures.trackAiQueryOutcomeutilerrorparam now acceptsstring | boolean | Error(wasstring | boolean).extractErrorReason(err)centralizes reason extraction: forRequestErrorit pullsresponseJSON.detail(handling bothstringand{message}shapes); for any otherErrorit falls back toerr.message.outcome: 'error_on_load'pluserror_reasonin the log/metric attributes whenevererroris truthy.Discover errors (
views/discover/results.tsx)fetchTotalCount'scatchblock now callstrackAiQueryOutcomewitherror: errso failed total-count requests are tracked instead of silently swallowed.aiQueryRunIdandmodehoisted above thetryso both branches share them.Explore (
views/explore/hooks/useAnalytics.tsx)Spans, traces, logs, and metrics analytics hooks now pass the raw
Errorobject (instead of a pre-extractederror?.messagestring) through totrackAiQueryOutcome. The error is boxed withuseBoxto avoid spurious effect re-fires on error-message identity changes; effect deps include the box ref.Test plan
assisted_query.outcomelog/metric recordsoutcome: 'error_on_load'with a populatederror_reason.events-meta/in Discover (errors dataset) and verify the same.has_results/empty_resultscorrectly.