Skip to content

Commit

Permalink
add parallelism information to the profiles
Browse files Browse the repository at this point in the history
  • Loading branch information
szegedi committed Oct 8, 2024
1 parent 2d175d3 commit 6e205e4
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 2 deletions.
7 changes: 7 additions & 0 deletions packages/dd-trace/src/profiling/exporters/agent.js
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,7 @@ class AgentExporter {
return `${type}.pprof`
}

const cpus = os.cpus()
const event = JSON.stringify({
attachments: Object.keys(profiles).map(typeToFile),
start: start.toISOString(),
Expand All @@ -101,6 +102,7 @@ class AgentExporter {
version: this._appVersion
},
platform: {
cpu_model: cpus[0]?.model,
hostname: this._host,
kernel_name: os.type(),
kernel_release: os.release(),
Expand All @@ -114,11 +116,16 @@ class AgentExporter {
version
},
runtime: {
available_processors: typeof os.availableParallelism === 'function'
? os.availableParallelism()
: cpus.length,
// Using `nodejs` for consistency with the existing `runtime` tag.
// Note that the event `family` property uses `node`, as that's what's
// proscribed by the Intake API, but that's an internal enum and is
// not customer visible.
engine: 'nodejs',
// os.availableParallelism only available in node 18.14.0/19.4.0 and above
libuv_threadpool_size: process.env.UV_THREADPOOL_SIZE,
// strip off leading 'v'. This makes the format consistent with other
// runtimes (e.g. Ruby) but not with the existing `runtime_version` tag.
// We'll keep it like this as we want cross-engine consistency. We
Expand Down
6 changes: 4 additions & 2 deletions packages/dd-trace/test/profiling/exporters/agent.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,8 @@ describe('exporters/agent', function () {
expect(event.info.application).to.have.property('start_time')
expect(event.info.application).to.have.property('version', '1.2.3')
expect(event.info).to.have.property('platform')
expect(Object.keys(event.info.platform)).to.have.length(4)
expect(Object.keys(event.info.platform)).to.have.length(5)
expect(event.info.platform).to.have.property('cpu_model')
expect(event.info.platform).to.have.property('hostname', HOST)
expect(event.info.platform).to.have.property('kernel_name', os.type())
expect(event.info.platform).to.have.property('kernel_release', os.release())
Expand All @@ -120,7 +121,8 @@ describe('exporters/agent', function () {
expect(event.info.profiler.ssi).to.have.property('mechanism', 'none')
expect(event.info.profiler).to.have.property('version', version)
expect(event.info).to.have.property('runtime')
expect(Object.keys(event.info.runtime)).to.have.length(2)
expect(Object.keys(event.info.runtime)).to.have.length(3)
expect(event.info.runtime).to.have.property('available_processors')
expect(event.info.runtime).to.have.property('engine', 'nodejs')
expect(event.info.runtime).to.have.property('version', process.version.substring(1))

Expand Down

0 comments on commit 6e205e4

Please sign in to comment.