Skip to content

[9.0] [APM][OTel] Encode service name in the APM URLs (#217092)#218474

Merged
jennypavlova merged 3 commits intoelastic:9.0from
jennypavlova:backport/9.0/pr-217092
Apr 17, 2025
Merged

[9.0] [APM][OTel] Encode service name in the APM URLs (#217092)#218474
jennypavlova merged 3 commits intoelastic:9.0from
jennypavlova:backport/9.0/pr-217092

Conversation

@jennypavlova
Copy link
Member

Backport

This will backport the following commits from main to 9.0:

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
@jennypavlova jennypavlova added the backport This PR is a backport of another PR label Apr 16, 2025
@jennypavlova jennypavlova enabled auto-merge (squash) April 16, 2025 16:54
@botelastic botelastic bot added the Team:obs-ux-infra_services - DEPRECATED DEPRECATED - Use Team:obs-presentation. label Apr 16, 2025
@elasticmachine
Copy link
Contributor

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

@elasticmachine
Copy link
Contributor

elasticmachine commented Apr 16, 2025

💔 Build Failed

Failed CI Steps

Test Failures

  • [job] [logs] FTR Configs #30 / console app console context menu should open documentation when open documentation button is clicked
  • [job] [logs] FTR Configs #30 / console app console context menu should open documentation when open documentation button is clicked
  • [job] [logs] FTR Configs #30 / console app console context menu should open documentation when open documentation button is clicked

Metrics [docs]

Module Count

Fewer modules leads to a faster build time

id before after diff
aiAssistantManagementSelection 66 67 +1
apm 1647 1649 +2
inventory 225 226 +1
observabilityAIAssistantApp 494 495 +1
observabilityAiAssistantManagement 370 371 +1
profiling 290 291 +1
streamsApp 276 277 +1
ux 182 183 +1
total +9

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/typed-react-router-config 92 95 +3

Async chunks

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

id before after diff
aiAssistantManagementSelection 93.0KB 93.0KB +67.0B
apm 2.4MB 2.4MB +1.4KB
inventory 212.2KB 212.3KB +66.0B
observabilityAIAssistantApp 249.9KB 249.9KB +67.0B
observabilityAiAssistantManagement 107.1KB 107.2KB +67.0B
observabilityOnboarding 262.0KB 262.1KB +80.0B
profiling 401.2KB 401.3KB +75.0B
streamsApp 259.2KB 259.3KB +67.0B
uptime 413.6KB 413.7KB +20.0B
ux 170.1KB 170.2KB +107.0B
total +2.0KB

Page load bundle

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

id before after diff
entityManager 8.2KB 8.2KB +40.0B
inventory 13.4KB 13.5KB +39.0B
investigateApp 11.5KB 11.5KB +40.0B
observabilityAIAssistant 38.0KB 38.0KB +40.0B
observabilityShared 82.4KB 82.4KB +20.0B
slo 41.5KB 41.5KB +40.0B
streams 6.3KB 6.3KB +40.0B
total +259.0B
Unknown metric groups

API count

id before after diff
@kbn/typed-react-router-config 92 95 +3

History

@jennypavlova jennypavlova merged commit 4b50e48 into elastic:9.0 Apr 17, 2025
9 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

backport This PR is a backport of another PR Team:obs-ux-infra_services - DEPRECATED DEPRECATED - Use Team:obs-presentation.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants