From dd74850dcac71e01443561f773505c4e44abf797 Mon Sep 17 00:00:00 2001 From: Nicolas Savoire Date: Fri, 23 Jun 2023 14:44:43 +0200 Subject: [PATCH] Bump profiler version to 2.2.3 (#3286) * Add DD_PROFILING_DEBUG_SOURCE_MAPS option DD_PROFILING_DEBUG_SOURCE_MAPS env variable enables printing of detailed diagnostics concerning source maps. Pass logger to profiler module to enable logging. * Bump profiler version to 2.2.3 --- package.json | 2 +- packages/dd-trace/src/profiling/config.js | 2 ++ packages/dd-trace/src/profiling/profiler.js | 14 ++++++++------ yarn.lock | 8 ++++---- 4 files changed, 15 insertions(+), 11 deletions(-) diff --git a/package.json b/package.json index 0d254d8e9e7..3c37e52aa7f 100644 --- a/package.json +++ b/package.json @@ -70,7 +70,7 @@ "@datadog/native-iast-rewriter": "2.0.1", "@datadog/native-iast-taint-tracking": "^1.5.0", "@datadog/native-metrics": "^2.0.0", - "@datadog/pprof": "2.2.2", + "@datadog/pprof": "2.2.3", "@datadog/sketches-js": "^2.1.0", "@opentelemetry/api": "^1.0.0", "@opentelemetry/core": "^1.14.0", diff --git a/packages/dd-trace/src/profiling/config.js b/packages/dd-trace/src/profiling/config.js index 547cc610afe..1cdf23e44c2 100644 --- a/packages/dd-trace/src/profiling/config.js +++ b/packages/dd-trace/src/profiling/config.js @@ -27,6 +27,7 @@ class Config { DD_TRACE_AGENT_URL, DD_AGENT_HOST, DD_TRACE_AGENT_PORT, + DD_PROFILING_DEBUG_SOURCE_MAPS, DD_PROFILING_UPLOAD_TIMEOUT, DD_PROFILING_SOURCE_MAP, DD_PROFILING_UPLOAD_PERIOD, @@ -70,6 +71,7 @@ class Config { this.flushInterval = flushInterval this.uploadTimeout = uploadTimeout this.sourceMap = sourceMap + this.debugSourceMaps = isTrue(coalesce(options.debugSourceMaps, DD_PROFILING_DEBUG_SOURCE_MAPS, false)) this.endpointCollection = endpointCollection this.pprofPrefix = pprofPrefix diff --git a/packages/dd-trace/src/profiling/profiler.js b/packages/dd-trace/src/profiling/profiler.js index 79ea435ce2e..47dde4c7e57 100644 --- a/packages/dd-trace/src/profiling/profiler.js +++ b/packages/dd-trace/src/profiling/profiler.js @@ -4,12 +4,11 @@ const { EventEmitter } = require('events') const { Config } = require('./config') const { snapshotKinds } = require('./constants') -function maybeSourceMap (sourceMap) { +function maybeSourceMap (sourceMap, SourceMapper, debug) { if (!sourceMap) return - const { SourceMapper } = require('@datadog/pprof') return SourceMapper.create([ process.cwd() - ]) + ], debug) } class Profiler extends EventEmitter { @@ -42,12 +41,15 @@ class Profiler extends EventEmitter { // of the profiler from running without source maps. let mapper try { - mapper = await maybeSourceMap(config.sourceMap) - if (mapper) { + const { setLogger, SourceMapper } = require('@datadog/pprof') + setLogger(config.logger) + + mapper = await maybeSourceMap(config.sourceMap, SourceMapper, config.debugSourceMaps) + if (config.SourceMap && config.debugSourceMaps) { this._logger.debug(() => { return mapper.infoMap.size === 0 ? 'Found no source maps' - : `Found source-maps for following files: [${Array.from(mapper.infoMap.keys()).join(', ')}]` + : `Found source maps for following files: [${Array.from(mapper.infoMap.keys()).join(', ')}]` }) } } catch (err) { diff --git a/yarn.lock b/yarn.lock index 35f76047f81..a88f033215d 100644 --- a/yarn.lock +++ b/yarn.lock @@ -409,10 +409,10 @@ node-addon-api "^6.1.0" node-gyp-build "^3.9.0" -"@datadog/pprof@2.2.2": - version "2.2.2" - resolved "https://registry.yarnpkg.com/@datadog/pprof/-/pprof-2.2.2.tgz#5cc8aa2c198bb594bc8ecd85c94adbfac6e75563" - integrity sha512-6FVmgQoYvHVnpnAzfTHRIONJQprEJ6PdrfA3Kn4dfVEXZMH42PBRLSNWe4qoi5AKmr4SoIc6Ay7VAlHb/cDNjA== +"@datadog/pprof@2.2.3": + version "2.2.3" + resolved "https://registry.yarnpkg.com/@datadog/pprof/-/pprof-2.2.3.tgz#a22ca30e386f5aa8559f4b2e297b76c80551c26d" + integrity sha512-cZXvNBBzvTMUx2xOxp49cZJ7/HOF7geVxqeRbveeJUVKwi8ZxmU1rQGcWPFX4iEEtfQu1M3NqbhmNtYsMJdEsQ== dependencies: delay "^5.0.0" node-gyp-build "^3.9.0"