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 by resolved path, include package versions in events #50

Merged
merged 3 commits into from
Apr 11, 2018

Conversation

toshok
Copy link
Contributor

@toshok toshok commented Apr 9, 2018

A couple of fixes:

  1. cache our instrumented packages by their resolved path, not by their request. This means that if you have two versions of express in the same app (vanishingly unlikely, but...) you end up with two instrumented versions - but you end up with those two versions of express, not the first one to be instrumented/cached.
  2. pull in the package.json files for packages as we instrument them, then pass the packageVersion down into the magic. Include that version in all events the magic sends. This will let us do nice things like COUNT/P99(durationMs) broken down by express version 🔥

@eanakashima
Copy link
Member

@ChristopherBiscardi you have bandwidth to review this one? I can if not, but I feel like you might have more useful background context.

Copy link

@ChristopherBiscardi ChristopherBiscardi left a comment

Choose a reason for hiding this comment

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

Logic looks good. Nice use of Set.

@@ -4,7 +4,7 @@ const child_process = require("child_process"),
tracker = require("../async_tracker"),
event = require("../event");

instrumentChildProcess(child_process);
instrumentChildProcess(child_process, {});

Choose a reason for hiding this comment

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

would be nice to set this second arg as a default arg instead of passing it in like:

let instrumentChildProcess = (child_process, opts = {}) => {

but the amount of code in that fn is pretty low, so maybe:

  shimmer.wrap(child_process, "execFile", wrapExecLike("execFile", opts.packageVersion || {}));

Copy link
Contributor Author

Choose a reason for hiding this comment

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

yeah, I think at some point in the past they were optional, but then I moved the default up to instrumentLoad and removed it from the individual instrumentations (this was before there were tests which poked at the instrumentations directly.)

👍

@@ -4,7 +4,7 @@ const http = require("http"),
tracker = require("../async_tracker"),
event = require("../event");

instrumentHttp(http);
instrumentHttp(http, {});

Choose a reason for hiding this comment

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

same default value comment here. Would be nice to accept undefined in the second arg and default to {}

lib/magic.js Outdated
// arguments are the same as to require.resolve.
function getPackageVersion(request, options) {
// treat `require("react-dom/server")` like `require("react-dom")` here
if (request.indexOf("/") !== -1) {

Choose a reason for hiding this comment

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

includes is supported back to node 6 (and node 4 is officially unsupported this month).

request.includes("/")

Copy link
Contributor Author

Choose a reason for hiding this comment

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

sigh, I never remember this method. #old

Chris Toshok added 2 commits April 11, 2018 14:46
… node version for builtins), and add meta.version to each event
…rument*. use includes instead of indexOf !== -1
@toshok toshok force-pushed the toshok.npm-package-version branch from d97de9b to 536487e Compare April 11, 2018 21:46
@toshok toshok merged commit 91134bf into master Apr 11, 2018
@toshok toshok deleted the toshok.npm-package-version branch April 11, 2018 21:54
@toshok toshok mentioned this pull request May 7, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants