Skip to content

Comments

[8.18] [APM][OTel] Encode service name in the APM URLs (#217092)#218477

Merged
jennypavlova merged 1 commit intoelastic:8.18from
jennypavlova:backport/8.18/pr-217092
Apr 16, 2025
Merged

[8.18] [APM][OTel] Encode service name in the APM URLs (#217092)#218477
jennypavlova merged 1 commit intoelastic:8.18from
jennypavlova:backport/8.18/pr-217092

Conversation

@jennypavlova
Copy link
Member

Backport

This will backport the following commits from main to 8.18:

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
@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 17:09
@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)

@jennypavlova jennypavlova merged commit 906ff07 into elastic:8.18 Apr 16, 2025
13 checks passed
@elasticmachine
Copy link
Contributor

💚 Build Succeeded

Metrics [docs]

Module Count

Fewer modules leads to a faster build time

id before after diff
aiAssistantManagementSelection 66 67 +1
apm 1679 1681 +2
inventory 223 224 +1
observabilityAIAssistantApp 493 494 +1
observabilityAiAssistantManagement 370 371 +1
profiling 291 292 +1
streamsApp 270 271 +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 96.6KB 96.6KB +67.0B
apm 2.6MB 2.6MB +1.4KB
inventory 211.7KB 211.8KB +67.0B
observabilityAIAssistantApp 250.1KB 250.1KB +67.0B
observabilityAiAssistantManagement 107.1KB 107.2KB +67.0B
observabilityOnboarding 271.6KB 271.7KB +80.0B
profiling 400.9KB 401.0KB +75.0B
streamsApp 258.7KB 258.8KB +67.0B
uptime 414.3KB 414.3KB +20.0B
ux 169.0KB 169.1KB +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 +40.0B
investigateApp 11.5KB 11.5KB +40.0B
observabilityAIAssistant 38.5KB 38.5KB +40.0B
observabilityShared 82.6KB 82.6KB +20.0B
slo 41.5KB 41.5KB +40.0B
streams 6.3KB 6.3KB +40.0B
total +260.0B
Unknown metric groups

API count

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

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