-
Notifications
You must be signed in to change notification settings - Fork 8.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
* Instrument Kibana with APM RUM agent (#44281) * Instrument Kibana with APM RUM agent * make route-change transaction work with properl url * extract page-load transaction url from app link * check if app is hidden and set active:false * make distributed tracing work and merge config * remove config/apm.js and address review * address review comments * add apm.js to build tassks * move apm from dev to src * add @types/hoist-non-react-statics which is required by react rum * apply changes correctly from master * Remove unneded changes * fix apminit Co-authored-by: Vignesh Shanmugam <vignesh.shanmugam22@gmail.com>
- Loading branch information
1 parent
cd60282
commit b602bed
Showing
13 changed files
with
219 additions
and
102 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
/* | ||
* Licensed to Elasticsearch B.V. under one or more contributor | ||
* license agreements. See the NOTICE file distributed with | ||
* this work for additional information regarding copyright | ||
* ownership. Elasticsearch B.V. licenses this file to you under | ||
* the Apache License, Version 2.0 (the "License"); you may | ||
* not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, | ||
* software distributed under the License is distributed on an | ||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | ||
* KIND, either express or implied. See the License for the | ||
* specific language governing permissions and limitations | ||
* under the License. | ||
*/ | ||
|
||
import { getConfig, isKibanaDistributable } from '../../../apm'; | ||
import agent from 'elastic-apm-node'; | ||
|
||
const apmEnabled = !isKibanaDistributable && process.env.ELASTIC_APM_ACTIVE === 'true'; | ||
|
||
export function apmImport() { | ||
return apmEnabled ? 'import { init } from "@elastic/apm-rum"' : ''; | ||
} | ||
|
||
export function apmInit(config) { | ||
return apmEnabled ? `init(${config})` : ''; | ||
} | ||
|
||
export function getApmConfig(appMetadata) { | ||
if (!apmEnabled) { | ||
return {}; | ||
} | ||
/** | ||
* we use the injected app metadata from the server to extract the | ||
* app URL path to be used for page-load transaction | ||
*/ | ||
const navLink = appMetadata.getNavLink(); | ||
const pageUrl = navLink ? navLink.toJSON().url : appMetadata._url; | ||
|
||
const config = { | ||
...getConfig('kibana-frontend'), | ||
...{ | ||
active: true, | ||
pageLoadTransactionName: pageUrl, | ||
}, | ||
}; | ||
/** | ||
* Get current active backend transaction to make distrubuted tracing | ||
* work for rendering the app | ||
*/ | ||
const backendTransaction = agent.currentTransaction; | ||
|
||
if (backendTransaction) { | ||
const { sampled, traceId } = backendTransaction; | ||
return { | ||
...config, | ||
...{ | ||
pageLoadTraceId: traceId, | ||
pageLoadSampled: sampled, | ||
pageLoadSpanId: backendTransaction.ensureParentId(), | ||
}, | ||
}; | ||
} | ||
return config; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
/* | ||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
* or more contributor license agreements. Licensed under the Elastic License; | ||
* you may not use this file except in compliance with the Elastic License. | ||
*/ | ||
|
||
declare module '@elastic/apm-rum-react'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.