@datadog/pprof
Advanced tools
Comparing version 1.1.1 to 2.0.0-pre-9983949
@@ -82,10 +82,15 @@ "use strict"; | ||
} | ||
targetNode.cpuTime += sample.cpuTime; | ||
targetNode.hitCount++; | ||
if (sample.labels) { | ||
targetNode.labelSets.push(sample.labels); | ||
if (sample.labels && Object.keys(sample.labels).length > 0) { | ||
targetNode.labelSets.push({ | ||
labels: sample.labels, | ||
cpuTime: sample.cpuTime, | ||
}); | ||
} | ||
else { | ||
targetNode.cpuTime += sample.cpuTime; | ||
targetNode.hitCount++; | ||
} | ||
targetNode = timeProfile.topDownRoot; | ||
} | ||
const intervalMicros = 1000 / this.frequency; | ||
const intervalMicros = 1000000 / this.frequency; | ||
return (0, profile_serializer_1.serializeCpuProfile)(timeProfile, intervalMicros); | ||
@@ -92,0 +97,0 @@ } |
@@ -218,3 +218,3 @@ "use strict"; | ||
periodType: timeValueType, | ||
period: intervalMicros, | ||
period: intervalNanos, | ||
}; | ||
@@ -251,19 +251,14 @@ serialize(profile, prof.topDownRoot, appendTimeEntryToSamples, stringTable, undefined, sourceMapper); | ||
const appendCpuEntryToSamples = (entry, samples) => { | ||
for (const labelSet of entry.node.labelSets) { | ||
for (const labelCpu of entry.node.labelSets) { | ||
const sample = new profile_1.perftools.profiles.Sample({ | ||
locationId: entry.stack, | ||
value: [1, intervalNanos], | ||
label: buildLabels(labelSet, stringTable), | ||
value: [1, labelCpu.cpuTime], | ||
label: buildLabels(labelCpu.labels, stringTable), | ||
}); | ||
samples.push(sample); | ||
} | ||
const unknownEntryCount = entry.node.hitCount - entry.node.labelSets.length; | ||
if (unknownEntryCount > 0) { | ||
if (entry.node.hitCount > 0) { | ||
const sample = new profile_1.perftools.profiles.Sample({ | ||
locationId: entry.stack, | ||
value: [ | ||
unknownEntryCount, | ||
entry.node.cpuTime, | ||
// unknownEntryCount * intervalNanos, | ||
], | ||
value: [entry.node.hitCount, entry.node.cpuTime], | ||
}); | ||
@@ -282,3 +277,3 @@ samples.push(sample); | ||
periodType: cpuValueType, | ||
period: intervalMicros, | ||
period: intervalNanos, | ||
}; | ||
@@ -285,0 +280,0 @@ serialize(profile, prof.topDownRoot, appendCpuEntryToSamples, stringTable, undefined, sourceMapper); |
@@ -36,3 +36,2 @@ "use strict"; | ||
} | ||
const scanner = require("../../third_party/cloud-debug-nodejs/src/agent/io/scanner"); | ||
const pify = require('pify'); | ||
@@ -207,7 +206,43 @@ const pLimit = require('p-limit'); | ||
} | ||
function isErrnoException(e) { | ||
return e instanceof Error && 'code' in e; | ||
} | ||
function isNonFatalError(error) { | ||
const nonFatalErrors = ['ENOENT', 'EPERM', 'EACCES', 'ELOOP']; | ||
return (isErrnoException(error) && error.code && nonFatalErrors.includes(error.code)); | ||
} | ||
async function* walk(dir, | ||
// eslint-disable-next-line @typescript-eslint/no-unused-vars | ||
fileFilter = (filename) => true, | ||
// eslint-disable-next-line @typescript-eslint/no-unused-vars | ||
directoryFilter = (root, dirname) => true) { | ||
async function* walkRecursive(dir) { | ||
try { | ||
for await (const d of await fs.promises.opendir(dir)) { | ||
const entry = path.join(dir, d.name); | ||
if (d.isDirectory() && directoryFilter(dir, d.name)) { | ||
yield* walkRecursive(entry); | ||
} | ||
else if (d.isFile() && fileFilter(d.name)) { | ||
// check that the file is readable | ||
await fs.promises.access(entry, fs.constants.R_OK); | ||
yield entry; | ||
} | ||
} | ||
} | ||
catch (error) { | ||
if (!isNonFatalError(error)) { | ||
throw error; | ||
} | ||
} | ||
} | ||
yield* walkRecursive(dir); | ||
} | ||
async function getMapFiles(baseDir) { | ||
const fileStats = await scanner.scan(false, baseDir, /.js.map$/); | ||
const mapFiles = fileStats.selectFiles(/.js.map$/, process.cwd()); | ||
const mapFiles = []; | ||
for await (const entry of walk(baseDir, filename => filename.endsWith('.js.map'), (root, dirname) => root !== '/proc' && dirname !== '.git' && dirname !== 'node_modules')) { | ||
mapFiles.push(path.relative(baseDir, entry)); | ||
} | ||
return mapFiles; | ||
} | ||
//# sourceMappingURL=sourcemapper.js.map |
@@ -58,6 +58,10 @@ /** | ||
} | ||
export interface LabelsCpu { | ||
labels: LabelSet; | ||
cpuTime: number; | ||
} | ||
export interface CpuProfileNode extends ProfileNode { | ||
hitCount: number; | ||
cpuTime: number; | ||
labelSets: LabelSet[]; | ||
labelSets: LabelsCpu[]; | ||
} | ||
@@ -64,0 +68,0 @@ export interface CpuProfileSample { |
{ | ||
"name": "@datadog/pprof", | ||
"version": "1.1.1", | ||
"version": "2.0.0-pre-9983949", | ||
"description": "pprof support for Node.js", | ||
@@ -31,3 +31,2 @@ "repository": "datadog/pprof-nodejs", | ||
"delay": "^5.0.0", | ||
"findit2": "^2.2.3", | ||
"node-gyp-build": "^3.9.0", | ||
@@ -34,0 +33,0 @@ "p-limit": "^3.1.0", |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
No v1
QualityPackage is not semver >=1. This means it is not stable and does not support ^ ranges.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
7
4
65
10665010
104
5197
2
- Removedfindit2@^2.2.3
- Removedfindit2@2.2.3(transitive)