|
1 | 1 | 'use strict'
|
2 | 2 |
|
3 |
| -const coalesce = require('koalas') |
4 | 3 | const os = require('os')
|
5 | 4 | const path = require('path')
|
6 | 5 | const { URL, format, pathToFileURL } = require('url')
|
@@ -59,8 +58,8 @@ class Config {
|
59 | 58 | const host = os.hostname()
|
60 | 59 | const version = options.version ?? DD_VERSION
|
61 | 60 | // Must be longer than one minute so pad with five seconds
|
62 |
| - const flushInterval = coalesce(options.interval, Number(DD_PROFILING_UPLOAD_PERIOD) * 1000, 65 * 1000) |
63 |
| - const uploadTimeout = coalesce(options.uploadTimeout, Number(DD_PROFILING_UPLOAD_TIMEOUT), 60 * 1000) |
| 61 | + const flushInterval = options.interval ?? (Number(DD_PROFILING_UPLOAD_PERIOD) * 1000 || 65 * 1000) |
| 62 | + const uploadTimeout = options.uploadTimeout ?? (Number(DD_PROFILING_UPLOAD_TIMEOUT) || 60 * 1000) |
64 | 63 | const sourceMap = options.sourceMap ?? DD_PROFILING_SOURCE_MAP ?? true
|
65 | 64 | const pprofPrefix = options.pprofPrefix ?? DD_PROFILING_PPROF_PREFIX ?? ''
|
66 | 65 |
|
@@ -134,10 +133,10 @@ class Config {
|
134 | 133 | DD_PROFILING_EXPERIMENTAL_OOM_MONITORING_ENABLED ?? oomMonitoringSupported)
|
135 | 134 | checkOptionAllowed(oomMonitoringEnabled, 'OOM monitoring', oomMonitoringSupported)
|
136 | 135 |
|
137 |
| - const heapLimitExtensionSize = coalesce(options.oomHeapLimitExtensionSize, |
138 |
| - Number(DD_PROFILING_EXPERIMENTAL_OOM_HEAP_LIMIT_EXTENSION_SIZE), 0) |
139 |
| - const maxHeapExtensionCount = coalesce(options.oomMaxHeapExtensionCount, |
140 |
| - Number(DD_PROFILING_EXPERIMENTAL_OOM_MAX_HEAP_EXTENSION_COUNT), 0) |
| 136 | + const heapLimitExtensionSize = options.oomHeapLimitExtensionSize ?? |
| 137 | + (Number(DD_PROFILING_EXPERIMENTAL_OOM_HEAP_LIMIT_EXTENSION_SIZE) || 0) |
| 138 | + const maxHeapExtensionCount = options.oomMaxHeapExtensionCount ?? |
| 139 | + (Number(DD_PROFILING_EXPERIMENTAL_OOM_MAX_HEAP_EXTENSION_COUNT) || 0) |
141 | 140 | const exportStrategies = oomMonitoringEnabled
|
142 | 141 | ? ensureOOMExportStrategies(options.oomExportStrategies ?? DD_PROFILING_EXPERIMENTAL_OOM_EXPORT_STRATEGIES ??
|
143 | 142 | [oomExportStrategies.PROCESS], this)
|
@@ -175,10 +174,10 @@ class Config {
|
175 | 174 | )
|
176 | 175 | checkOptionWithSamplingContextAllowed(this.cpuProfilingEnabled, 'CPU profiling')
|
177 | 176 |
|
178 |
| - this.samplingInterval = coalesce(options.samplingInterval, 1e3 / 99) // 99hz in millis |
| 177 | + this.samplingInterval = options.samplingInterval || 1e3 / 99 // 99hz in millis |
179 | 178 |
|
180 |
| - this.heapSamplingInterval = coalesce(options.heapSamplingInterval, |
181 |
| - Number(DD_PROFILING_HEAP_SAMPLING_INTERVAL)) |
| 179 | + this.heapSamplingInterval = options.heapSamplingInterval ?? |
| 180 | + (Number(DD_PROFILING_HEAP_SAMPLING_INTERVAL) || 512 * 1024) |
182 | 181 | const uploadCompression0 = options.uploadCompression ?? DD_PROFILING_DEBUG_UPLOAD_COMPRESSION ?? 'on'
|
183 | 182 | let [uploadCompression, level0] = uploadCompression0.split('-')
|
184 | 183 | if (!['on', 'off', 'gzip', 'zstd'].includes(uploadCompression)) {
|
@@ -222,8 +221,7 @@ class Config {
|
222 | 221 |
|
223 | 222 | const hasExecArg = (arg) => process.execArgv.includes(arg) || String(NODE_OPTIONS).includes(arg)
|
224 | 223 |
|
225 |
| - this.asyncContextFrameEnabled = isTrue(options.useAsyncContextFrame ?? |
226 |
| - DD_PROFILING_ASYNC_CONTEXT_FRAME_ENABLED ?? false) |
| 224 | + this.asyncContextFrameEnabled = isTrue(options.useAsyncContextFrame ?? DD_PROFILING_ASYNC_CONTEXT_FRAME_ENABLED) |
227 | 225 | if (this.asyncContextFrameEnabled) {
|
228 | 226 | if (satisfies(process.versions.node, '>=24.0.0')) {
|
229 | 227 | if (hasExecArg('--no-async-context-frame')) {
|
|
0 commit comments