feat: Add source mapping to CPU (wall time) profiler - #4095
Conversation
f3cf356 to
269100d
Compare
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #4095 +/- ##
==========================================
- Coverage 97.48% 97.40% -0.08%
==========================================
Files 517 517
Lines 62214 62270 +56
Branches 1 1
==========================================
+ Hits 60647 60654 +7
- Misses 1567 1616 +49
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
269100d to
b81bc00
Compare
bizob2828
left a comment
There was a problem hiding this comment.
I don't think we could land this in the current state based on my comments
4a59a16 to
4c35d38
Compare
bizob2828
left a comment
There was a problem hiding this comment.
tried using newrelic/newrelic-node-examples#378 but i don't see any samples that have user code in it. it's all either the agent or core node code. either way take a look at my suggestions
39b9abc to
50cb745
Compare
bizob2828
left a comment
There was a problem hiding this comment.
a few tests suggestions/questions but the code looks great!
| started = true | ||
| }) | ||
|
|
||
| await new Promise((resolve) => setImmediate(resolve)) |
Description
This PR adds source code mapping* support for our current
CpuProfiler. When enabled via theprofiling.source_mapping.enabledconfig option, approf.SourceMapperis built once during agent startup by scanning the application root (process.cwd()) for source maps. It's cached on theProfilingManagerand passed into theCpuProfiler's constructor when the profilers are registered. It builds it once at startup, rather than on each profiling cycle, to keep the profiling start/stop path synchronous and avoids re-scanning on every collection. Caching it on the manager also lets the sameSourceMapperbe shared with theHeapProfilerwhen we add heap source mapping later.If the
SourceMapperfails to build (or no source maps are found), the profiler falls back to its original behavior and reports the compiled file/line/code information.*Source code mapping refers to mapping the profiling sample to the pre-compiled code e.g. TypeScript, pre-compiled JavaScript. The goal is that users will be able to more easily correlate the node in the flamegraph with the function information (file location, code line number, etc.) in their written code instead of the compiled version.
How to Test
With the example app: newrelic/newrelic-node-examples#378
Related Issues
Closes #4083