Repository navigation
Instrument require() for autobreadcrumbs - #322
Conversation
|
This is now pretty much fully working. I had a bunch of subtle module caching and double-instrumentation stuff going on in the tests because my first pass at Still want to investigate a couple things:
|
Is this still WIP? Should we be reviewing? |
|
Worked through investigation points 2 and 3 and determined that current state is acceptable. Identified a duplication issue of some sort in point 1, tracking it down and then I'll remove WIP tag and request review. |
129f3f8 to
b555acf
Compare
c10116c to
838330f
Compare
|
Tracked down duplication. Also actually figured out the explanation behind point 3, but opted to leave it as is to avoid a significant mostly-unnecessary refactor; explained in a comment above where we proactively Ready for review; primary piece to review is instrumentor.js; aspects of that in particular are how instrumentor is used from client.js and the coupling between instrumentor and Raven, and the interface between instrumentor and each of the three "instrument this module" files. |
benvinegar
left a comment
There was a problem hiding this comment.
I actually wrote a bunch more comments, then worked through the logic and realized I had it wrong – seems good. My one request changes is re: DRYing the fill helper.
| pg: false | ||
| }; | ||
|
|
||
| function fill(obj, name, replacement, track) { |
There was a problem hiding this comment.
Can we not put this in ../utils? It's duplicated 3 times in this patch.
There was a problem hiding this comment.
Yea, sure, I had a mental note on this but forgot about it. This was another of my motivating factors for a shared js utils, but that's a separate issue.
| var Module = require('module'); | ||
| fill(Module, '_load', function (origLoad) { | ||
| return function (moduleId, parent, isMain) { | ||
| var origModule = origLoad.apply(this, arguments); |
There was a problem hiding this comment.
Worth doing that Array args copy / perf trick here?
There was a problem hiding this comment.
Maybe, but there are a few other spots where we're doing something.apply(this, arguments) in instrumentation for console and http (and fwiw raven-js also has spots where it doesn't do the copy opt...), so I'd rather go all-or-nothing on it.
| this.autoBreadcrumbs = options.autoBreadcrumbs || false; | ||
| // default to 30, don't allow higher than 100 | ||
| this.maxBreadcrumbs = Math.max(0, Math.min(options.maxBreadcrumbs || 30, 100)); | ||
| this.autoBreadcrumbs = extend({}, autoBreadcrumbDefaults); |
There was a problem hiding this comment.
I thought we had a test for this logic. Is it not affected by this?
There was a problem hiding this comment.
For which part in particular? I basically moved the "figure out what our autobreadcrumb to turn on" bit into instrumentor. I don't think anything really changed behavior-wise, just where it lives, so now client has to care a lot less and just has to pass its config on to the instrumentor. It actually ended up simplifying things quite a bit from a combination of two or three small differences.
benvinegar
left a comment
There was a problem hiding this comment.
🔥 Lets run the memcheck stuff before cutting a new version.
This is a bit behind where I am locally, will push an update soon, but here's the PR to start tracking.