Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@datadog/pprof

Package Overview
Dependencies
Maintainers
1
Versions
72
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@datadog/pprof - npm Package Compare versions

Comparing version 6.0.0-pre-7d7500a to 6.0.0-pre-918c1bd

1

out/src/index.d.ts

@@ -19,2 +19,3 @@ import * as heapProfiler from './heap-profiler';

kSampleCount: any;
GARBAGE_COLLECTION_FUNCTION_NAME: string;
NON_JS_THREADS_FUNCTION_NAME: string;

@@ -21,0 +22,0 @@ };

4

out/src/profile-encoder.js

@@ -22,4 +22,4 @@ "use strict";

const gzipPromise = (0, util_1.promisify)(zlib_1.gzip);
async function encode(profile) {
return gzipPromise(profile.encode());
function encode(profile) {
return profile.encodeAsync().then(gzipPromise);
}

@@ -26,0 +26,0 @@ exports.encode = encode;

@@ -19,3 +19,4 @@ /**

import { AllocationProfileNode, GenerateAllocationLabelsFunction, GenerateTimeLabelsFunction, TimeProfile } from './v8-types';
export declare const NON_JS_THREADS_FUNCTION_NAME = "(non-JS threads)";
export declare const NON_JS_THREADS_FUNCTION_NAME = "Non JS threads activity";
export declare const GARBAGE_COLLECTION_FUNCTION_NAME = "Garbage Collection";
/**

@@ -22,0 +23,0 @@ * Converts v8 time profile into into a profile proto.

@@ -18,5 +18,6 @@ "use strict";

Object.defineProperty(exports, "__esModule", { value: true });
exports.serializeHeapProfile = exports.serializeTimeProfile = exports.NON_JS_THREADS_FUNCTION_NAME = void 0;
exports.serializeHeapProfile = exports.serializeTimeProfile = exports.GARBAGE_COLLECTION_FUNCTION_NAME = exports.NON_JS_THREADS_FUNCTION_NAME = void 0;
const pprof_format_1 = require("pprof-format");
exports.NON_JS_THREADS_FUNCTION_NAME = '(non-JS threads)';
exports.NON_JS_THREADS_FUNCTION_NAME = 'Non JS threads activity';
exports.GARBAGE_COLLECTION_FUNCTION_NAME = 'Garbage Collection';
function isGeneratedLocation(location) {

@@ -52,7 +53,9 @@ return (location.column !== undefined &&

const node = entry.node;
// mjs files have a `file://` prefix in the scriptName -> remove it
if (node.scriptName.startsWith('file://')) {
node.scriptName = node.scriptName.slice(7);
}
if (ignoreSamplesPath && node.scriptName.indexOf(ignoreSamplesPath) > -1) {
continue;
}
if (node.name === '(idle)' || node.name === '(program)')
continue;
const stack = entry.stack;

@@ -191,2 +194,67 @@ const location = getLocation(node, sourceMapper);

}
/** Perform some modifications on time profile:
* - Add non-JS thread activity node if available
* - Remove `(idle)` and `(program)` nodes
* - Convert `(garbage collector)` node to `Garbage Collection`
* - Put `non-JS thread activity` node and `Garbage Collection` under a top level `Node.js` node
* This function does not change the input profile.
*/
function updateTimeProfile(prof) {
const newTopLevelChildren = [];
let runtimeNode;
function getRuntimeNode() {
if (!runtimeNode) {
runtimeNode = {
name: 'Node.js',
scriptName: '',
scriptId: 0,
lineNumber: 0,
columnNumber: 0,
children: [],
hitCount: 0,
};
newTopLevelChildren.push(runtimeNode);
}
return runtimeNode;
}
for (const child of prof.topDownRoot.children) {
if (child.name === '(idle)' || child.name === '(program)') {
continue;
}
if (child.name === '(garbage collector)') {
// Create a new node to avoid modifying the input one
const newChild = {
...child,
name: exports.GARBAGE_COLLECTION_FUNCTION_NAME,
};
getRuntimeNode().children.push(newChild);
}
else {
newTopLevelChildren.push(child);
}
}
if (prof.hasCpuTime && prof.nonJSThreadsCpuTime) {
const node = {
name: exports.NON_JS_THREADS_FUNCTION_NAME,
scriptName: '',
scriptId: 0,
lineNumber: 0,
columnNumber: 0,
children: [],
hitCount: 0,
contexts: [
{
context: {},
timestamp: BigInt(0),
cpuTime: prof.nonJSThreadsCpuTime,
},
],
};
getRuntimeNode().children.push(node);
}
return {
...prof,
topDownRoot: { ...prof.topDownRoot, children: newTopLevelChildren },
};
}
/**

@@ -221,3 +289,6 @@ * Converts v8 time profile into into a profile proto.

if (Object.keys(labels).length > 0) {
const values = [1, intervalNanos];
// Only assign wall time if there are hits, some special nodes such as `(Non-JS threads)`
// have zero hit count (since they do not count as wall time) and should not be assigned any
// wall time.
const values = unlabelledHits > 0 ? [1, intervalNanos] : [0, 0];
if (prof.hasCpuTime) {

@@ -240,3 +311,5 @@ values.push(context.cpuTime);

const labels = generateLabels ? generateLabels({ node: entry.node }) : {};
const values = [unlabelledHits, unlabelledHits * intervalNanos];
const values = unlabelledHits > 0
? [unlabelledHits, unlabelledHits * intervalNanos]
: [0, 0];
if (prof.hasCpuTime) {

@@ -268,22 +341,4 @@ values.push(unlabelledCpuTime);

};
if (prof.nonJSThreadsCpuTime) {
const node = {
name: exports.NON_JS_THREADS_FUNCTION_NAME,
scriptName: '',
scriptId: 0,
lineNumber: 0,
columnNumber: 0,
children: [],
hitCount: 0,
contexts: [
{
context: {},
timestamp: BigInt(0),
cpuTime: prof.nonJSThreadsCpuTime,
},
],
};
prof.topDownRoot.children.push(node);
}
serialize(profile, prof.topDownRoot, appendTimeEntryToSamples, stringTable, undefined, sourceMapper);
const updatedProf = updateTimeProfile(prof);
serialize(profile, updatedProf.topDownRoot, appendTimeEntryToSamples, stringTable, undefined, sourceMapper);
return new pprof_format_1.Profile(profile);

@@ -290,0 +345,0 @@ }

@@ -316,3 +316,3 @@ "use strict";

const mapFiles = [];
for await (const entry of walk(baseDir, filename => filename.endsWith('.js.map'), (root, dirname) => root !== '/proc' && dirname !== '.git' && dirname !== 'node_modules')) {
for await (const entry of walk(baseDir, filename => /\.[cm]?js\.map$/.test(filename), (root, dirname) => root !== '/proc' && dirname !== '.git' && dirname !== 'node_modules')) {
mapFiles.push(path.relative(baseDir, entry));

@@ -319,0 +319,0 @@ }

@@ -48,4 +48,5 @@ /**

kSampleCount: any;
GARBAGE_COLLECTION_FUNCTION_NAME: string;
NON_JS_THREADS_FUNCTION_NAME: string;
};
export { getNativeThreadId };

@@ -130,3 +130,7 @@ "use strict";

exports.v8ProfilerStuckEventLoopDetected = v8ProfilerStuckEventLoopDetected;
exports.constants = { kSampleCount, NON_JS_THREADS_FUNCTION_NAME: profile_serializer_1.NON_JS_THREADS_FUNCTION_NAME };
exports.constants = {
kSampleCount,
GARBAGE_COLLECTION_FUNCTION_NAME: profile_serializer_1.GARBAGE_COLLECTION_FUNCTION_NAME,
NON_JS_THREADS_FUNCTION_NAME: profile_serializer_1.NON_JS_THREADS_FUNCTION_NAME,
};
//# sourceMappingURL=time-profiler.js.map
{
"name": "@datadog/pprof",
"version": "6.0.0-pre-7d7500a",
"version": "6.0.0-pre-918c1bd",
"description": "pprof support for Node.js",

@@ -39,3 +39,3 @@ "repository": "datadog/pprof-nodejs",

"p-limit": "^3.1.0",
"pprof-format": "^2.0.7",
"pprof-format": "^2.1.0",
"source-map": "^0.7.4"

@@ -59,3 +59,3 @@ },

"mocha": "^10.2.0",
"nan": "^2.18.0",
"nan": "^2.19.0",
"nyc": "^15.1.0",

@@ -62,0 +62,0 @@ "sinon": "^15.2.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

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc