Skip to content

Commit

Permalink
[8.7] [APM] Fix missing path in route change transactions (#151333)…
Browse files Browse the repository at this point in the history
… (#151712)

# Backport

This will backport the following commits from `main` to `8.7`:
- [[APM] Fix missing `path` in `route change` transactions
(#151333)](#151333)

<!--- Backport version: 8.9.7 -->

### Questions ?
Please refer to the [Backport tool
documentation](https://github.com/sqren/backport)

<!--BACKPORT [{"author":{"name":"Søren
Louv-Jansen","email":"[email protected]"},"sourceCommit":{"committedDate":"2023-02-21T14:04:05Z","message":"[APM]
Fix missing `path` in `route change` transactions (#151333)\n\nThis
improves APM instrumentation in the APM app so
`route-change`\r\ntransactions are captured with a more specific name
than `apm unknown`\r\n\r\n#
Before\r\n\r\n![image](https://user-images.githubusercontent.com/209966/219080268-23726882-ac58-4cbc-baa0-a9174fab83c0.png)\r\n\r\n#
After\r\n\r\n\r\n![image](https://user-images.githubusercontent.com/209966/219080283-bb0438d3-ce82-4fc5-9ac1-0eb40a88d44a.png)","sha":"38f26e7c433dacf22fd0f7994467c9d6eea30a9a","branchLabelMapping":{"^v8.8.0$":"main","^v(\\d+).(\\d+).\\d+$":"$1.$2"}},"sourcePullRequest":{"labels":["Team:APM","release_note:skip","v8.7.0","v8.8.0"],"number":151333,"url":"https://github.com/elastic/kibana/pull/151333","mergeCommit":{"message":"[APM]
Fix missing `path` in `route change` transactions (#151333)\n\nThis
improves APM instrumentation in the APM app so
`route-change`\r\ntransactions are captured with a more specific name
than `apm unknown`\r\n\r\n#
Before\r\n\r\n![image](https://user-images.githubusercontent.com/209966/219080268-23726882-ac58-4cbc-baa0-a9174fab83c0.png)\r\n\r\n#
After\r\n\r\n\r\n![image](https://user-images.githubusercontent.com/209966/219080283-bb0438d3-ce82-4fc5-9ac1-0eb40a88d44a.png)","sha":"38f26e7c433dacf22fd0f7994467c9d6eea30a9a"}},"sourceBranch":"main","suggestedTargetBranches":["8.7"],"targetPullRequestStates":[{"branch":"8.7","label":"v8.7.0","labelRegex":"^v(\\d+).(\\d+).\\d+$","isSourceBranch":false,"state":"NOT_CREATED"},{"branch":"main","label":"v8.8.0","labelRegex":"^v8.8.0$","isSourceBranch":true,"state":"MERGED","url":"https://github.com/elastic/kibana/pull/151333","number":151333,"mergeCommit":{"message":"[APM]
Fix missing `path` in `route change` transactions (#151333)\n\nThis
improves APM instrumentation in the APM app so
`route-change`\r\ntransactions are captured with a more specific name
than `apm unknown`\r\n\r\n#
Before\r\n\r\n![image](https://user-images.githubusercontent.com/209966/219080268-23726882-ac58-4cbc-baa0-a9174fab83c0.png)\r\n\r\n#
After\r\n\r\n\r\n![image](https://user-images.githubusercontent.com/209966/219080283-bb0438d3-ce82-4fc5-9ac1-0eb40a88d44a.png)","sha":"38f26e7c433dacf22fd0f7994467c9d6eea30a9a"}}]}]
BACKPORT-->

Co-authored-by: Søren Louv-Jansen <[email protected]>
  • Loading branch information
kibanamachine and sorenlouv authored Feb 21, 2023
1 parent a53908f commit 272471d
Show file tree
Hide file tree
Showing 2 changed files with 48 additions and 17 deletions.
37 changes: 20 additions & 17 deletions x-pack/plugins/apm/public/components/routing/app_root/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ import { ApmErrorBoundary } from '../apm_error_boundary';
import { apmRouter } from '../apm_route_config';
import { RedirectDependenciesToDependenciesInventory } from './redirect_dependencies_to_dependencies_inventory';
import { TrackPageview } from '../track_pageview';
import { UpdateExecutionContextOnRouteChange } from './update_execution_context_on_route_change';

const storage = new Storage(localStorage);

Expand Down Expand Up @@ -73,24 +74,26 @@ export function ApmAppRoot({
<RedirectWithDefaultDateRange>
<RedirectWithOffset>
<TrackPageview>
<BreadcrumbsContextProvider>
<UrlParamsProvider>
<LicenseProvider>
<AnomalyDetectionJobsContextProvider>
<InspectorContextProvider>
<ApmThemeProvider>
<MountApmHeaderActionMenu />
<UpdateExecutionContextOnRouteChange>
<BreadcrumbsContextProvider>
<UrlParamsProvider>
<LicenseProvider>
<AnomalyDetectionJobsContextProvider>
<InspectorContextProvider>
<ApmThemeProvider>
<MountApmHeaderActionMenu />

<Route
component={ScrollToTopOnPathChange}
/>
<RouteRenderer />
</ApmThemeProvider>
</InspectorContextProvider>
</AnomalyDetectionJobsContextProvider>
</LicenseProvider>
</UrlParamsProvider>
</BreadcrumbsContextProvider>
<Route
component={ScrollToTopOnPathChange}
/>
<RouteRenderer />
</ApmThemeProvider>
</InspectorContextProvider>
</AnomalyDetectionJobsContextProvider>
</LicenseProvider>
</UrlParamsProvider>
</BreadcrumbsContextProvider>
</UpdateExecutionContextOnRouteChange>
</TrackPageview>
</RedirectWithOffset>
</RedirectWithDefaultDateRange>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
/*
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
* or more contributor license agreements. Licensed under the Elastic License
* 2.0; you may not use this file except in compliance with the Elastic License
* 2.0.
*/

import { useExecutionContext } from '@kbn/kibana-react-plugin/public';
import { useMatchRoutes } from '@kbn/typed-react-router-config';
import { last } from 'lodash';
import { useApmPluginContext } from '../../../context/apm_plugin/use_apm_plugin_context';

export function UpdateExecutionContextOnRouteChange({
children,
}: {
children: React.ReactElement;
}) {
const { core } = useApmPluginContext();
const lastMatch = last(useMatchRoutes());

useExecutionContext(core.executionContext, {
type: 'application',
name: 'apm',
page: lastMatch?.match?.path,
});

return children;
}

0 comments on commit 272471d

Please sign in to comment.