fix: rum agent should work correctly on new platform (#67037) (#67477)

* fix: rum agent should work correctly on new platform

* chore: add IS_KIBANA_DISTRIBUTABLE flag back

Co-authored-by: Elastic Machine <elasticmachine@users.noreply.github.com>

Co-authored-by: Elastic Machine <elasticmachine@users.noreply.github.com>
This commit is contained in:
Vignesh Shanmugam 2020-05-28 10:24:08 +02:00 committed by GitHub
parent 3e3794aaf4
commit d49eb7fd46
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
5 changed files with 75 additions and 49 deletions

View file

@ -479,6 +479,14 @@ module.exports = {
};
```
APM [Real User Monitoring agent](https://www.elastic.co/guide/en/apm/agent/rum-js/current/index.html) is not available in the Kibana distributables,
however the agent can be enabled by setting `ELASTIC_APM_ACTIVE` to `true`.
flags
```
ELASTIC_APM_ACTIVE=true yarn start
// activates both Node.js and RUM agent
```
Once the agent is active, it will trace all incoming HTTP requests to Kibana, monitor for errors, and collect process-level metrics.
The collected data will be sent to the APM Server and is viewable in the APM UI in Kibana.

View file

@ -172,7 +172,7 @@
"deep-freeze-strict": "^1.1.1",
"deepmerge": "^4.2.2",
"del": "^5.1.0",
"elastic-apm-node": "^3.2.0",
"elastic-apm-node": "^3.6.0",
"elasticsearch": "^16.7.0",
"elasticsearch-browser": "^16.7.0",
"execa": "^4.0.0",

View file

@ -33,7 +33,11 @@ const injectedMetadata = JSON.parse(
document.querySelector('kbn-injected-metadata')!.getAttribute('data')!
);
if (process.env.IS_KIBANA_DISTRIBUTABLE !== 'true' && process.env.ELASTIC_APM_ACTIVE === 'true') {
/**
* `apmConfig` would be populated with relavant APM RUM agent
* configuration if server is started with `ELASTIC_APM_ACTIVE=true`
*/
if (process.env.IS_KIBANA_DISTRIBUTABLE !== 'true' && injectedMetadata.vars.apmConfig != null) {
// @ts-ignore
// eslint-disable-next-line @typescript-eslint/no-var-requires
const { init } = require('@elastic/apm-rum');

View file

@ -30,22 +30,21 @@ export function apmInit(config) {
return apmEnabled ? `init(${config})` : '';
}
export function getApmConfig(appMetadata) {
export function getApmConfig(app) {
if (!apmEnabled) {
return {};
return null;
}
/**
* we use the injected app metadata from the server to extract the
* app URL path to be used for page-load transaction
* app id to be used for page-load transaction
*/
const navLink = appMetadata.getNavLink();
const pageUrl = navLink ? navLink.toJSON().url : appMetadata._url;
const appId = app.getId();
const config = {
...getConfig('kibana-frontend'),
...{
active: true,
pageLoadTransactionName: pageUrl,
pageLoadTransactionName: appId,
},
};
/**

View file

@ -11864,10 +11864,10 @@ ejs@^3.0.1:
resolved "https://registry.yarnpkg.com/ejs/-/ejs-3.0.2.tgz#745b01cdcfe38c1c6a2da3bbb2d9957060a31226"
integrity sha512-IncmUpn1yN84hy2shb0POJ80FWrfGNY0cxO9f4v+/sG7qcBvAtVWUA1IdzY/8EYUmOVhoKJVdJjNd3AZcnxOjA==
elastic-apm-http-client@^9.2.0:
version "9.2.1"
resolved "https://registry.yarnpkg.com/elastic-apm-http-client/-/elastic-apm-http-client-9.2.1.tgz#e0e980ceb9975ff770bdbf2f5cdaac39fd70e8e6"
integrity sha512-KythghGrgsozTVZdsUdKED1+IcfN1CEIWS4zL8crsV234Dj9QaffG88E7pu11PZ04HiOSVemAKby21aNRV0kLQ==
elastic-apm-http-client@^9.3.0:
version "9.3.0"
resolved "https://registry.yarnpkg.com/elastic-apm-http-client/-/elastic-apm-http-client-9.3.0.tgz#fcbb3b4f2af209dc304ac496438d381ef19b9b44"
integrity sha512-vxySk7S1oPN7uPcjv0+GLs3Y1cmN7WDVTEHBJixEDg+L6DJMysgxIGst+32Nc0ZmeU5NIjV/Ds9b+6S/yXRdIQ==
dependencies:
breadth-filter "^2.0.0"
container-info "^1.0.1"
@ -11879,10 +11879,10 @@ elastic-apm-http-client@^9.2.0:
stream-chopper "^3.0.1"
unicode-byte-truncate "^1.0.0"
elastic-apm-node@^3.2.0:
version "3.2.0"
resolved "https://registry.yarnpkg.com/elastic-apm-node/-/elastic-apm-node-3.2.0.tgz#a1aa5b255f8867788b38e2854aa331c3a0cc0e22"
integrity sha512-GnoYcge/Xy8/I/0pHF2V9tZU1aRFMqcP7PQ0WXCqdETMUUq7Gmf0fcdzjA8CoDALR+rfsjn4ByF1p7uXoTJoPQ==
elastic-apm-node@^3.6.0:
version "3.6.0"
resolved "https://registry.yarnpkg.com/elastic-apm-node/-/elastic-apm-node-3.6.0.tgz#675980951fbf2fc5606d5a95a8d0b097609ac6eb"
integrity sha512-T1BlWlQ3kYPIjcGaGIszaVYbsiP9aMr8V5gFxzkI7LjY9XelahOnC3u8Mmd6TWLh/QyakDcdt8J6VL3bMuR3WA==
dependencies:
after-all-results "^2.0.0"
async-value-promise "^1.1.1"
@ -11890,8 +11890,9 @@ elastic-apm-node@^3.2.0:
console-log-level "^1.4.1"
cookie "^0.4.0"
core-util-is "^1.0.2"
elastic-apm-http-client "^9.2.0"
end-of-stream "^1.4.1"
elastic-apm-http-client "^9.3.0"
end-of-stream "^1.4.4"
error-stack-parser "^2.0.6"
fast-safe-stringify "^2.0.7"
http-headers "^3.0.2"
http-request-to-url "^1.0.0"
@ -11901,16 +11902,16 @@ elastic-apm-node@^3.2.0:
object-filter-sequence "^1.0.0"
object-identity-map "^1.0.2"
original-url "^1.2.3"
read-pkg-up "^7.0.0"
read-pkg-up "^7.0.1"
redact-secrets "^1.0.0"
relative-microtime "^2.0.0"
require-ancestors "^1.0.0"
require-in-the-middle "^5.0.0"
semver "^6.1.1"
require-in-the-middle "^5.0.3"
semver "^6.3.0"
set-cookie-serde "^1.0.0"
shallow-clone-shim "^1.0.0"
shallow-clone-shim "^2.0.0"
sql-summary "^1.0.1"
stackman "^4.0.0"
stackman "^4.0.1"
traceparent "^1.0.0"
unicode-byte-truncate "^1.0.0"
@ -12204,10 +12205,10 @@ errno@^0.1.1, errno@^0.1.3, errno@~0.1.7:
dependencies:
prr "~1.0.1"
error-callsites@^2.0.2:
version "2.0.2"
resolved "https://registry.yarnpkg.com/error-callsites/-/error-callsites-2.0.2.tgz#55c17a9490a85d72158563f13dc078851ca05b1e"
integrity sha512-s35ELWAKAY9oPqnnfP1V4AnasWV0r2ihaLlpsCGrykZgcR/YKsMXV3q8Ap4Mmp8U90VxJqxKJE5Io0IkkRhJIg==
error-callsites@^2.0.3:
version "2.0.3"
resolved "https://registry.yarnpkg.com/error-callsites/-/error-callsites-2.0.3.tgz#c9278de0d7d4b4861150af295bb92891393ff24a"
integrity sha512-v036z4IEffZFE5kBkV5/F2MzhLnG0vuDyN+VXpzCf4yWXvX/1WJCI0A+TGTr8HWzBfCw5k8gr9rwAo09V+obTA==
error-ex@^1.2.0, error-ex@^1.3.1:
version "1.3.1"
@ -12230,6 +12231,13 @@ error-stack-parser@^2.0.4:
dependencies:
stackframe "^1.1.0"
error-stack-parser@^2.0.6:
version "2.0.6"
resolved "https://registry.yarnpkg.com/error-stack-parser/-/error-stack-parser-2.0.6.tgz#5a99a707bd7a4c58a797902d48d82803ede6aad8"
integrity sha512-d51brTeqC+BHlwF0BhPtcYgF5nlzf9ZZ0ZIUQNZpc9ZB9qw5IJ2diTrBY9jlCJkTLITYPjmiX6OWCwH+fuyNgQ==
dependencies:
stackframe "^1.1.1"
error@^7.0.0, error@^7.0.2:
version "7.0.2"
resolved "https://registry.yarnpkg.com/error/-/error-7.0.2.tgz#a5f75fff4d9926126ddac0ea5dc38e689153cb02"
@ -14478,11 +14486,6 @@ get-own-enumerable-property-symbols@^3.0.0:
resolved "https://registry.yarnpkg.com/get-own-enumerable-property-symbols/-/get-own-enumerable-property-symbols-3.0.0.tgz#b877b49a5c16aefac3655f2ed2ea5b684df8d203"
integrity sha512-CIJYJC4GGF06TakLg8z4GQKvDsx9EMspVxOYih7LerEL/WosUnFIww45CGfxfeKHqlg3twgUrYRT1O3WQqjGCg==
get-own-property-descriptors-polyfill@^1.0.1:
version "1.0.1"
resolved "https://registry.yarnpkg.com/get-own-property-descriptors-polyfill/-/get-own-property-descriptors-polyfill-1.0.1.tgz#e0814a5c32bd9ef387a1de44147f93056a904002"
integrity sha512-S1k3UgpTshd171qaPldcr+BY82277tsNI+ETIZLJ/re6KYQYbV4qRtUw5kmHIZlEy4hZvwdzHFn+8xupNVl4YQ==
get-port@4.2.0:
version "4.2.0"
resolved "https://registry.yarnpkg.com/get-port/-/get-port-4.2.0.tgz#e37368b1e863b7629c43c5a323625f95cf24b119"
@ -24966,10 +24969,10 @@ read-pkg-up@^6.0.0:
read-pkg "^5.1.1"
type-fest "^0.5.0"
read-pkg-up@^7.0.0:
version "7.0.0"
resolved "https://registry.yarnpkg.com/read-pkg-up/-/read-pkg-up-7.0.0.tgz#3f3e53858ec5ae5e6fe14bc479da0a7c98f85ff3"
integrity sha512-t2ODkS/vTTcRlKwZiZsaLGb5iwfx9Urp924aGzVyboU6+7Z2i6eGr/G1Z4mjvwLLQV3uFOBKobNRGM3ux2PD/w==
read-pkg-up@^7.0.1:
version "7.0.1"
resolved "https://registry.yarnpkg.com/read-pkg-up/-/read-pkg-up-7.0.1.tgz#f3a6135758459733ae2b95638056e1854e7ef507"
integrity sha512-zK0TB7Xd6JpCLmlLmufqykGE+/TlOePD6qKClNW7hHDKFh/J7/7gCWGR7joEQEW1bKq3a3yUZSObOoWLFQ4ohg==
dependencies:
find-up "^4.1.0"
read-pkg "^5.2.0"
@ -25819,7 +25822,7 @@ require-from-string@^2.0.1:
resolved "https://registry.yarnpkg.com/require-from-string/-/require-from-string-2.0.2.tgz#89a7fdd938261267318eafe14f9c32e598c36909"
integrity sha512-Xf0nWe6RseziFMu+Ap9biiUbmplq6S9/p+7w7YXP/JBHhrUDDUhwa+vANyubuqfZWTveU//DYVGsDG7RKL/vEw==
require-in-the-middle@^5.0.0, require-in-the-middle@^5.0.2:
require-in-the-middle@^5.0.2:
version "5.0.2"
resolved "https://registry.yarnpkg.com/require-in-the-middle/-/require-in-the-middle-5.0.2.tgz#ce3593007a61583b39ccdcd2c167a2a326c670b2"
integrity sha512-l2r6F9i6t5xp4OE9cw/daB/ooQKHZOOW1AYPADhEvk/Tj/THJDS8gePp76Zyuht6Cj57a0KL+eHK5Dyv7wZnKA==
@ -25828,6 +25831,15 @@ require-in-the-middle@^5.0.0, require-in-the-middle@^5.0.2:
module-details-from-path "^1.0.3"
resolve "^1.12.0"
require-in-the-middle@^5.0.3:
version "5.0.3"
resolved "https://registry.yarnpkg.com/require-in-the-middle/-/require-in-the-middle-5.0.3.tgz#ef8bfd771760db573bc86d1341d8ae411a04c600"
integrity sha512-p/ICV8uMlqC4tjOYabLMxAWCIKa0YUQgZZ6KDM0xgXJNgdGQ1WmL2A07TwmrZw+wi6ITUFKzH5v3n+ENEyXVkA==
dependencies:
debug "^4.1.1"
module-details-from-path "^1.0.3"
resolve "^1.12.0"
require-main-filename@^1.0.1:
version "1.0.1"
resolved "https://registry.yarnpkg.com/require-main-filename/-/require-main-filename-1.0.1.tgz#97f717b69d48784f5f526a6c5aa8ffdda055a4d1"
@ -26681,7 +26693,7 @@ semver@^5.5.1:
resolved "https://registry.yarnpkg.com/semver/-/semver-5.5.1.tgz#7dfdd8814bdb7cabc7be0fb1d734cfb66c940477"
integrity sha512-PqpAxfrEhlSUWge8dwIp4tZnQ25DIOthpiaHNIthsjEFQD6EvqUKUDM7L8O2rShkFccYo1VjJR0coWfNkCubRw==
semver@^6.0.0, semver@^6.1.1, semver@^6.1.2, semver@^6.2.0, semver@^6.3.0, semver@~6.3.0:
semver@^6.0.0, semver@^6.1.2, semver@^6.2.0, semver@^6.3.0, semver@~6.3.0:
version "6.3.0"
resolved "https://registry.yarnpkg.com/semver/-/semver-6.3.0.tgz#ee0a64c8af5e8ceea67687b133761e1becbd1d3d"
integrity sha512-b39TBaTSfV6yBrapU89p5fKekE2m/NwnDocOVruQFS1/veMgdzuPcnOM34M6CwxW8jH/lxEa5rBoDeUwu5HHTw==
@ -26873,12 +26885,10 @@ sha.js@^2.4.0, sha.js@^2.4.8:
inherits "^2.0.1"
safe-buffer "^5.0.1"
shallow-clone-shim@^1.0.0:
version "1.1.0"
resolved "https://registry.yarnpkg.com/shallow-clone-shim/-/shallow-clone-shim-1.1.0.tgz#c1048ba9167f313f4f4c019ff3f0a40626322960"
integrity sha512-ZY+sf7fm8CDFecoL/IntHFhqu8Ll+elOcuXO5WlVgSfnpxuUMni/Y9sB9gMf85nWsVDM+CfMJpLBwiN/lOO5/w==
dependencies:
get-own-property-descriptors-polyfill "^1.0.1"
shallow-clone-shim@^2.0.0:
version "2.0.0"
resolved "https://registry.yarnpkg.com/shallow-clone-shim/-/shallow-clone-shim-2.0.0.tgz#b62bf55aed79f4c1430ea1dc4d293a193f52cf91"
integrity sha512-YRNymdiL3KGOoS67d73TEmk4tdPTO9GSMCoiphQsTcC9EtC+AOmMPjkyBkRoCJfW9ASsaZw1craaiw1dPN2D3Q==
shallow-clone@^0.1.2:
version "0.1.2"
@ -27595,15 +27605,20 @@ stackframe@^1.1.0:
resolved "https://registry.yarnpkg.com/stackframe/-/stackframe-1.1.0.tgz#e3fc2eb912259479c9822f7d1f1ff365bd5cbc83"
integrity sha512-Vx6W1Yvy+AM1R/ckVwcHQHV147pTPBKWCRLrXMuPrFVfvBUc3os7PR1QLIWCMhPpRg5eX9ojzbQIMLGBwyLjqg==
stackman@^4.0.0:
version "4.0.0"
resolved "https://registry.yarnpkg.com/stackman/-/stackman-4.0.0.tgz#3ccdc8682fee36373ed2492dc3dad546eb44647d"
integrity sha512-JHhUxla4KkXVzPRJoBdIolVbXWBv2qIUe/XdsH9/fkXCgsIdFhCny91tqy9Zld66ROj+dZ0E54l/I3vL3y3Uiw==
stackframe@^1.1.1:
version "1.1.1"
resolved "https://registry.yarnpkg.com/stackframe/-/stackframe-1.1.1.tgz#ffef0a3318b1b60c3b58564989aca5660729ec71"
integrity sha512-0PlYhdKh6AfFxRyK/v+6/k+/mMfyiEBbTM5L94D0ZytQnJ166wuwoTYLHFWGbs2dpA8Rgq763KGWmN1EQEYHRQ==
stackman@^4.0.1:
version "4.0.1"
resolved "https://registry.yarnpkg.com/stackman/-/stackman-4.0.1.tgz#b5709446f078db9b9dadbb317f296224d9a35b5b"
integrity sha512-lntIge3BFEElgvpZT2ld5f4U+mF84fRtJ8vA3ymUVx1euVx43ZMkd09+5RWW4FmvYDFhZwPh1gvtdsdnJyF4Fg==
dependencies:
after-all-results "^2.0.0"
async-cache "^1.1.0"
debug "^4.1.1"
error-callsites "^2.0.2"
error-callsites "^2.0.3"
load-source-map "^1.0.0"
stacktrace-gps@^3.0.3: