Skip to content

[Perfomance] Add is_initial_load meta#206645

Merged
kpatticha merged 27 commits intoelastic:mainfrom
kpatticha:4185-initial-load
Feb 25, 2025
Merged

[Perfomance] Add is_initial_load meta#206645
kpatticha merged 27 commits intoelastic:mainfrom
kpatticha:4185-initial-load

Conversation

@kpatticha
Copy link
Contributor

@kpatticha kpatticha commented Jan 14, 2025

closes https://github.com/elastic/observability-dev/issues/4185

Summary

This PR adds the is_initial_load parameter to the meta field to distinguish whether the onPageReady trigger occurs during the initial load or a page refresh.

Refactoring:

  • Removed the target field. as context.pageName now provides the necessary information
  • Refactor APM instrumentation to simplify it

Fixes:

⚠️ Instrumentation

The plugins need to call the following function:

onPageRefreshStart()

This method adds a performance marker start::pageRefresh to indicate when a page refresh begins. This marker is used along with an end marker end::pageReady to determine the total refresh duration.

Screen.Recording.2025-02-14.at.12.39.54.PM.mov
Screen.Recording.2025-02-14.at.12.43.29.PM.mov

How to test

  • Checkout the PR
  • make sure you run yarn kbn bootstrap
  • go to any page that has onPageReady function instrumented (ex services)

TODO

  • Once approved, update docs

@kpatticha kpatticha requested a review from a team as a code owner January 14, 2025 17:26
@kpatticha kpatticha added release_note:skip Skip the PR/issue when compiling release notes v9.0.0 backport:current-major and removed backport:current-major labels Jan 14, 2025
Copy link
Member

@afharo afharo left a comment

Choose a reason for hiding this comment

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

Approving from the Core POV because a Set is better than a string[].

I added a comment because I'd love to understand what we're trying to track here.

Copy link
Member

@maryam-saeidi maryam-saeidi left a comment

Choose a reason for hiding this comment

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

Awesome! 🥇

Do we also have a way to distinguish whether the event was related to a page load via inside Kibana navigation or the initial load of Kibana?

@kpatticha
Copy link
Contributor Author

Awesome! 🥇

Do we also have a way to distinguish whether the event was related to a page load via inside Kibana navigation or the initial load of Kibana?

with the current implementation we don't have a way to distinguish this. There is another EBT metric, kibana_started, which we might be able to correlate with these two events using their timestamps. However, this would require additional analysis work.

Copy link
Contributor

@awahab07 awahab07 left a comment

Choose a reason for hiding this comment

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

is_initial_load changes with date change because selected time range is persisted via URL state. Also, URL could change even against UI actions which do not cause a data reload.

206645-initial-load-meta-url-issue.mov

See if extracting the plugin url or using pathname is better suited here instead of the full url.

@kpatticha
Copy link
Contributor Author

is_initial_load changes with date change because selected time range is persisted via URL state. Also, URL could change even against UI actions which do not cause a data reload.

206645-initial-load-meta-url-issue.mov
See if extracting the plugin url or using pathname is better suited here instead of the full url.

Thanks, I will take a look

@kpatticha
Copy link
Contributor Author

I discovered a bug while addressing the issue Abdul mentioned. The initial marker isn't removed when the page is refreshed, causing it to report an incorrect duration.

@kpatticha kpatticha requested a review from a team February 14, 2025 10:24
@botelastic botelastic bot added the Team:obs-ux-infra_services - DEPRECATED DEPRECATED - Use Team:obs-presentation. label Feb 14, 2025
@elasticmachine
Copy link
Contributor

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

@kpatticha
Copy link
Contributor Author

Since I found the bug, I refactored and updated the code. I'm requesting another review. 🙏

@kpatticha
Copy link
Contributor Author

@elasticmachine merge upstream

@kpatticha
Copy link
Contributor Author

The refresh duration on Metrics Explorer is good now. But the date change is still instantaneous.

206645-Refresh-Date-Change-Issue.mov

Screen.Recording.2025-02-25.at.1.35.52.PM.mov

@awahab07 should be fixed now by c9be509 . it's been a bit strange how metrics explorer handles the loading state.

@kpatticha kpatticha requested a review from awahab07 February 25, 2025 11:41
@elasticmachine
Copy link
Contributor

💚 Build Succeeded

Metrics [docs]

Public APIs missing comments

Total count of every public API that lacks a comment. Target amount is 0. Run node scripts/build_api_docs --plugin [yourplugin] --stats comments for more detailed information.

id before after diff
@kbn/ebt-tools 29 30 +1

Async chunks

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

id before after diff
apm 2.3MB 2.3MB +83.0B
infra 1.1MB 1.1MB +215.0B
total +298.0B

Page load bundle

Size of the bundles that are downloaded on every page load. Target size is below 100kb

id before after diff
core 474.6KB 474.6KB +38.0B
kbnUiSharedDeps-srcJs 3.6MB 3.6MB +38.0B
total +76.0B
Unknown metric groups

API count

id before after diff
@kbn/ebt-tools 38 39 +1

History

Copy link
Contributor

@awahab07 awahab07 left a comment

Choose a reason for hiding this comment

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

LGTM!

Thanks for adding the prop.

@kpatticha kpatticha merged commit 9a1d70d into elastic:main Feb 25, 2025
9 checks passed
@kibanamachine
Copy link
Contributor

Starting backport for target branches: 9.0

https://github.com/elastic/kibana/actions/runs/13528675783

@kibanamachine
Copy link
Contributor

💔 All backports failed

Status Branch Result
9.0 Backport failed because of merge conflicts

Manual backport

To create the backport manually run:

node scripts/backport --pr 206645

Questions ?

Please refer to the Backport tool documentation

@kibanamachine kibanamachine added the backport missing Added to PRs automatically when the are determined to be missing a backport. label Feb 26, 2025
@kibanamachine
Copy link
Contributor

Friendly reminder: Looks like this PR hasn’t been backported yet.
To create automatically backports add a backport:* label or prevent reminders by adding the backport:skip label.
You can also create backports manually by running node scripts/backport --pr 206645 locally

JoseLuisGJ pushed a commit to JoseLuisGJ/kibana that referenced this pull request Feb 27, 2025
closes elastic/observability-dev#4185 

## Summary

This PR adds the `is_initial_load` parameter to the meta field to
distinguish whether the `onPageReady` trigger occurs during the initial
load or a page refresh.

Refactoring: 
- Removed the `target` field. as `context.pageName` now provides the
necessary information
- Refactor APM instrumentation to simplify it

Fixes: 
- elastic/observability-dev#3464  


### ⚠️  Instrumentation 

The plugins need to call the following function: 

``` onPageRefreshStart()```


This method adds a performance marker `start::pageRefresh` to indicate when a page refresh begins. This marker is used along with an end marker `end::pageReady` to determine the total refresh duration.


 
https://github.com/user-attachments/assets/62587d18-b33e-437b-9774-d8e196dbf764

https://github.com/user-attachments/assets/e9c9a761-57bc-4743-9cc7-ea7634696ee3



### How to test
- Checkout the PR
- make sure you run `yarn kbn bootstrap`
- go to any page that has onPageReady function instrumented (ex services)  


### TODO
- Once approved, update docs

---------

Co-authored-by: Elastic Machine <elasticmachine@users.noreply.github.com>
@kibanamachine
Copy link
Contributor

Friendly reminder: Looks like this PR hasn’t been backported yet.
To create automatically backports add a backport:* label or prevent reminders by adding the backport:skip label.
You can also create backports manually by running node scripts/backport --pr 206645 locally

1 similar comment
@kibanamachine
Copy link
Contributor

Friendly reminder: Looks like this PR hasn’t been backported yet.
To create automatically backports add a backport:* label or prevent reminders by adding the backport:skip label.
You can also create backports manually by running node scripts/backport --pr 206645 locally

Dosant added a commit to Dosant/kibana that referenced this pull request Mar 2, 2025
@kibanamachine
Copy link
Contributor

Friendly reminder: Looks like this PR hasn’t been backported yet.
To create automatically backports add a backport:* label or prevent reminders by adding the backport:skip label.
You can also create backports manually by running node scripts/backport --pr 206645 locally

@kpatticha kpatticha added backport:skip This PR does not require backporting and removed backport:prev-minor labels Mar 4, 2025
@kibanamachine kibanamachine removed the backport missing Added to PRs automatically when the are determined to be missing a backport. label Mar 4, 2025
CAWilson94 pushed a commit to CAWilson94/kibana that referenced this pull request Mar 22, 2025
closes elastic/observability-dev#4185 

## Summary

This PR adds the `is_initial_load` parameter to the meta field to
distinguish whether the `onPageReady` trigger occurs during the initial
load or a page refresh.

Refactoring: 
- Removed the `target` field. as `context.pageName` now provides the
necessary information
- Refactor APM instrumentation to simplify it

Fixes: 
- elastic/observability-dev#3464  


### ⚠️  Instrumentation 

The plugins need to call the following function: 

``` onPageRefreshStart()```


This method adds a performance marker `start::pageRefresh` to indicate when a page refresh begins. This marker is used along with an end marker `end::pageReady` to determine the total refresh duration.


 
https://github.com/user-attachments/assets/62587d18-b33e-437b-9774-d8e196dbf764

https://github.com/user-attachments/assets/e9c9a761-57bc-4743-9cc7-ea7634696ee3



### How to test
- Checkout the PR
- make sure you run `yarn kbn bootstrap`
- go to any page that has onPageReady function instrumented (ex services)  


### TODO
- Once approved, update docs

---------

Co-authored-by: Elastic Machine <elasticmachine@users.noreply.github.com>
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. v9.0.0 v9.1.0

Projects

None yet

Development

Successfully merging this pull request may close these issues.

8 participants