Skip to content

[ObsUX] Add Profiling tab to Asset Details#171764

Merged
mykolaharmash merged 9 commits intoelastic:mainfrom
mykolaharmash:prodfiler-4268-infra-profiling
Nov 27, 2023
Merged

[ObsUX] Add Profiling tab to Asset Details#171764
mykolaharmash merged 9 commits intoelastic:mainfrom
mykolaharmash:prodfiler-4268-infra-profiling

Conversation

@mykolaharmash
Copy link
Copy Markdown
Contributor

@mykolaharmash mykolaharmash commented Nov 22, 2023

Summary

This adds a new "Universal Profiling" tab to asset details with a flamegrapth for a selected host. The tab is behind a feature flag and is disabled by default. It will be enabled by default for clound/onprem once we implement Profiling empty state, serverless is tbd.

  • Added two new endpoints for fetching profiling status (not used by the FE yet) and flamegraph data.
  • Added a profilingEnabled feature flag
  • Added a new tab in the UI and integrated the Flamegraph embeddable

CleanShot 2023-11-22 at 16 38 00@2x

How to test

  • Connect local kibana to oblt cluster that has Profiling configured (e.g. edge)
  • Add this to your dev kibana.yml
xpack.profiling.enabled: true
xpack.infra.profilingEnabled: true

# Direct ES URL on the oblt cluster that you're using, in case of edge it's https://edge-oblt.es.us-west2.gcp.elastic-cloud.com:443
xpack.profiling.elasticsearch.hosts: REMOTE_CLUSTER_ES_URL

# If needed create a new user on the remote oblt cluster
xpack.profiling.elasticsearch.username: REMOTE_CLUSTER_USER
xpack.profiling.elasticsearch.password: REMOTE_CLUSTER_PASWORD
  • Open kibana, go to Hosts
  • Open a flyout for one of the hosts and make sure you see the Profiling tab with a flamegraph
  • Open Host details as a full page and also make sure you see the new tab

@ghost
Copy link
Copy Markdown

ghost commented Nov 22, 2023

🤖 GitHub comments

Expand to view the GitHub comments

Just comment with:

  • /oblt-deploy : Deploy a Kibana instance using the Observability test environments.
  • /oblt-deploy-serverless : Deploy a serverless Kibana instance using the Observability test environments.
  • run elasticsearch-ci/docs : Re-trigger the docs validation. (use unformatted text in the comment!)

@mykolaharmash mykolaharmash force-pushed the prodfiler-4268-infra-profiling branch from 273f886 to 885c8d4 Compare November 22, 2023 16:02
@mykolaharmash mykolaharmash added v8.12.0 release_note:skip Skip the PR/issue when compiling release notes backport:skip This PR does not require backporting Team:obs-ux-infra_services - DEPRECATED DEPRECATED - Use Team:obs-presentation. labels Nov 22, 2023
@mykolaharmash mykolaharmash force-pushed the prodfiler-4268-infra-profiling branch 2 times, most recently from 285093f to 163ce8d Compare November 23, 2023 10:09
@mykolaharmash mykolaharmash marked this pull request as ready for review November 23, 2023 10:10
@mykolaharmash mykolaharmash requested a review from a team as a code owner November 23, 2023 10:10
@mykolaharmash mykolaharmash requested a review from a team November 23, 2023 10:10
@mykolaharmash mykolaharmash requested review from a team as code owners November 23, 2023 10:10
@elasticmachine
Copy link
Copy Markdown
Contributor

Pinging @elastic/obs-ux-infra_services-team (Team:obs-ux-infra_services)

@mykolaharmash mykolaharmash force-pushed the prodfiler-4268-infra-profiling branch from 163ce8d to f6b1119 Compare November 23, 2023 10:13
@mykolaharmash mykolaharmash requested a review from a team as a code owner November 23, 2023 10:13
@mykolaharmash
Copy link
Copy Markdown
Contributor Author

I left out API tests for now as I could not generate a good profiling data archive to test against. Will try to figure it out in the upcoming changes.

Comment on lines +24 to +36
const { loading, response, makeRequest } = useHTTPRequest<BaseFlameGraph>(
'/api/infra/profiling/flamegraph',
'POST',
JSON.stringify(InfraProfilingRequestParamsRT.encode(body)),
undefined,
undefined,
undefined,
true
);

useEffect(() => {
makeRequest();
}, [makeRequest]);
Copy link
Copy Markdown
Contributor

@crespocarlos crespocarlos Nov 23, 2023

Choose a reason for hiding this comment

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

Disclaimer: I haven't tested the PR yet, so everything I'm going to write here might not make sense because your implementation could be working as expected.

That said, here are just some initial thoughts regarding this component and suggestions:

1 - In the asset details flyout/full page, to prevent changes in the date picker from triggering requests in tabs that are not currently visible, we use the useIntersectingState hook. With this hook, you can delay component re-rendering to happen only once the component becomes visible.

2 - If Auto-Refresh is enabled, two things could happen: a never-ending loading loop and performance issues. If ongoing requests are not properly canceled between refresh cycles, the server will be busy with unnecessary requests.

To fix this, you could use the useRequestObservable() hook. This observable is responsible for determining when a new request can be made if auto-refresh is enabled. Here is an example of usage.

Feel free to reach out if you need any help, and sorry for the long comment :)

Copy link
Copy Markdown
Contributor Author

@mykolaharmash mykolaharmash Nov 23, 2023

Choose a reason for hiding this comment

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

Thank you @crespocarlos! Those are very good suggestions 🙌 Tbh I have not put much work into the FE component yet and was planning to do this with my next change while adding the Top Functions embeddable, at that point this component will become more complex and I'll have a better idea how to structure the code.

Copy link
Copy Markdown
Contributor

@crespocarlos crespocarlos Nov 23, 2023

Choose a reason for hiding this comment

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

hey @mykolaharmash , I've got some examples of what I said above.

Inventory UI: Auto refresh on (loading state and many cancelled requests)

auto_refresh_prof.mov

flamegraph request happen when the visible tab is the overview tab

hidden_prof_request.mov

For the auto-reload, it might be a good idea in the future if the profiler loader kept the rendered component and just showed a loading indicator above the content. Similar to the charts and table in the hosts view. I know this is not part of this ticket.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Thank you for making the videos @crespocarlos! I'll add useIntersectingState and useRequestObservable as you suggested.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

@crespocarlos please take another look when have time. I've refactored a bit the request logic, the issues should be fixed now. I've used useRequestObservable to fix the canceled requests thingy, but for the unintended requests I went for a simple active flag based on the currently active tab (see here). It seemed like it's enough in this case, but let me know if I'm missing something.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

@crespocarlos, I've merged this one, but let me know if you see issues with the code, I'll address it with my next change 🙌

@kibanamachine kibanamachine requested a review from a team November 23, 2023 10:56
@mykolaharmash
Copy link
Copy Markdown
Contributor Author

@elasticmachine merge upstream

<EuiFlexItem grow={false}>
<EuiLink onClick={() => createConnector()}>
<EuiLink
data-test-subj="serverlessSearchConnectorIngestionPanelSetUpAConnectorLink"
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

This seems to be some automated change, not related to the feature

Copy link
Copy Markdown
Member

@sphilipse sphilipse left a comment

Choose a reason for hiding this comment

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

Approving for CI auto-commit

Copy link
Copy Markdown
Contributor

@cauemarcondes cauemarcondes left a comment

Choose a reason for hiding this comment

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

did a first look, but haven't run it yet though.

makeRequest();
}, [makeRequest]);

if (loading || response === null) {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I think you can remove this if-clause, am I right? The Flamegraph component will render a loading spinner while loading = true.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

True, it was a quick patch to implicitly cast the response to the BaseFlameGraph and I forgot to get rid of it.

Copy link
Copy Markdown
Contributor

@thomheymann thomheymann left a comment

Choose a reason for hiding this comment

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

security changes LGTM

@mykolaharmash mykolaharmash requested a review from a team as a code owner November 23, 2023 15:44
Copy link
Copy Markdown
Contributor

@shahzad31 shahzad31 left a comment

Choose a reason for hiding this comment

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

Obs UX MG Changes LGTM !!

@kibana-ci
Copy link
Copy Markdown

💛 Build succeeded, but was flaky

Failed CI Steps

Metrics [docs]

Module Count

Fewer modules leads to a faster build time

id before after diff
infra 1371 1374 +3

Async chunks

Total size of all lazy-loaded chunks that will be downloaded as the user navigates the app

id before after diff
infra 1.9MB 1.9MB +984.0B

History

To update your PR or re-run it, just comment with:
@elasticmachine merge upstream

Copy link
Copy Markdown
Contributor

@cauemarcondes cauemarcondes left a comment

Choose a reason for hiding this comment

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

LGTM, great work 🚀

@mykolaharmash mykolaharmash merged commit 3f9b2ce into elastic:main Nov 27, 2023
@mykolaharmash mykolaharmash deleted the prodfiler-4268-infra-profiling branch November 27, 2023 09:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

backport:skip This PR does not require backporting release_note:skip Skip the PR/issue when compiling release notes Team:obs-ux-infra_services - DEPRECATED DEPRECATED - Use Team:obs-presentation. v8.12.0

Projects

None yet

Development

Successfully merging this pull request may close these issues.

10 participants