-
Notifications
You must be signed in to change notification settings - Fork 8.3k
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
Fix context.pageName by fixing missing executionContext and add enableExecutionContextTracking flag #204547
Fix context.pageName by fixing missing executionContext and add enableExecutionContextTracking flag #204547
Conversation
add router to bazel
…om implementation
Pinging @elastic/obs-ux-management-team (Team:obs-ux-management) |
x-pack/solutions/observability/plugins/observability/public/application/index.tsx
Outdated
Show resolved
Hide resolved
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.
Looks good!
I also suggest to change MatchPropagator so that it throws error if executionContext is undefined. We can do this now because MatchPropagator should only be called when consumer set enableExecutionContextTracking to true. This would help us find missconfiguration errors like we had today where executionContext became undefined
@@ -63,12 +63,12 @@ const defaultContextValue = { | |||
services: {}, | |||
}; | |||
|
|||
export const sharedUXContext = | |||
export const SharedUXContext = |
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.
Can we please rename this into SharedUXRouterContext
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.
Changed in c56ab90
path={path} | ||
element={ | ||
<> | ||
{enableExecutionContextTracking && <MatchPropagator />} |
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 this here? Seems like this will also be called inside <Route/>
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.
I don't think so, but I am not sure how to verify that. Would you mind checking it? If you and your team don't see a use case for it, I can remove it, but I am not sure why it was added in the first place.
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 double-checked. Agree that we should keep it here
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.
Approving bc this seems to work, I left a comment just to understand better.
@@ -28,7 +28,7 @@ import { HideableReactQueryDevTools } from './hideable_react_query_dev_tools'; | |||
function App() { | |||
return ( | |||
<> | |||
<Routes> | |||
<Routes enableExecutionContextTracking={true}> |
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.
Can you explain a little more about why we have to explicitly opt into this?
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.
Sure, I started by enabling this logic everywhere in this PR, assuming any custom implementation will override it. But when I asked teams to verify this assumption, in some cases, that was not the case, and when Anton and I were checking the issue, it seemed there could be a race condition, and we cannot rely on the order of execution here.
So, I decided to disable this logic where we have custom implementation and have it out of the box everywhere else, but due to the following reasons, I decided to change direction:
- For security, there are many places where we need to disable default tracking, which didn't seem to be worth it.
- We cannot ensure in places that we enable it, it works as expected. So, allowing each team to enable it to verify the changes seemed like a better approach.
- PR review in case of disabling would take a lot of time since different teams need to check the existing implementation for all their routes in one PR.
💛 Build succeeded, but was flaky
Failed CI StepsTest Failures
Metrics [docs]Module Count
Public APIs missing comments
Async chunks
Public APIs missing exports
Page load bundle
Unknown metric groupsAPI count
History
|
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.
lgtm, thank you!
Starting backport for target branches: 8.x https://github.com/elastic/kibana/actions/runs/12393464758 |
💔 All backports failed
Manual backportTo create the backport manually run:
Questions ?Please refer to the Backport tool documentation |
💚 All backports created successfully
Note: Successful backport PRs will be merged automatically after passing CI. Questions ?Please refer to the Backport tool documentation |
…eExecutionContextTracking flag (elastic#204547) Resolves elastic#195778 ## 🐞 Summary This PR fixes missing executionContext in sharedux router by adding `SharedUXContext` to the `KibanaRootContextProvider` (inside of the `KibanaRenderContextProvider`). (More context provided in this elastic#195778 (comment)) It also introduces `enableExecutionContextTracking` to enable tracking logic to avoid creating a race condition for the existing custom execution context tracking implementations. I enabled this flag for the observability plugin and here is the difference: |Item|Screenshot| |---|---| |Before|![image](https://github.com/user-attachments/assets/83283d23-3347-45be-95c1-120cdfabb9c5)| |After|![image](https://github.com/user-attachments/assets/9de51645-6bf1-4537-baeb-6878e7bb3590)| ### 🧪 How to test - Go to the observability alerts page and check the kibana-browser request as shown above ### ✨ Possible future improvements Allowing this logic to be provided by the consumer so that we can get rid of custom implementations (Example: [APM custom execution context](https://github.com/elastic/kibana/blob/e9671937bacfaa911d32de0e8885e7f26425888a/x-pack/plugins/observability_solution/apm/public/components/routing/app_root/update_execution_context_on_route_change.ts#L21,L25)) --------- Co-authored-by: Anton Dosov <[email protected]> Co-authored-by: Davis McPhee <[email protected]> Co-authored-by: Marco Antonio Ghiani <[email protected]> Co-authored-by: Elena Stoeva <[email protected]> (cherry picked from commit 53748fd) # Conflicts: # packages/react/kibana_context/root/BUILD.bazel
Starting backport for target branches: 8.17, 8.x https://github.com/elastic/kibana/actions/runs/12397221444 |
💔 All backports failed
Manual backportTo create the backport manually run:
Questions ?Please refer to the Backport tool documentation |
…eExecutionContextTracking flag (elastic#204547) Resolves elastic#195778 ## 🐞 Summary This PR fixes missing executionContext in sharedux router by adding `SharedUXContext` to the `KibanaRootContextProvider` (inside of the `KibanaRenderContextProvider`). (More context provided in this elastic#195778 (comment)) It also introduces `enableExecutionContextTracking` to enable tracking logic to avoid creating a race condition for the existing custom execution context tracking implementations. I enabled this flag for the observability plugin and here is the difference: |Item|Screenshot| |---|---| |Before|![image](https://github.com/user-attachments/assets/83283d23-3347-45be-95c1-120cdfabb9c5)| |After|![image](https://github.com/user-attachments/assets/9de51645-6bf1-4537-baeb-6878e7bb3590)| ### 🧪 How to test - Go to the observability alerts page and check the kibana-browser request as shown above ### ✨ Possible future improvements Allowing this logic to be provided by the consumer so that we can get rid of custom implementations (Example: [APM custom execution context](https://github.com/elastic/kibana/blob/e9671937bacfaa911d32de0e8885e7f26425888a/x-pack/plugins/observability_solution/apm/public/components/routing/app_root/update_execution_context_on_route_change.ts#L21,L25)) --------- Co-authored-by: Anton Dosov <[email protected]> Co-authored-by: Davis McPhee <[email protected]> Co-authored-by: Marco Antonio Ghiani <[email protected]> Co-authored-by: Elena Stoeva <[email protected]> (cherry picked from commit 53748fd) # Conflicts: # packages/react/kibana_context/render/render_provider.tsx # packages/react/kibana_context/root/BUILD.bazel # packages/react/kibana_context/root/root_provider.test.tsx # packages/react/kibana_context/root/root_provider.tsx # packages/react/kibana_context/root/tsconfig.json
💚 All backports created successfully
Note: Successful backport PRs will be merged automatically after passing CI. Questions ?Please refer to the Backport tool documentation |
… enableExecutionContextTracking flag (#204547) (#204798) # Backport This will backport the following commits from `main` to `8.x`: - [Fix context.pageName by fixing missing executionContext and add enableExecutionContextTracking flag (#204547)](#204547) <!--- Backport version: 8.9.8 --> ### Questions ? Please refer to the [Backport tool documentation](https://github.com/sqren/backport) <!--BACKPORT [{"author":{"name":"Maryam Saeidi","email":"[email protected]"},"sourceCommit":{"committedDate":"2024-12-18T12:59:23Z","message":"Fix context.pageName by fixing missing executionContext and add enableExecutionContextTracking flag (#204547)\n\nResolves https://github.com/elastic/kibana/issues/195778\r\n\r\n## 🐞 Summary\r\nThis PR fixes missing executionContext in sharedux router by adding\r\n`SharedUXContext` to the `KibanaRootContextProvider` (inside of the\r\n`KibanaRenderContextProvider`). (More context provided in this\r\nhttps://github.com//issues/195778#issuecomment-2426936142)\r\n\r\nIt also introduces `enableExecutionContextTracking` to enable tracking\r\nlogic to avoid creating a race condition for the existing custom\r\nexecution context tracking implementations.\r\n\r\nI enabled this flag for the observability plugin and here is the\r\ndifference:\r\n\r\n|Item|Screenshot|\r\n|---|---|\r\n\r\n|Before|![image](https://github.com/user-attachments/assets/83283d23-3347-45be-95c1-120cdfabb9c5)|\r\n\r\n|After|![image](https://github.com/user-attachments/assets/9de51645-6bf1-4537-baeb-6878e7bb3590)|\r\n\r\n### 🧪 How to test\r\n- Go to the observability alerts page and check the kibana-browser\r\nrequest as shown above\r\n\r\n### ✨ Possible future improvements\r\n\r\nAllowing this logic to be provided by the consumer so that we can get\r\nrid of custom implementations (Example: [APM custom execution\r\ncontext](https://github.com/elastic/kibana/blob/e9671937bacfaa911d32de0e8885e7f26425888a/x-pack/plugins/observability_solution/apm/public/components/routing/app_root/update_execution_context_on_route_change.ts#L21,L25))\r\n\r\n---------\r\n\r\nCo-authored-by: Anton Dosov <[email protected]>\r\nCo-authored-by: Davis McPhee <[email protected]>\r\nCo-authored-by: Marco Antonio Ghiani <[email protected]>\r\nCo-authored-by: Elena Stoeva <[email protected]>","sha":"53748fdefa1d59d58a4708258a1476dc140b1588","branchLabelMapping":{"^v9.0.0$":"main","^v8.18.0$":"8.x","^v(\\d+).(\\d+).\\d+$":"$1.$2"}},"sourcePullRequest":{"labels":["release_note:skip","v9.0.0","backport:prev-minor","Team:obs-ux-management"],"number":204547,"url":"https://github.com/elastic/kibana/pull/204547","mergeCommit":{"message":"Fix context.pageName by fixing missing executionContext and add enableExecutionContextTracking flag (#204547)\n\nResolves https://github.com/elastic/kibana/issues/195778\r\n\r\n## 🐞 Summary\r\nThis PR fixes missing executionContext in sharedux router by adding\r\n`SharedUXContext` to the `KibanaRootContextProvider` (inside of the\r\n`KibanaRenderContextProvider`). (More context provided in this\r\nhttps://github.com//issues/195778#issuecomment-2426936142)\r\n\r\nIt also introduces `enableExecutionContextTracking` to enable tracking\r\nlogic to avoid creating a race condition for the existing custom\r\nexecution context tracking implementations.\r\n\r\nI enabled this flag for the observability plugin and here is the\r\ndifference:\r\n\r\n|Item|Screenshot|\r\n|---|---|\r\n\r\n|Before|![image](https://github.com/user-attachments/assets/83283d23-3347-45be-95c1-120cdfabb9c5)|\r\n\r\n|After|![image](https://github.com/user-attachments/assets/9de51645-6bf1-4537-baeb-6878e7bb3590)|\r\n\r\n### 🧪 How to test\r\n- Go to the observability alerts page and check the kibana-browser\r\nrequest as shown above\r\n\r\n### ✨ Possible future improvements\r\n\r\nAllowing this logic to be provided by the consumer so that we can get\r\nrid of custom implementations (Example: [APM custom execution\r\ncontext](https://github.com/elastic/kibana/blob/e9671937bacfaa911d32de0e8885e7f26425888a/x-pack/plugins/observability_solution/apm/public/components/routing/app_root/update_execution_context_on_route_change.ts#L21,L25))\r\n\r\n---------\r\n\r\nCo-authored-by: Anton Dosov <[email protected]>\r\nCo-authored-by: Davis McPhee <[email protected]>\r\nCo-authored-by: Marco Antonio Ghiani <[email protected]>\r\nCo-authored-by: Elena Stoeva <[email protected]>","sha":"53748fdefa1d59d58a4708258a1476dc140b1588"}},"sourceBranch":"main","suggestedTargetBranches":[],"targetPullRequestStates":[{"branch":"main","label":"v9.0.0","labelRegex":"^v9.0.0$","isSourceBranch":true,"state":"MERGED","url":"https://github.com/elastic/kibana/pull/204547","number":204547,"mergeCommit":{"message":"Fix context.pageName by fixing missing executionContext and add enableExecutionContextTracking flag (#204547)\n\nResolves https://github.com/elastic/kibana/issues/195778\r\n\r\n## 🐞 Summary\r\nThis PR fixes missing executionContext in sharedux router by adding\r\n`SharedUXContext` to the `KibanaRootContextProvider` (inside of the\r\n`KibanaRenderContextProvider`). (More context provided in this\r\nhttps://github.com//issues/195778#issuecomment-2426936142)\r\n\r\nIt also introduces `enableExecutionContextTracking` to enable tracking\r\nlogic to avoid creating a race condition for the existing custom\r\nexecution context tracking implementations.\r\n\r\nI enabled this flag for the observability plugin and here is the\r\ndifference:\r\n\r\n|Item|Screenshot|\r\n|---|---|\r\n\r\n|Before|![image](https://github.com/user-attachments/assets/83283d23-3347-45be-95c1-120cdfabb9c5)|\r\n\r\n|After|![image](https://github.com/user-attachments/assets/9de51645-6bf1-4537-baeb-6878e7bb3590)|\r\n\r\n### 🧪 How to test\r\n- Go to the observability alerts page and check the kibana-browser\r\nrequest as shown above\r\n\r\n### ✨ Possible future improvements\r\n\r\nAllowing this logic to be provided by the consumer so that we can get\r\nrid of custom implementations (Example: [APM custom execution\r\ncontext](https://github.com/elastic/kibana/blob/e9671937bacfaa911d32de0e8885e7f26425888a/x-pack/plugins/observability_solution/apm/public/components/routing/app_root/update_execution_context_on_route_change.ts#L21,L25))\r\n\r\n---------\r\n\r\nCo-authored-by: Anton Dosov <[email protected]>\r\nCo-authored-by: Davis McPhee <[email protected]>\r\nCo-authored-by: Marco Antonio Ghiani <[email protected]>\r\nCo-authored-by: Elena Stoeva <[email protected]>","sha":"53748fdefa1d59d58a4708258a1476dc140b1588"}}]}] BACKPORT-->
Resolves #195778
🐞 Summary
This PR fixes missing executionContext in sharedux router by adding
SharedUXContext
to theKibanaRootContextProvider
(inside of theKibanaRenderContextProvider
). (More context provided in this #195778 (comment))It also introduces
enableExecutionContextTracking
to enable tracking logic to avoid creating a race condition for the existing custom execution context tracking implementations.I enabled this flag for the observability plugin and here is the difference:
🧪 How to test
✨ Possible future improvements
Allowing this logic to be provided by the consumer so that we can get rid of custom implementations (Example: APM custom execution context)