Skip to content

Commit 46b7986

Browse files
committed
Use 'process' as default strategy for oom export
'process' is the safer export strategy for heap profile export upon oom.
1 parent 4e7da80 commit 46b7986

File tree

2 files changed

+25
-2
lines changed

2 files changed

+25
-2
lines changed

packages/dd-trace/src/profiling/config.js

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -91,8 +91,10 @@ class Config {
9191
Number(DD_PROFILING_EXPERIMENTAL_OOM_HEAP_LIMIT_EXTENSION_SIZE), 0)
9292
const maxHeapExtensionCount = coalesce(options.oomMaxHeapExtensionCount,
9393
Number(DD_PROFILING_EXPERIMENTAL_OOM_MAX_HEAP_EXTENSION_COUNT), 0)
94-
const exportStrategies = ensureOOMExportStrategies(coalesce(options.oomExportStrategies,
95-
DD_PROFILING_EXPERIMENTAL_OOM_EXPORT_STRATEGIES), this)
94+
const exportStrategies = oomMonitoringEnabled
95+
? ensureOOMExportStrategies(coalesce(options.oomExportStrategies, DD_PROFILING_EXPERIMENTAL_OOM_EXPORT_STRATEGIES,
96+
[oomExportStrategies.PROCESS]), this)
97+
: []
9698
const exportCommand = oomMonitoringEnabled ? buildExportCommand(this) : undefined
9799
this.oomMonitoring = {
98100
enabled: oomMonitoringEnabled,

packages/dd-trace/test/profiling/config.spec.js

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -171,6 +171,27 @@ describe('config', () => {
171171
})
172172
})
173173

174+
it('should use process as default strategy for OOM heap profiler', () => {
175+
process.env = {
176+
DD_PROFILING_EXPERIMENTAL_OOM_MONITORING_ENABLED: 'true'
177+
}
178+
const config = new Config()
179+
180+
expect(config.oomMonitoring).to.deep.equal({
181+
enabled: true,
182+
heapLimitExtensionSize: 0,
183+
maxHeapExtensionCount: 0,
184+
exportStrategies: ['process'],
185+
exportCommand: [
186+
process.execPath,
187+
path.normalize(path.join(__dirname, '../../src/profiling', 'exporter_cli.js')),
188+
'http://localhost:8126/',
189+
`host:${config.host},service:node,snapshot:on_oom`,
190+
'space'
191+
]
192+
})
193+
})
194+
174195
it('should support OOM heap profiler configuration', () => {
175196
process.env = {
176197
DD_PROFILING_EXPERIMENTAL_OOM_MONITORING_ENABLED: '1',

0 commit comments

Comments
 (0)