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

Instrument Kibana with APM RUM agent #44281

Merged
merged 12 commits into from
Dec 18, 2019
Merged

Instrument Kibana with APM RUM agent #44281

merged 12 commits into from
Dec 18, 2019

Conversation

vigneshshanmugam
Copy link
Member

@vigneshshanmugam vigneshshanmugam commented Aug 28, 2019

Summary

Instruments Kibana and other X-Pack Plugins(APM UI) with Elastic APM RUM JS agent. The agent is code is bundled on the client side and initialised based on ELASTIC_APM_ACTIVE env flag.

For now, this is meant as a useful internal tool for Kibana developers and will not be distributed with
the Kibana distrubution.

Checklist

Use strikethroughs to remove checklist items you don't feel are applicable to this PR.

For maintainers

@vigneshshanmugam vigneshshanmugam requested review from a team as code owners August 28, 2019 16:05
package.json Outdated Show resolved Hide resolved
@sorenlouv sorenlouv added the release_note:skip Skip the PR/issue when compiling release notes label Aug 28, 2019
@vigneshshanmugam vigneshshanmugam added the WIP Work in progress label Aug 28, 2019
@spalger
Copy link
Contributor

spalger commented Aug 28, 2019

retest

@elasticmachine
Copy link
Contributor

💚 Build Succeeded

@elasticmachine
Copy link
Contributor

💚 Build Succeeded

@vigneshshanmugam vigneshshanmugam requested a review from a team as a code owner August 29, 2019 15:40
@elasticmachine
Copy link
Contributor

💔 Build Failed

@spalger
Copy link
Contributor

spalger commented Aug 29, 2019

Looks like the xpack functional tests are failing because Cannot read property 'toJSON' of undefined

Copy link
Contributor

@spalger spalger left a comment

Choose a reason for hiding this comment

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

Please request review from @elastic/kibana-operations once the tests are passing

@vigneshshanmugam
Copy link
Member Author

@spalger Sure, would have to wait for Node agent PR to get merged before we merge this one.

@elasticmachine
Copy link
Contributor

💚 Build Succeeded

@vigneshshanmugam vigneshshanmugam self-assigned this Sep 4, 2019
@elasticmachine
Copy link
Contributor

💔 Build Failed

@elasticmachine
Copy link
Contributor

💔 Build Failed

@elasticmachine
Copy link
Contributor

💔 Build Failed

@vigneshshanmugam
Copy link
Member Author

@elastic/kibana-operations Can i get review on this PR? Thanks in advance.

@watson
Copy link
Contributor

watson commented Dec 9, 2019

@vigneshshanmugam What's the idea behind the isKibanaDistributable flag as opposed to only looking at the active config option? Is that as to have an extra guard against accidentally using this in a production environment? If this is a requirement, did you consider also letting the Node.js agent take this into account?

@vigneshshanmugam
Copy link
Member Author

@watson It's an extra guard and considered it only for RUM at the moment, since we don't want to ship RUM agent JavaScript bundle to the client even if the flag is set to true by accident. Wont be applicable for the Node.js agent since its we require it anyway in the server.

Copy link
Contributor

@watson watson left a comment

Choose a reason for hiding this comment

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

Now that you no longer use the configFile config option, but manually load the config file. You could make the code a little bit simpler by refactoring the way src/apm.js loads config/apm.js which in turn loads config/apm.dev.js. You could just move the logic of config/apm.js into the getConfig function of src/apm.js and so there's only a need for one config file: config/apm.dev.js. What do you think of that?

src/apm.js Outdated Show resolved Hide resolved
src/apm.js Outdated Show resolved Hide resolved
@vigneshshanmugam
Copy link
Member Author

I agree with you that it would be simpler and we won't have two config files, But would it be easier for the devs to look at APM specific config inside config/apm.js instead of where the config is loaded? Personally I am okay with removing config/apm.js and move the logic inside src/apm.js

@watson
Copy link
Contributor

watson commented Dec 10, 2019

I don't think there's a big need for people to know the default config current set inside the config/apm.js file. If they are very curious for some reason, src/apm.js isn't hard to find anyway. So feel free to remove config/apm.js 👍

@mistic
Copy link
Member

mistic commented Dec 17, 2019

@elasticmachine merge upstream

1 similar comment
@mistic
Copy link
Member

mistic commented Dec 17, 2019

@elasticmachine merge upstream

@spalger
Copy link
Contributor

spalger commented Dec 17, 2019

@elasticmachine merge upstream

Copy link
Contributor

@watson watson left a comment

Choose a reason for hiding this comment

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

I haven't run this locally, but looking at the code, it all seems perfect 👍

Copy link
Contributor

@pgayvallet pgayvallet left a comment

Choose a reason for hiding this comment

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

LGTM for platform changes

Could you please open an issue for the integration in new platform and ping the team on it?

Comment on lines +286 to +287

apm: getApmConfig(legacyMetadata.app),
Copy link
Contributor

Choose a reason for hiding this comment

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

ping @eliperelman Will need to reintegrate this in renderer PR

Comment on lines +83 to +85
apm: {
[key: string]: unknown;
};
Copy link
Contributor

Choose a reason for hiding this comment

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

Quick note on this: injectedMetadata are more or less already deprecated and might be removed at some point in NP. You have to keep in mind that you need to migrate this to an asynchronous way to access and use this data at some point.

* In Kibana app, this logic would run after the boostrap js files gets
* downloaded and get associated with the page-load transaction
*/
$rootScope.$on('$routeChangeStart', (_, nextRoute) => {
Copy link
Contributor

Choose a reason for hiding this comment

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

in NP this will probably need to be hooked into ApplicationService.navigateToApp, However NP does not yet exposes that kind of hooks

@vigneshshanmugam
Copy link
Member Author

@pgayvallet Thanks for the review,I have opened an issue and added the label for the same #53466

@vigneshshanmugam vigneshshanmugam merged commit 254b18c into elastic:master Dec 18, 2019
@vigneshshanmugam vigneshshanmugam deleted the apm-rum branch December 18, 2019 11:16
smith pushed a commit to smith/kibana that referenced this pull request Apr 3, 2020
* 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
smith pushed a commit to smith/kibana that referenced this pull request Apr 3, 2020
* 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
smith added a commit that referenced this pull request Apr 3, 2020
* 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>
smith added a commit that referenced this pull request Apr 6, 2020
* 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

* Suggested fixes

Co-authored-by: Vignesh Shanmugam <vignesh.shanmugam22@gmail.com>
Co-authored-by: Elastic Machine <elasticmachine@users.noreply.github.com>
@kibanamachine
Copy link
Contributor

💔 Build Failed

History

To update your PR or re-run it, just comment with:
@elasticmachine merge upstream

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
release_note:skip Skip the PR/issue when compiling release notes v7.6.0 v8.0.0
Projects
None yet
Development

Successfully merging this pull request may close these issues.

9 participants