Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Merged
merged 5 commits into from
May 25, 2020
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -490,6 +490,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.

Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,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",
Expand Down
6 changes: 5 additions & 1 deletion src/core/public/entry_point.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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') {
/**
* If APM RUM agent is enabled while starting the server,
* `apmConfig` would be populated with relavant configuration
*/
if (injectedMetadata.vars.apmConfig != null) {
vigneshshanmugam marked this conversation as resolved.
Show resolved Hide resolved
// @ts-ignore
// eslint-disable-next-line @typescript-eslint/no-var-requires
const { init } = require('@elastic/apm-rum');
Expand Down
11 changes: 5 additions & 6 deletions src/legacy/ui/apm/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In the NP this will always be core, so I'm not sure that's very useful?

Copy link
Member Author

@vigneshshanmugam vigneshshanmugam May 19, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, I have left a comment in the description on why its like this for now.

Since we don't have a nice way to get the currently navigated app after the Kibana is bootstrapped, we will use the app.getId() which would return core for NP and consolidate all transactions under core. Issue to track this #53466

I found other way to solve this was to subscribing to currentAppId and updating the transaction. But that wont work as well since it happens after the kibana app is bootstrapped. I guess we need a better way to group them right from the time the agent is initialised on. Like from the server before the agent is itself initialised, need access to the current app. Do you have any other ideas?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Perhaps add a comment about this in the code as well.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sure, I will add it on my upcoming PR which I am experimenting with using window.location.href since we are using it only for dev environment and can use it till we get a solution in NP.


const config = {
...getConfig('kibana-frontend'),
...{
active: true,
pageLoadTransactionName: pageUrl,
pageLoadTransactionName: appId,
},
};
/**
Expand Down
97 changes: 56 additions & 41 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -11907,10 +11907,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"
Expand All @@ -11922,19 +11922,20 @@ 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"
basic-auth "^2.0.1"
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"
Expand All @@ -11944,16 +11945,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"

Expand Down Expand Up @@ -12247,10 +12248,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"
Expand All @@ -12273,6 +12274,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"
Expand Down Expand Up @@ -14521,11 +14529,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==

[email protected]:
version "4.2.0"
resolved "https://registry.yarnpkg.com/get-port/-/get-port-4.2.0.tgz#e37368b1e863b7629c43c5a323625f95cf24b119"
Expand Down Expand Up @@ -25109,10 +25112,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"
Expand Down Expand Up @@ -25962,7 +25965,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==
Expand All @@ -25971,6 +25974,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"
Expand Down Expand Up @@ -26846,7 +26858,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==
Expand Down Expand Up @@ -27033,12 +27045,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"
Expand Down Expand Up @@ -27755,15 +27765,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:
Expand Down