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
Bug 1856351: Fix build details page charts #6879
Conversation
@TheRealJon: This pull request references Bugzilla bug 1856351, which is valid. The bug has been moved to the POST state. The bug has been updated to refer to the pull request using the external bug tracker. 3 validation(s) were run on this bug
In response to this:
Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository. |
@TheRealJon: This pull request references Bugzilla bug 1856351, which is valid. 3 validation(s) were run on this bug
In response to this:
Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository. |
@TheRealJon: The following test failed, say
Full PR test history. Your PR dashboard. Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository. I understand the commands that are listed here. |
This is likely failing the the analyze test because I am importing moment into the datetime helper file. I did this to simplify the implementation, but it's probably overkill. I'll update to remove this import. |
7d4e944
to
5b8d3bf
Compare
@TheRealJon: This pull request references Bugzilla bug 1856351, which is valid. 3 validation(s) were run on this bug
In response to this:
Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository. |
I think this is ready for review. /assign @rohitkrai03 cc @spadgett |
/cc @kyoto |
/hold need to fix some unit tests |
cc @rawagner |
/hold cancel |
5b8d3bf
to
a1650d8
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks @TheRealJon!
A few comments on the smaller details, but generally LGTM 👍
export const ONE_MONTH = 30 * ONE_DAY; | ||
export const ONE_YEAR = 365.25 * ONE_DAY; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd suggest removing ONE_MONTH
and ONE_YEAR
since they're not currently used and obviously both 30 days and 325.25 days are not technically accurate. In practice, I think the definition of month and year will depend on the context they're used in.
|
||
const xTickFormat = span < 5 * 60 * 1000 ? twentyFourHourTimeWithSeconds : twentyFourHourTime; | ||
|
||
const xTickFormat = (d) => twentyFourHourTime(d, span < 5 * 60 * 1000); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I guess we use ONE_MINUTE
here 😄
return `${hours}:${minutes}:${seconds}`; | ||
export const twentyFourHourTime = (date: Date, showSeconds?: boolean): string => { | ||
const hours = zeroPad(date?.getHours() ?? 0); | ||
const minutes = `:${zeroPad(date?.getMinutes() ?? 0)}`; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: I think including the :
in the return statement as before is a little easier to read.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
To keep it consistent with seconds
, I think we should keep the colon as part of minutes
.
const seconds = zeroPad(date.getSeconds()); | ||
return `${hours}:${minutes}:${seconds}`; | ||
export const twentyFourHourTime = (date: Date, showSeconds?: boolean): string => { | ||
const hours = zeroPad(date?.getHours() ?? 0); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we need to handle the case where date
is not set? Since it's not an optional parameter and we use type checking, can we assume that it is indeed a Date
and lose the ?.
checks?
export const twentyFourHourTime = (date: Date, showSeconds?: boolean): string => { | ||
const hours = zeroPad(date?.getHours() ?? 0); | ||
const minutes = `:${zeroPad(date?.getMinutes() ?? 0)}`; | ||
const seconds = `:${zeroPad(date?.getSeconds() ?? 0)}`; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Probably not significant in practice, but I notice the computation for seconds
is done just to be thrown away unless showSeconds
is true
.
How about this?
const seconds = showSeconds ? `:${zeroPad(date?.getSeconds() ?? 0)}` : '';
...rest | ||
}) => { | ||
const [utilization, , utilizationLoading] = usePrometheusPoll({ | ||
const prometheusPollProps = { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
💯
frontend/public/components/build.tsx
Outdated
if (!podName) { | ||
return null; | ||
} | ||
|
||
const endTime = build?.status?.completionTimestamp |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We're assuming that build
is set elsewhere in this function, so I guess we can use build.
instead of build.?
everywhere.
frontend/public/components/build.tsx
Outdated
formatDate: (d) => twentyFourHourTime(d, timespan < 5 * ONE_MINUTE), | ||
domain: { x: [endTime - timespan, endTime] }, // force domain to match queried timespan |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we're OK in this case, but in general I've had trouble with triggering unnecessary graph re-renders by having function / object / array props that are recreated in the render function like this.
If the graph does not seem to be re-rendering too frequently, I think this is fine, but in general I'm trying to avoid these situations. For example, passing startTime
and endTime
integer props instead of a domain
object might avoid some re-renders, depending on how BuildGraphs
is used.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'll pull out domain
into a separate declaration and memoize it so it will only get re-initialized if timespan
or endTime
change.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'll also memoize areaProps
so that it won't cause unnecessary re-renders.
domain={{ | ||
...(allZero && { y: [0, 1] }), | ||
...domain, | ||
}} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The could be triggering unnecessary re-renders. If so, domain
could be memoized.
> | ||
{xAxis && <ChartAxis tickCount={tickCount} tickFormat={formatDate} />} | ||
{xAxis && <ChartAxis tickCount={tickCount} tickFormat={(tick) => formatDate(tick)} />} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Using (tick) => formatDate(tick)
instead of just formatDate
might cause ChartAxis
to re-render unnecessarily too. An easy solution to avoid that possibility would be to define const xAxisTickFormat = (tick) => formatDate(tick);
outside the component.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We can't define this outside the component since formatDate
is a prop. I'll use the React callback hook to make sure the function definition only changes when necessary.
498788a
to
c9c0d12
Compare
/retest |
@kyoto Addressed your feedback |
c9c0d12
to
3a85227
Compare
- Create new global time related constants - Update build details page area charts to only from build start to completion - Minimum queried timepan to one minute - Show seconds on build charts if timespan is less than 5 minutes - Force x domain on build charts to match the queried timespan so that chart will not show less than one minute on the x-axis. - Add new xMutator callback arg to graph util `mapLimitsRequests` function to allow for post-processing of utilization chart x values - Add new xMutator and yMutator callback args to graph util `getRangeVectorStats` function to allow for post-processing of prometheus response data x and y values - Remove logic from getRangeVectorStats function that removed second and millisecond data from all x values - Update PrometheusMultilineUtilizationItem to use new xMutator argument to trim seconds and milliseconds off of multiline area chart data points. - Create new global constants for prometheus query default samples and timespan - Update Area and AreaChart components to use new global prometheus constants and accept domain prop - Update twentyFourHourTime util function to accept `showSeconds` arg and get rid of twentyFourHourTimeWithSeconds function. - Update usage of twentyFourHourTime/twentyFourHourTimeWithSeconds function where needed
3a85227
to
f6c127a
Compare
Thanks @TheRealJon! /lgtm |
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: kyoto, TheRealJon The full list of commands accepted by this bot can be found here. The pull request process is described here
Needs approval from an approver in each of these files:
Approvers can indicate their approval by writing |
/retest Please review the full test history for this PR and help us cut down flakes. |
1 similar comment
/retest Please review the full test history for this PR and help us cut down flakes. |
@TheRealJon: All pull requests linked via external trackers have merged: Bugzilla bug 1856351 has been moved to the MODIFIED state. In response to this:
Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository. |
Update build details page charts to only show utilization data from when the build ran.
one minute on the x-axis.
mapLimitsRequests
function to allow for post-processing ofutilization chart x values
getRangeVectorStats
function to allowfor post-processing of prometheus response data x and y values
values
milliseconds off of multiline area chart data points.
showSeconds
arg and get rid oftwentyFourHourTimeWithSeconds function.