Skip to content

Comments

[8.x] [APM][OTel] Encode service name in the APM URLs (#217092)#218475

Merged
jennypavlova merged 2 commits intoelastic:8.xfrom
jennypavlova:backport/8.x/pr-217092
Apr 16, 2025
Merged

[8.x] [APM][OTel] Encode service name in the APM URLs (#217092)#218475
jennypavlova merged 2 commits intoelastic:8.xfrom
jennypavlova:backport/8.x/pr-217092

Conversation

@jennypavlova
Copy link
Member

Backport

This will backport the following commits from main to 8.x:

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/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
@botelastic botelastic bot added the Team:obs-ux-infra_services - DEPRECATED DEPRECATED - Use Team:obs-presentation. label Apr 16, 2025
@jennypavlova jennypavlova enabled auto-merge (squash) April 16, 2025 17:03
@elasticmachine
Copy link
Contributor

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

@jennypavlova jennypavlova merged commit 95e63f8 into elastic:8.x Apr 16, 2025
8 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 64 65 +1
apm 1918 1920 +2
inventory 234 235 +1
observabilityAIAssistantApp 423 424 +1
observabilityAiAssistantManagement 383 384 +1
profiling 290 291 +1
streamsApp 442 443 +1
ux 180 181 +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 76.4KB 76.5KB +67.0B
apm 2.7MB 2.7MB +1.4KB
inventory 191.8KB 191.9KB +66.0B
observabilityAIAssistantApp 244.5KB 244.6KB +67.0B
observabilityAiAssistantManagement 86.8KB 86.8KB +67.0B
observabilityOnboarding 261.9KB 262.0KB +80.0B
profiling 380.6KB 380.7KB +75.0B
streamsApp 406.7KB 406.7KB +75.0B
uptime 504.2KB 504.2KB +20.0B
ux 148.6KB 148.7KB +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.3KB 8.3KB +40.0B
inventory 13.5KB 13.6KB +39.0B
investigateApp 11.6KB 11.7KB +40.0B
observabilityAIAssistant 38.4KB 38.4KB +40.0B
observabilityShared 82.6KB 82.6KB +20.0B
slo 42.5KB 42.5KB +40.0B
streams 6.6KB 6.6KB +40.0B
total +259.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