Skip to content

Configurable NativeSpaceProfiler samplingInterval #5725

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

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions packages/dd-trace/src/profiling/config.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ class Config {
DD_PROFILING_EXPERIMENTAL_OOM_MONITORING_ENABLED,
DD_PROFILING_EXPERIMENTAL_TIMELINE_ENABLED,
DD_PROFILING_HEAP_ENABLED,
DD_PROFILING_HEAP_SAMPLING_INTERVAL,
DD_PROFILING_PPROF_PREFIX,
DD_PROFILING_PROFILERS,
DD_PROFILING_SOURCE_MAP,
Expand Down Expand Up @@ -191,6 +192,8 @@ class Config {
logExperimentalVarDeprecation('CPU_ENABLED')
checkOptionWithSamplingContextAllowed(this.cpuProfilingEnabled, 'CPU profiling')

this.heapSamplingInterval = coalesce(options.heapSamplingInterval,
Number(DD_PROFILING_HEAP_SAMPLING_INTERVAL))
this.profilers = ensureProfilers(profilers, this)
}
}
Expand Down
2 changes: 1 addition & 1 deletion packages/dd-trace/src/profiling/profilers/space.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ function strategiesToCallbackMode (strategies, callbackMode) {
class NativeSpaceProfiler {
constructor (options = {}) {
this.type = 'space'
this._samplingInterval = options.samplingInterval || 512 * 1024
this._samplingInterval = options.heapSamplingInterval || 512 * 1024
this._stackDepth = options.stackDepth || 64
this._pprof = undefined
this._oomMonitoring = options.oomMonitoring || {}
Expand Down
6 changes: 3 additions & 3 deletions packages/dd-trace/test/profiling/profilers/space.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,14 +34,14 @@ describe('profilers/native/space', () => {
})

it('should use the provided configuration options', () => {
const samplingInterval = 1024
const heapSamplingInterval = 1024
const stackDepth = 10
const profiler = new NativeSpaceProfiler({ samplingInterval, stackDepth })
const profiler = new NativeSpaceProfiler({ heapSamplingInterval, stackDepth })

profiler.start()

sinon.assert.calledOnce(pprof.heap.start)
sinon.assert.calledWith(pprof.heap.start, samplingInterval, stackDepth)
sinon.assert.calledWith(pprof.heap.start, heapSamplingInterval, stackDepth)
})

it('should stop the internal space profiler', () => {
Expand Down
Loading