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

StateTimeline: Treat second time field as state endings #84130

Merged
merged 7 commits into from Mar 11, 2024

Conversation

leeoniya
Copy link
Contributor

@leeoniya leeoniya commented Mar 9, 2024

Fixes https://github.com/grafana/support-escalations/issues/9636
Fixes #84127

StateTimeline panel currently requires either null values or a new state to terminate the previous state. however, splicing in the null values into the correct positions is pretty much impossible with our transformations. datasets often contain some form of endTime field to indicate state terminations. what this PR does is detects the presence of a second time field and splices in the null values correctly (using our beloved outerJoin transformation).

additionally, it fixes a regression i introduced in #83355 that removed spanNulls: -1 handling from GraphNG. it turns out we still need this while we do the final frame joining in lower layers and this is the only way that StateTimeline prep is able to communicate the NULL_RETAIN intent. we can remove this once we pull up the frame alignment up into the panels. i added a test to make sure we test the intended behavior and not the spanNulls setting itself, which is an implementation detail.

new gdev dashboard that shows off the new endTime detection and requires that frame joining + NULL_RETAIN works properly.

image

also fixes another spanNulls-related bug...

Fixes #76869

image

@leeoniya leeoniya added type/bug area/panel/state-timeline no-backport Skip backport of PR kind/enhancement no-changelog Skip including change in changelog/release notes labels Mar 9, 2024
@leeoniya leeoniya requested a review from ryantxu March 9, 2024 03:09
@leeoniya leeoniya self-assigned this Mar 9, 2024
@leeoniya leeoniya requested review from a team as code owners March 9, 2024 03:09
@leeoniya leeoniya requested review from Develer, mdvictor and kaydelaney and removed request for a team March 9, 2024 03:09
@grafana-delivery-bot grafana-delivery-bot bot added this to the 11.0.x milestone Mar 9, 2024
@leeoniya leeoniya requested review from nmarrs and removed request for mdvictor and kaydelaney March 9, 2024 03:14
@@ -496,6 +545,7 @@ export function prepareTimelineFields(
},
},
};
changed = true;
Copy link
Contributor Author

Choose a reason for hiding this comment

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

this is the fix for #76869

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.

Tested locally and it looks like it addresses the escalation - it might be a good idea to sync up as a team around null handling as its been several months since we poked at this and it would be good for everyone to fully understand the 3 different null modes

} else if (endFieldIdx === -1) {
endFieldIdx = i;
break;
}
Copy link
Contributor

Choose a reason for hiding this comment

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

I remember that we have handling were we have consider the first field to be the time field, does it make sense though to always consider the next found time field as the end field? (i.e. couldn't other time data be represented in user's data?)

I'm not sure this should be default behavior vs only apply in certain circumstances 🤷🏻‍♂️

Copy link
Contributor Author

Choose a reason for hiding this comment

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

i.e. couldn't other time data be represented in user's data?

technically, yes. but there is plenty of existing "auto" behavior that makes assumptions like "first string field", "all number fields", etc. to get it perfect in all cases we'd have to give explicit control to users over what each field in their response represents for each viz panel.

my gut feeling is that endTime is the most likely additional time field. if this turns out to be wrong, we can then expose options to override these assumptions and select fields explicitly, like we do in Trend, Candlestick, XYChart, etc.

['OK', undefined, null, undefined, 'NO_DATA', undefined, undefined, null],
[undefined, 'ERROR', undefined, null, undefined, 'WARNING', null, undefined],
]);
});
Copy link
Contributor

Choose a reason for hiding this comment

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

❤️

@leeoniya
Copy link
Contributor Author

leeoniya commented Mar 11, 2024

it might be a good idea to sync up as a team around null handling

yep. but i'm also secretly hoping to ride it out till uPlot v2 and we don't need field joining / frame alignment any more. then there is only null and it has one meaning - a gap.

@leeoniya leeoniya merged commit 57df3b8 into main Mar 11, 2024
18 checks passed
@leeoniya leeoniya deleted the leeoniya/state-timeline-timeEnd branch March 11, 2024 03:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

StateTimeline: Support second time field for state end State Timeline event widths prematurely end
3 participants