Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Inspector: Show transformation query errors #73344

Merged
merged 11 commits into from
Sep 20, 2023
Merged

Inspector: Show transformation query errors #73344

merged 11 commits into from
Sep 20, 2023

Conversation

ryantxu
Copy link
Member

@ryantxu ryantxu commented Aug 16, 2023

What is this feature?

While working on #73451, I discovered that the inspect error tab will not show transformation errors

Why do we need this feature?

Currently when transforms have an error you can not see them in the inspector. With this PR they will now show up:
image

This is more important when multiple errors may exist and the inspector is the only way to know what happened

@@ -67,7 +67,7 @@ export const InspectErrorTab = ({ errors }: InspectErrorTabProps) => {
return (
<>
{errors.map((error, index) => (
<Alert title={error.refId || `Query ${index + 1}`} severity="error" key={index}>
<Alert title={error.refId || `Error ${index + 1}`} severity="error" key={index}>
Copy link
Member Author

Choose a reason for hiding this comment

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

changing the text here because the error has no relation to query index

@@ -41,6 +41,10 @@ export const heatmapTransformer: SynchronousDataTransformerInfo<HeatmapTransform

transformer: (options: HeatmapTransformerOptions) => {
return (data: DataFrame[]) => {
if (1 === 1) {
data[200].fields = []; // will throw an exception!
Copy link
Member Author

Choose a reason for hiding this comment

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

^^^ DO NOT MERGE... this just forces an error for testing

const [dataOptions, setDataOptions] = useState<GetDataOptions>({
withTransforms: false,
withTransforms: defaultTab === InspectTab.Error,
Copy link
Member Author

Choose a reason for hiding this comment

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

previously this would mask any xform errors since they are not run

Copy link
Member

Choose a reason for hiding this comment

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

yea, working on the new inspector for scenes and I looked at this code and its very confusing that the data options that live under the Data tab can affect the data passed to other tabs. (Not doing that for scene inspect drawer)

@@ -63,8 +63,10 @@ export const usePanelLatestData = (

return {
data: latestData,
error: latestData && latestData.error,
Copy link
Member Author

Choose a reason for hiding this comment

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

this was only checking the deprecated property... not the other flavors that will show alerts in the panel

@@ -272,6 +272,8 @@ describe('PanelQueryRunner', () => {

ctx.runner.getData({ withTransforms: true, withFieldConfig: true }).subscribe({
next: (data: grafanaData.PanelData) => {
console.log('XFORM', data);
Copy link
Member Author

Choose a reason for hiding this comment

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

TODO... not yet sure how to test this :(

@ryantxu ryantxu requested review from gtk-grafana and dprokop August 16, 2023 20:02
@ryantxu ryantxu changed the title Transforms: Catch and report errors when running transformations Inspector: Show transformation query errors Aug 17, 2023
@ryantxu ryantxu added no-backport Skip backport of PR no-changelog Skip including change in changelog/release notes labels Aug 17, 2023
@@ -228,7 +228,7 @@ export class PanelQueryRunner {
return of({
...data,
state: LoadingState.Error,
error: toDataQueryError(err),
errors: [toDataQueryError(err)],
Copy link
Member Author

Choose a reason for hiding this comment

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

this PR fixes the inspector so it also shows errors when the array is set... that is good because the single error flavor is deprecated in favor of using the array

@ryantxu ryantxu requested a review from axelavargas August 18, 2023 21:07
Copy link
Member

@axelavargas axelavargas left a comment

Choose a reason for hiding this comment

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

Hey Ryan 👋🏾 , I took a look at the PR, codewise looks good. I tested locally and from the user perspective, I think it makes sense.

I left a small comment about an edge case.

Thanks for helping with this ⭐

@ryantxu ryantxu marked this pull request as ready for review September 19, 2023 18:27
@ryantxu ryantxu requested review from a team as code owners September 19, 2023 18:27
@ryantxu ryantxu requested a review from axelavargas September 19, 2023 18:34
Copy link
Member

@axelavargas axelavargas left a comment

Choose a reason for hiding this comment

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

🥳

Copy link
Contributor

@nmarrs nmarrs left a comment

Choose a reason for hiding this comment

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

LGTM

A possible future improvement may be labeling the errors so it is more clear where they are coming from (i.e. from a given query / transform etc) as right now it is clear something is breaking but not what is breaking

Screenshot 2023-09-20 at 10 16 20 AM

Comment on lines 44 to 47
if (1 === 1) {
data[200].fields = []; // will throw an exception!
}

Copy link
Contributor

Choose a reason for hiding this comment

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

😬 - just want to make sure we remember to remove this before merging

Suggested change
if (1 === 1) {
data[200].fields = []; // will throw an exception!
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/dashboard area/frontend no-backport Skip backport of PR no-changelog Skip including change in changelog/release notes panel/inspect
Projects
Archived in project
Development

Successfully merging this pull request may close these issues.

5 participants