Skip to content

Conversation

@TheRealJon
Copy link
Member

@TheRealJon TheRealJon commented May 21, 2019

Improve Prometheus poll hook.

  • Move response handling out of the hook. Handle response in component.
  • Prometheus poll and Area chart take a single query prop. Array of queries was just adding unnecessary complexity and was not being used.
  • Create generic poll hook
  • Create useSafeFetch hook - uses an AbortController to terminate pending fetches on unmount.
  • Add helper functions to build URLs for Prometheus API requests.
  • General code style fixes, variable name improvements, file renames, and type improvements.

@TheRealJon TheRealJon requested review from kyoto and spadgett May 21, 2019 18:54
@openshift-ci-robot openshift-ci-robot added the size/XL Denotes a PR that changes 500-999 lines, ignoring generated files. label May 21, 2019
Copy link
Member

@spadgett spadgett left a comment

Choose a reason for hiding this comment

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

👍 nice work

Copy link
Member

Choose a reason for hiding this comment

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

Nice!

@spadgett spadgett added this to the v4.2 milestone May 22, 2019
@TheRealJon TheRealJon force-pushed the prometheus-poll-updates branch from 555431c to 81ee4ef Compare May 22, 2019 13:07
return () => controller.current.abort();
}, []);

return (url) => coFetchJSON(url, 'get', {signal: controller.current.signal});
Copy link
Contributor

Choose a reason for hiding this comment

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

This is really awesome. Would be nice to have a unit test for it, you can check out some of the other unit tests for hooks that we've written. Also, we may want to use this for other HTTP methods in the future, but not needed now.

Copy link
Member

Choose a reason for hiding this comment

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

Adding a unit test for this would be nice, but I went ahead and added lgtm since this PR is blocking some other graph work.

Copy link
Member

@kyoto kyoto left a comment

Choose a reason for hiding this comment

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

Thanks @TheRealJon. The code looks good to me and I also tested locally.

@openshift-ci-robot openshift-ci-robot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label May 23, 2019
@kyoto
Copy link
Member

kyoto commented May 23, 2019

/lgtm

@openshift-ci-robot openshift-ci-robot added the lgtm Indicates that a PR is ready to be merged. label May 23, 2019
@openshift-ci-robot
Copy link
Contributor

[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

Details Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@TheRealJon
Copy link
Member Author

/retest

2 similar comments
@TheRealJon
Copy link
Member Author

/retest

@spadgett
Copy link
Member

/retest

@openshift-bot
Copy link
Contributor

/retest

Please review the full test history for this PR and help us cut down flakes.

@spadgett
Copy link
Member

/retest

@openshift-bot
Copy link
Contributor

/retest

Please review the full test history for this PR and help us cut down flakes.

1 similar comment
@openshift-bot
Copy link
Contributor

/retest

Please review the full test history for this PR and help us cut down flakes.

@openshift-merge-robot openshift-merge-robot merged commit 082aa8f into openshift:master May 23, 2019
@TheRealJon TheRealJon deleted the prometheus-poll-updates branch June 26, 2019 15:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

approved Indicates a PR has been approved by an approver from all required OWNERS files. lgtm Indicates that a PR is ready to be merged. size/XL Denotes a PR that changes 500-999 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

7 participants