Skip to content

Commit

Permalink
Bump profiler version to 2.2.3 (#3286)
Browse files Browse the repository at this point in the history
* 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
  • Loading branch information
nsavoire authored Jun 23, 2023
1 parent f8442ab commit dd74850
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 11 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
2 changes: 2 additions & 0 deletions packages/dd-trace/src/profiling/config.js
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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

Expand Down
14 changes: 8 additions & 6 deletions packages/dd-trace/src/profiling/profiler.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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) {
Expand Down
8 changes: 4 additions & 4 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down

0 comments on commit dd74850

Please sign in to comment.