-
Notifications
You must be signed in to change notification settings - Fork 135
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): use single instance of apm across all packages #796
Conversation
💚 Build SucceededExpand to view the summary
Build stats
Test stats 🧪
Steps errorsExpand to view the steps failures
|
Codecov Report
@@ Coverage Diff @@
## master #796 +/- ##
==========================================
+ Coverage 92.13% 92.66% +0.52%
==========================================
Files 50 50
Lines 2289 2290 +1
Branches 457 456 -1
==========================================
+ Hits 2109 2122 +13
+ Misses 177 165 -12
Partials 3 3
|
@jahtalab Can i get your review before I do the rebase, that wont have a huge change as it would be simply point to rum-core. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@vigneshshanmugam , I think the approach taken here is fine but IMO, it doesn't address the core issue which is the fact that the agent is loaded in the page twice, we need to fix that! One idea is to stop having dependency from the framework specific packages to the base package and instead use window.elasticApm
This is a common problem and we have to deal with it as you said. There are couple of options. 1. Exposing
|
a42cada
to
7484673
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks @vigneshshanmugam for opening the issue, we should address the core issue to prevent this. But we can merge this one as a quick fix.
* Use a single instance of ApmBase across all instance of the agent | ||
* including the instanes used in framework specific integrations | ||
*/ | ||
function getApmBase() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: Is there any reason for having a function here instead of just having on the top level?
It seems to me the logic would be simpler if we remove this function.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just a personal preference. It looked a bit cleaner than having to reassign apmBase
like this
let apmBase
if (isBrowser && window.elasticApm) {
apmBase = window.elasticApm
} else {
const enabled = bootstrap()
const serviceFactory = createServiceFactory()
apmBase = new ApmBase(serviceFactory, !enabled)
if (isBrowser) {
window.elasticApm = apmBase
}
}
export {apmBase}
* fix(rum): use single instance of apm across all packages * chore: address review and add test
* upstream/master: (23 commits) feat(rum-core): capture XHR/Fetch spans using resource timing (elastic#825) docs: update set-up.asciidoc (elastic#814) chore: remove compressed size gh workflow (elastic#828) feat: use page visibilityState for browser responsiveness check (elastic#813) ci(jenkins): report bundlesize as a GitHub comment (elastic#826) docs: release notes for 5.2.1 (elastic#824) chore(release): publish fix(rum-core): protect aganist buggy navigation timing data (elastic#819) fix(rum-core): protect aganist buggy navigation timing data (elastic#819) chore(rum-core): use startTime for LCP marks (elastic#815) fix(rum-core): capture tbt after all task entries are observed (elastic#803) feat(rum-react): use correct path when route is path array (elastic#800) ci: enable benchmark on a PR basis (elastic#812) ci: use dockerLogs step (elastic#810) fix: env var invalid type (elastic#809) fix: workarount for elastic/beats#18858 (elastic#807) docs: add release notes for 5.2.0 (elastic#801) chore(release): publish fix(rum-core): consider user defined type of high precedence (elastic#798) fix(rum): use single instance of apm across all packages (elastic#796) ...
* fix(rum): use single instance of apm across all packages * chore: address review and add test
elasticApm
if its present on window #791apm
instance is singletonwindow.elasticApm
multiple times