[APM][OTel] Encode service name in the APM URLs#217092
[APM][OTel] Encode service name in the APM URLs#217092jennypavlova merged 30 commits intoelastic:mainfrom
Conversation
| return addBasePath( | ||
| basePath, | ||
| `/app/apm/services/${serviceName}/overview/?rangeFrom=${dateRangeStart}&rangeTo=${dateRangeEnd}` | ||
| `/app/apm/services/${encodeURIComponent( |
There was a problem hiding this comment.
This is probably not needed as it's legacy_uptime but changed that and the test anyway
|
/ci |
|
/ci |
|
/ci |
|
Starting backport for target branches: 8.18, 8.x, 9.0 https://github.com/elastic/kibana/actions/runs/14497054882 |
💛 Build succeeded, but was flaky
Failed CI StepsTest Failures
Metrics [docs]Module Count
Public APIs missing comments
Async chunks
Page load bundle
History
|
💔 All backports failed
Manual backportTo create the backport manually run: Questions ?Please refer to the Backport tool documentation |
Closes elastic#213943 ## Summary This PR ensures the service name is always encoded in the APM UIs. It's a follow-up of elastic#215031 and aims to find a better solution to the problem: - Add the encoding directly to `formatRequest` as suggested there - I saw that there are many places where we use legacy Url builders, so I will try to replace them where possible and use apm router link method where the path is encoded ([ref](https://github.com/elastic/kibana/blob/7158e0201bf6becb4f2b821fb693bf6ed6365b54/src/platform/packages/shared/kbn-typed-react-router-config/src/create_router.ts#L184-L185)) - The PR includes the changes to address the issue above: - Replaced and removed `LegacyAPMLink` - Refactored `useAPMHref` to support encoding (and extracted and test the encoding logic) - Example usage: - Before: ```js useAPMHref({ path: `/services/${serviceName}/.....`, persistedFilters, }); ``` - After: ```js useAPMHref({ path: '/services/{serviceName}/.......}', pathParams: { serviceName }, persistedFilters, }); ``` - Used the APM router link method as much as possible ## Testing - Run `node scripts/synthtrace trace_with_service_names_with_slashes.ts --clean --live --uniqueIds --live` - Go to service inventory and click the links: https://github.com/user-attachments/assets/fcd4fbfc-4125-4cc8-9b00-53c5f375423f (cherry picked from commit f816e7b) # Conflicts: # x-pack/solutions/observability/plugins/apm/ftr_e2e/cypress/e2e/service_overview/otel_service_overview_and_transactions.cy.ts # x-pack/solutions/observability/plugins/apm/public/components/app/error_group_details/error_sampler/error_sample_detail.tsx
Closes elastic#213943 ## Summary This PR ensures the service name is always encoded in the APM UIs. It's a follow-up of elastic#215031 and aims to find a better solution to the problem: - Add the encoding directly to `formatRequest` as suggested there - I saw that there are many places where we use legacy Url builders, so I will try to replace them where possible and use apm router link method where the path is encoded ([ref](https://github.com/elastic/kibana/blob/7158e0201bf6becb4f2b821fb693bf6ed6365b54/src/platform/packages/shared/kbn-typed-react-router-config/src/create_router.ts#L184-L185)) - The PR includes the changes to address the issue above: - Replaced and removed `LegacyAPMLink` - Refactored `useAPMHref` to support encoding (and extracted and test the encoding logic) - Example usage: - Before: ```js useAPMHref({ path: `/services/${serviceName}/.....`, persistedFilters, }); ``` - After: ```js useAPMHref({ path: '/services/{serviceName}/.......}', pathParams: { serviceName }, persistedFilters, }); ``` - Used the APM router link method as much as possible ## Testing - Run `node scripts/synthtrace trace_with_service_names_with_slashes.ts --clean --live --uniqueIds --live` - Go to service inventory and click the links: https://github.com/user-attachments/assets/fcd4fbfc-4125-4cc8-9b00-53c5f375423f (cherry picked from commit f816e7b) # Conflicts: # x-pack/solutions/observability/plugins/apm/ftr_e2e/cypress/e2e/service_overview/otel_service_overview_and_transactions.cy.ts # x-pack/solutions/observability/plugins/apm/public/components/app/service_map/controls.tsx # x-pack/solutions/observability/plugins/apm/public/components/app/top_traces_overview/trace_list.tsx # x-pack/solutions/observability/plugins/apm/public/components/routing/app_root/apm_header_action_menu/anomaly_detection_setup_link.tsx # x-pack/solutions/observability/plugins/apm/public/components/shared/charts/timeline/marker/error_marker.tsx
💚 All backports created successfully
Note: Successful backport PRs will be merged automatically after passing CI. Questions ?Please refer to the Backport tool documentation |
Closes elastic#213943 ## Summary This PR ensures the service name is always encoded in the APM UIs. It's a follow-up of elastic#215031 and aims to find a better solution to the problem: - Add the encoding directly to `formatRequest` as suggested there - I saw that there are many places where we use legacy Url builders, so I will try to replace them where possible and use apm router link method where the path is encoded ([ref](https://github.com/elastic/kibana/blob/7158e0201bf6becb4f2b821fb693bf6ed6365b54/src/platform/packages/shared/kbn-typed-react-router-config/src/create_router.ts#L184-L185)) - The PR includes the changes to address the issue above: - Replaced and removed `LegacyAPMLink` - Refactored `useAPMHref` to support encoding (and extracted and test the encoding logic) - Example usage: - Before: ```js useAPMHref({ path: `/services/${serviceName}/.....`, persistedFilters, }); ``` - After: ```js useAPMHref({ path: '/services/{serviceName}/.......}', pathParams: { serviceName }, persistedFilters, }); ``` - Used the APM router link method as much as possible ## Testing - Run `node scripts/synthtrace trace_with_service_names_with_slashes.ts --clean --live --uniqueIds --live` - Go to service inventory and click the links: https://github.com/user-attachments/assets/fcd4fbfc-4125-4cc8-9b00-53c5f375423f (cherry picked from commit f816e7b) # Conflicts: # x-pack/solutions/observability/plugins/apm/ftr_e2e/cypress/e2e/service_overview/otel_service_overview_and_transactions.cy.ts # x-pack/solutions/observability/plugins/apm/public/components/app/error_group_details/error_sampler/error_sample_detail.tsx # x-pack/solutions/observability/plugins/apm/public/components/app/service_map/controls.tsx # x-pack/solutions/observability/plugins/apm/public/components/app/top_traces_overview/trace_list.tsx # x-pack/solutions/observability/plugins/apm/public/components/routing/app_root/apm_header_action_menu/anomaly_detection_setup_link.tsx # x-pack/solutions/observability/plugins/apm/public/components/shared/charts/timeline/marker/error_marker.tsx
…8477) # Backport This will backport the following commits from `main` to `8.18`: - [[APM][OTel] Encode service name in the APM URLs (#217092)](#217092) <!--- Backport version: 9.6.6 --> ### Questions ? Please refer to the [Backport tool documentation](https://github.com/sorenlouv/backport) <!--BACKPORT [{"author":{"name":"jennypavlova","email":"dzheni.pavlova@elastic.co"},"sourceCommit":{"committedDate":"2025-04-16T15:52:33Z","message":"[APM][OTel] Encode service name in the APM URLs (#217092)\n\nCloses #213943\n\n## Summary\n\nThis PR ensures the service name is always encoded in the APM UIs. It's\na follow-up of #215031 and aims to\nfind a better solution to the problem:\n- Add the encoding directly to `formatRequest` as suggested there\n- I saw that there are many places where we use legacy Url builders, so\nI will try to replace them where possible and use\napm router link method where the path is encoded\n([ref](https://github.com/elastic/kibana/blob/7158e0201bf6becb4f2b821fb693bf6ed6365b54/src/platform/packages/shared/kbn-typed-react-router-config/src/create_router.ts#L184-L185))\n- The PR includes the changes to address the issue above:\n - Replaced and removed `LegacyAPMLink`\n- Refactored `useAPMHref` to support encoding (and extracted and test\nthe encoding logic)\n - Example usage: \n - Before: \n ```js\n useAPMHref({\n path: `/services/${serviceName}/.....`,\n persistedFilters,\n });\n ```\n - After:\n ```js\n useAPMHref({\n path: '/services/{serviceName}/.......}',\n pathParams: { serviceName },\n persistedFilters,\n });\n ```\n - Used the APM router link method as much as possible\n\n\n## Testing\n- Run `node scripts/synthtrace trace_with_service_names_with_slashes.ts\n--clean --live --uniqueIds --live`\n- Go to service inventory and click the links:\n\n\nhttps://github.com/user-attachments/assets/fcd4fbfc-4125-4cc8-9b00-53c5f375423f","sha":"f816e7b84f94d9af8d3fffb85dc83512f31c55e9","branchLabelMapping":{"^v9.1.0$":"main","^v8.19.0$":"8.x","^v(\\d+).(\\d+).\\d+$":"$1.$2"}},"sourcePullRequest":{"labels":["release_note:enhancement","v9.0.0","backport:prev-minor","Team:obs-ux-infra_services","backport:version","v8.18.0","v9.1.0","v8.19.0"],"title":"[APM][OTel] Encode service name in the APM URLs","number":217092,"url":"https://github.com/elastic/kibana/pull/217092","mergeCommit":{"message":"[APM][OTel] Encode service name in the APM URLs (#217092)\n\nCloses #213943\n\n## Summary\n\nThis PR ensures the service name is always encoded in the APM UIs. It's\na follow-up of #215031 and aims to\nfind a better solution to the problem:\n- Add the encoding directly to `formatRequest` as suggested there\n- I saw that there are many places where we use legacy Url builders, so\nI will try to replace them where possible and use\napm router link method where the path is encoded\n([ref](https://github.com/elastic/kibana/blob/7158e0201bf6becb4f2b821fb693bf6ed6365b54/src/platform/packages/shared/kbn-typed-react-router-config/src/create_router.ts#L184-L185))\n- The PR includes the changes to address the issue above:\n - Replaced and removed `LegacyAPMLink`\n- Refactored `useAPMHref` to support encoding (and extracted and test\nthe encoding logic)\n - Example usage: \n - Before: \n ```js\n useAPMHref({\n path: `/services/${serviceName}/.....`,\n persistedFilters,\n });\n ```\n - After:\n ```js\n useAPMHref({\n path: '/services/{serviceName}/.......}',\n pathParams: { serviceName },\n persistedFilters,\n });\n ```\n - Used the APM router link method as much as possible\n\n\n## Testing\n- Run `node scripts/synthtrace trace_with_service_names_with_slashes.ts\n--clean --live --uniqueIds --live`\n- Go to service inventory and click the links:\n\n\nhttps://github.com/user-attachments/assets/fcd4fbfc-4125-4cc8-9b00-53c5f375423f","sha":"f816e7b84f94d9af8d3fffb85dc83512f31c55e9"}},"sourceBranch":"main","suggestedTargetBranches":["9.0","8.18","8.x"],"targetPullRequestStates":[{"branch":"9.0","label":"v9.0.0","branchLabelMappingKey":"^v(\\d+).(\\d+).\\d+$","isSourceBranch":false,"state":"NOT_CREATED"},{"branch":"8.18","label":"v8.18.0","branchLabelMappingKey":"^v(\\d+).(\\d+).\\d+$","isSourceBranch":false,"state":"NOT_CREATED"},{"branch":"main","label":"v9.1.0","branchLabelMappingKey":"^v9.1.0$","isSourceBranch":true,"state":"MERGED","url":"https://github.com/elastic/kibana/pull/217092","number":217092,"mergeCommit":{"message":"[APM][OTel] Encode service name in the APM URLs (#217092)\n\nCloses #213943\n\n## Summary\n\nThis PR ensures the service name is always encoded in the APM UIs. It's\na follow-up of #215031 and aims to\nfind a better solution to the problem:\n- Add the encoding directly to `formatRequest` as suggested there\n- I saw that there are many places where we use legacy Url builders, so\nI will try to replace them where possible and use\napm router link method where the path is encoded\n([ref](https://github.com/elastic/kibana/blob/7158e0201bf6becb4f2b821fb693bf6ed6365b54/src/platform/packages/shared/kbn-typed-react-router-config/src/create_router.ts#L184-L185))\n- The PR includes the changes to address the issue above:\n - Replaced and removed `LegacyAPMLink`\n- Refactored `useAPMHref` to support encoding (and extracted and test\nthe encoding logic)\n - Example usage: \n - Before: \n ```js\n useAPMHref({\n path: `/services/${serviceName}/.....`,\n persistedFilters,\n });\n ```\n - After:\n ```js\n useAPMHref({\n path: '/services/{serviceName}/.......}',\n pathParams: { serviceName },\n persistedFilters,\n });\n ```\n - Used the APM router link method as much as possible\n\n\n## Testing\n- Run `node scripts/synthtrace trace_with_service_names_with_slashes.ts\n--clean --live --uniqueIds --live`\n- Go to service inventory and click the links:\n\n\nhttps://github.com/user-attachments/assets/fcd4fbfc-4125-4cc8-9b00-53c5f375423f","sha":"f816e7b84f94d9af8d3fffb85dc83512f31c55e9"}},{"branch":"8.x","label":"v8.19.0","branchLabelMappingKey":"^v8.19.0$","isSourceBranch":false,"state":"NOT_CREATED"}]}] BACKPORT-->
) # Backport This will backport the following commits from `main` to `8.x`: - [[APM][OTel] Encode service name in the APM URLs (#217092)](#217092) <!--- Backport version: 9.6.6 --> ### Questions ? Please refer to the [Backport tool documentation](https://github.com/sorenlouv/backport) <!--BACKPORT [{"author":{"name":"jennypavlova","email":"dzheni.pavlova@elastic.co"},"sourceCommit":{"committedDate":"2025-04-16T15:52:33Z","message":"[APM][OTel] Encode service name in the APM URLs (#217092)\n\nCloses #213943\n\n## Summary\n\nThis PR ensures the service name is always encoded in the APM UIs. It's\na follow-up of #215031 and aims to\nfind a better solution to the problem:\n- Add the encoding directly to `formatRequest` as suggested there\n- I saw that there are many places where we use legacy Url builders, so\nI will try to replace them where possible and use\napm router link method where the path is encoded\n([ref](https://github.com/elastic/kibana/blob/7158e0201bf6becb4f2b821fb693bf6ed6365b54/src/platform/packages/shared/kbn-typed-react-router-config/src/create_router.ts#L184-L185))\n- The PR includes the changes to address the issue above:\n - Replaced and removed `LegacyAPMLink`\n- Refactored `useAPMHref` to support encoding (and extracted and test\nthe encoding logic)\n - Example usage: \n - Before: \n ```js\n useAPMHref({\n path: `/services/${serviceName}/.....`,\n persistedFilters,\n });\n ```\n - After:\n ```js\n useAPMHref({\n path: '/services/{serviceName}/.......}',\n pathParams: { serviceName },\n persistedFilters,\n });\n ```\n - Used the APM router link method as much as possible\n\n\n## Testing\n- Run `node scripts/synthtrace trace_with_service_names_with_slashes.ts\n--clean --live --uniqueIds --live`\n- Go to service inventory and click the links:\n\n\nhttps://github.com/user-attachments/assets/fcd4fbfc-4125-4cc8-9b00-53c5f375423f","sha":"f816e7b84f94d9af8d3fffb85dc83512f31c55e9","branchLabelMapping":{"^v9.1.0$":"main","^v8.19.0$":"8.x","^v(\\d+).(\\d+).\\d+$":"$1.$2"}},"sourcePullRequest":{"labels":["release_note:enhancement","v9.0.0","backport:prev-minor","Team:obs-ux-infra_services","backport:version","v8.18.0","v9.1.0","v8.19.0"],"title":"[APM][OTel] Encode service name in the APM URLs","number":217092,"url":"https://github.com/elastic/kibana/pull/217092","mergeCommit":{"message":"[APM][OTel] Encode service name in the APM URLs (#217092)\n\nCloses #213943\n\n## Summary\n\nThis PR ensures the service name is always encoded in the APM UIs. It's\na follow-up of #215031 and aims to\nfind a better solution to the problem:\n- Add the encoding directly to `formatRequest` as suggested there\n- I saw that there are many places where we use legacy Url builders, so\nI will try to replace them where possible and use\napm router link method where the path is encoded\n([ref](https://github.com/elastic/kibana/blob/7158e0201bf6becb4f2b821fb693bf6ed6365b54/src/platform/packages/shared/kbn-typed-react-router-config/src/create_router.ts#L184-L185))\n- The PR includes the changes to address the issue above:\n - Replaced and removed `LegacyAPMLink`\n- Refactored `useAPMHref` to support encoding (and extracted and test\nthe encoding logic)\n - Example usage: \n - Before: \n ```js\n useAPMHref({\n path: `/services/${serviceName}/.....`,\n persistedFilters,\n });\n ```\n - After:\n ```js\n useAPMHref({\n path: '/services/{serviceName}/.......}',\n pathParams: { serviceName },\n persistedFilters,\n });\n ```\n - Used the APM router link method as much as possible\n\n\n## Testing\n- Run `node scripts/synthtrace trace_with_service_names_with_slashes.ts\n--clean --live --uniqueIds --live`\n- Go to service inventory and click the links:\n\n\nhttps://github.com/user-attachments/assets/fcd4fbfc-4125-4cc8-9b00-53c5f375423f","sha":"f816e7b84f94d9af8d3fffb85dc83512f31c55e9"}},"sourceBranch":"main","suggestedTargetBranches":["9.0","8.18","8.x"],"targetPullRequestStates":[{"branch":"9.0","label":"v9.0.0","branchLabelMappingKey":"^v(\\d+).(\\d+).\\d+$","isSourceBranch":false,"state":"NOT_CREATED"},{"branch":"8.18","label":"v8.18.0","branchLabelMappingKey":"^v(\\d+).(\\d+).\\d+$","isSourceBranch":false,"state":"NOT_CREATED"},{"branch":"main","label":"v9.1.0","branchLabelMappingKey":"^v9.1.0$","isSourceBranch":true,"state":"MERGED","url":"https://github.com/elastic/kibana/pull/217092","number":217092,"mergeCommit":{"message":"[APM][OTel] Encode service name in the APM URLs (#217092)\n\nCloses #213943\n\n## Summary\n\nThis PR ensures the service name is always encoded in the APM UIs. It's\na follow-up of #215031 and aims to\nfind a better solution to the problem:\n- Add the encoding directly to `formatRequest` as suggested there\n- I saw that there are many places where we use legacy Url builders, so\nI will try to replace them where possible and use\napm router link method where the path is encoded\n([ref](https://github.com/elastic/kibana/blob/7158e0201bf6becb4f2b821fb693bf6ed6365b54/src/platform/packages/shared/kbn-typed-react-router-config/src/create_router.ts#L184-L185))\n- The PR includes the changes to address the issue above:\n - Replaced and removed `LegacyAPMLink`\n- Refactored `useAPMHref` to support encoding (and extracted and test\nthe encoding logic)\n - Example usage: \n - Before: \n ```js\n useAPMHref({\n path: `/services/${serviceName}/.....`,\n persistedFilters,\n });\n ```\n - After:\n ```js\n useAPMHref({\n path: '/services/{serviceName}/.......}',\n pathParams: { serviceName },\n persistedFilters,\n });\n ```\n - Used the APM router link method as much as possible\n\n\n## Testing\n- Run `node scripts/synthtrace trace_with_service_names_with_slashes.ts\n--clean --live --uniqueIds --live`\n- Go to service inventory and click the links:\n\n\nhttps://github.com/user-attachments/assets/fcd4fbfc-4125-4cc8-9b00-53c5f375423f","sha":"f816e7b84f94d9af8d3fffb85dc83512f31c55e9"}},{"branch":"8.x","label":"v8.19.0","branchLabelMappingKey":"^v8.19.0$","isSourceBranch":false,"state":"NOT_CREATED"}]}] BACKPORT-->
Closes elastic#213943 ## Summary This PR ensures the service name is always encoded in the APM UIs. It's a follow-up of elastic#215031 and aims to find a better solution to the problem: - Add the encoding directly to `formatRequest` as suggested there - I saw that there are many places where we use legacy Url builders, so I will try to replace them where possible and use apm router link method where the path is encoded ([ref](https://github.com/elastic/kibana/blob/7158e0201bf6becb4f2b821fb693bf6ed6365b54/src/platform/packages/shared/kbn-typed-react-router-config/src/create_router.ts#L184-L185)) - The PR includes the changes to address the issue above: - Replaced and removed `LegacyAPMLink` - Refactored `useAPMHref` to support encoding (and extracted and test the encoding logic) - Example usage: - Before: ```js useAPMHref({ path: `/services/${serviceName}/.....`, persistedFilters, }); ``` - After: ```js useAPMHref({ path: '/services/{serviceName}/.......}', pathParams: { serviceName }, persistedFilters, }); ``` - Used the APM router link method as much as possible ## Testing - Run `node scripts/synthtrace trace_with_service_names_with_slashes.ts --clean --live --uniqueIds --live` - Go to service inventory and click the links: https://github.com/user-attachments/assets/fcd4fbfc-4125-4cc8-9b00-53c5f375423f
) # Backport This will backport the following commits from `main` to `9.0`: - [[APM][OTel] Encode service name in the APM URLs (#217092)](#217092) <!--- Backport version: 9.6.6 --> ### Questions ? Please refer to the [Backport tool documentation](https://github.com/sorenlouv/backport) <!--BACKPORT [{"author":{"name":"jennypavlova","email":"dzheni.pavlova@elastic.co"},"sourceCommit":{"committedDate":"2025-04-16T15:52:33Z","message":"[APM][OTel] Encode service name in the APM URLs (#217092)\n\nCloses #213943\n\n## Summary\n\nThis PR ensures the service name is always encoded in the APM UIs. It's\na follow-up of #215031 and aims to\nfind a better solution to the problem:\n- Add the encoding directly to `formatRequest` as suggested there\n- I saw that there are many places where we use legacy Url builders, so\nI will try to replace them where possible and use\napm router link method where the path is encoded\n([ref](https://github.com/elastic/kibana/blob/7158e0201bf6becb4f2b821fb693bf6ed6365b54/src/platform/packages/shared/kbn-typed-react-router-config/src/create_router.ts#L184-L185))\n- The PR includes the changes to address the issue above:\n - Replaced and removed `LegacyAPMLink`\n- Refactored `useAPMHref` to support encoding (and extracted and test\nthe encoding logic)\n - Example usage: \n - Before: \n ```js\n useAPMHref({\n path: `/services/${serviceName}/.....`,\n persistedFilters,\n });\n ```\n - After:\n ```js\n useAPMHref({\n path: '/services/{serviceName}/.......}',\n pathParams: { serviceName },\n persistedFilters,\n });\n ```\n - Used the APM router link method as much as possible\n\n\n## Testing\n- Run `node scripts/synthtrace trace_with_service_names_with_slashes.ts\n--clean --live --uniqueIds --live`\n- Go to service inventory and click the links:\n\n\nhttps://github.com/user-attachments/assets/fcd4fbfc-4125-4cc8-9b00-53c5f375423f","sha":"f816e7b84f94d9af8d3fffb85dc83512f31c55e9","branchLabelMapping":{"^v9.1.0$":"main","^v8.19.0$":"8.x","^v(\\d+).(\\d+).\\d+$":"$1.$2"}},"sourcePullRequest":{"labels":["release_note:enhancement","v9.0.0","backport:prev-minor","Team:obs-ux-infra_services","backport:version","v8.18.0","v9.1.0","v8.19.0"],"title":"[APM][OTel] Encode service name in the APM URLs","number":217092,"url":"https://github.com/elastic/kibana/pull/217092","mergeCommit":{"message":"[APM][OTel] Encode service name in the APM URLs (#217092)\n\nCloses #213943\n\n## Summary\n\nThis PR ensures the service name is always encoded in the APM UIs. It's\na follow-up of #215031 and aims to\nfind a better solution to the problem:\n- Add the encoding directly to `formatRequest` as suggested there\n- I saw that there are many places where we use legacy Url builders, so\nI will try to replace them where possible and use\napm router link method where the path is encoded\n([ref](https://github.com/elastic/kibana/blob/7158e0201bf6becb4f2b821fb693bf6ed6365b54/src/platform/packages/shared/kbn-typed-react-router-config/src/create_router.ts#L184-L185))\n- The PR includes the changes to address the issue above:\n - Replaced and removed `LegacyAPMLink`\n- Refactored `useAPMHref` to support encoding (and extracted and test\nthe encoding logic)\n - Example usage: \n - Before: \n ```js\n useAPMHref({\n path: `/services/${serviceName}/.....`,\n persistedFilters,\n });\n ```\n - After:\n ```js\n useAPMHref({\n path: '/services/{serviceName}/.......}',\n pathParams: { serviceName },\n persistedFilters,\n });\n ```\n - Used the APM router link method as much as possible\n\n\n## Testing\n- Run `node scripts/synthtrace trace_with_service_names_with_slashes.ts\n--clean --live --uniqueIds --live`\n- Go to service inventory and click the links:\n\n\nhttps://github.com/user-attachments/assets/fcd4fbfc-4125-4cc8-9b00-53c5f375423f","sha":"f816e7b84f94d9af8d3fffb85dc83512f31c55e9"}},"sourceBranch":"main","suggestedTargetBranches":["9.0","8.18","8.x"],"targetPullRequestStates":[{"branch":"9.0","label":"v9.0.0","branchLabelMappingKey":"^v(\\d+).(\\d+).\\d+$","isSourceBranch":false,"state":"NOT_CREATED"},{"branch":"8.18","label":"v8.18.0","branchLabelMappingKey":"^v(\\d+).(\\d+).\\d+$","isSourceBranch":false,"state":"NOT_CREATED"},{"branch":"main","label":"v9.1.0","branchLabelMappingKey":"^v9.1.0$","isSourceBranch":true,"state":"MERGED","url":"https://github.com/elastic/kibana/pull/217092","number":217092,"mergeCommit":{"message":"[APM][OTel] Encode service name in the APM URLs (#217092)\n\nCloses #213943\n\n## Summary\n\nThis PR ensures the service name is always encoded in the APM UIs. It's\na follow-up of #215031 and aims to\nfind a better solution to the problem:\n- Add the encoding directly to `formatRequest` as suggested there\n- I saw that there are many places where we use legacy Url builders, so\nI will try to replace them where possible and use\napm router link method where the path is encoded\n([ref](https://github.com/elastic/kibana/blob/7158e0201bf6becb4f2b821fb693bf6ed6365b54/src/platform/packages/shared/kbn-typed-react-router-config/src/create_router.ts#L184-L185))\n- The PR includes the changes to address the issue above:\n - Replaced and removed `LegacyAPMLink`\n- Refactored `useAPMHref` to support encoding (and extracted and test\nthe encoding logic)\n - Example usage: \n - Before: \n ```js\n useAPMHref({\n path: `/services/${serviceName}/.....`,\n persistedFilters,\n });\n ```\n - After:\n ```js\n useAPMHref({\n path: '/services/{serviceName}/.......}',\n pathParams: { serviceName },\n persistedFilters,\n });\n ```\n - Used the APM router link method as much as possible\n\n\n## Testing\n- Run `node scripts/synthtrace trace_with_service_names_with_slashes.ts\n--clean --live --uniqueIds --live`\n- Go to service inventory and click the links:\n\n\nhttps://github.com/user-attachments/assets/fcd4fbfc-4125-4cc8-9b00-53c5f375423f","sha":"f816e7b84f94d9af8d3fffb85dc83512f31c55e9"}},{"branch":"8.x","label":"v8.19.0","branchLabelMappingKey":"^v8.19.0$","isSourceBranch":false,"state":"NOT_CREATED"}]}] BACKPORT-->
Closes elastic#213943 ## Summary This PR ensures the service name is always encoded in the APM UIs. It's a follow-up of elastic#215031 and aims to find a better solution to the problem: - Add the encoding directly to `formatRequest` as suggested there - I saw that there are many places where we use legacy Url builders, so I will try to replace them where possible and use apm router link method where the path is encoded ([ref](https://github.com/elastic/kibana/blob/7158e0201bf6becb4f2b821fb693bf6ed6365b54/src/platform/packages/shared/kbn-typed-react-router-config/src/create_router.ts#L184-L185)) - The PR includes the changes to address the issue above: - Replaced and removed `LegacyAPMLink` - Refactored `useAPMHref` to support encoding (and extracted and test the encoding logic) - Example usage: - Before: ```js useAPMHref({ path: `/services/${serviceName}/.....`, persistedFilters, }); ``` - After: ```js useAPMHref({ path: '/services/{serviceName}/.......}', pathParams: { serviceName }, persistedFilters, }); ``` - Used the APM router link method as much as possible ## Testing - Run `node scripts/synthtrace trace_with_service_names_with_slashes.ts --clean --live --uniqueIds --live` - Go to service inventory and click the links: https://github.com/user-attachments/assets/fcd4fbfc-4125-4cc8-9b00-53c5f375423f
Closes #213943
Summary
This PR ensures the service name is always encoded in the APM UIs. It's a follow-up of #215031 and aims to find a better solution to the problem:
formatRequestas suggested thereapm router link method where the path is encoded (ref)
LegacyAPMLinkuseAPMHrefto support encoding (and extracted and test the encoding logic)Testing
node scripts/synthtrace trace_with_service_names_with_slashes.ts --clean --live --uniqueIds --liveapm_links_test.mov