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 2.0.0-pre-9983949 to 2.0.0-pre-b7ce6e3

2

out/src/cpu-profiler.d.ts

@@ -18,3 +18,3 @@ /**

export default class CpuProfiler extends NativeCpuProfiler {
profile(): import("../../proto/profile").perftools.profiles.IProfile | undefined;
profile(): import("pprof-format").Profile | undefined;
}

@@ -16,3 +16,3 @@ /**

*/
import { perftools } from '../../proto/profile';
import { Profile } from 'pprof-format';
import { SourceMapper } from './sourcemapper/sourcemapper';

@@ -28,3 +28,3 @@ import { AllocationProfileNode } from './v8-types';

*/
export declare function profile(ignoreSamplePath?: string, sourceMapper?: SourceMapper): perftools.profiles.IProfile;
export declare function profile(ignoreSamplePath?: string, sourceMapper?: SourceMapper): Profile;
/**

@@ -31,0 +31,0 @@ * Starts heap profiling. If heap profiling has already been started with

@@ -17,4 +17,4 @@ /**

/// <reference types="node" />
import { perftools } from '../../proto/profile';
export declare function encode(profile: perftools.profiles.IProfile): Promise<Buffer>;
export declare function encodeSync(profile: perftools.profiles.IProfile): Buffer;
import { Profile } from 'pprof-format';
export declare function encode(profile: Profile): Promise<Buffer>;
export declare function encodeSync(profile: Profile): Buffer;

@@ -21,14 +21,11 @@ "use strict";

const zlib_1 = require("zlib");
const profile_1 = require("../../proto/profile");
const gzipPromise = pify(zlib_1.gzip);
async function encode(profile) {
const buffer = profile_1.perftools.profiles.Profile.encode(profile).finish();
return gzipPromise(buffer);
return gzipPromise(profile.encode());
}
exports.encode = encode;
function encodeSync(profile) {
const buffer = profile_1.perftools.profiles.Profile.encode(profile).finish();
return (0, zlib_1.gzipSync)(buffer);
return (0, zlib_1.gzipSync)(profile.encode());
}
exports.encodeSync = encodeSync;
//# sourceMappingURL=profile-encoder.js.map

@@ -16,3 +16,3 @@ /**

*/
import { perftools } from '../../proto/profile';
import { Profile } from 'pprof-format';
import { SourceMapper } from './sourcemapper/sourcemapper';

@@ -27,3 +27,3 @@ import { AllocationProfileNode, CpuProfile, TimeProfile } from './v8-types';

*/
export declare function serializeTimeProfile(prof: TimeProfile, intervalMicros: number, sourceMapper?: SourceMapper): perftools.profiles.IProfile;
export declare function serializeTimeProfile(prof: TimeProfile, intervalMicros: number, sourceMapper?: SourceMapper): Profile;
/**

@@ -36,3 +36,3 @@ * Converts cpu profile into into a profile proto.

*/
export declare function serializeCpuProfile(prof: CpuProfile, intervalMicros: number, sourceMapper?: SourceMapper): perftools.profiles.IProfile;
export declare function serializeCpuProfile(prof: CpuProfile, intervalMicros: number, sourceMapper?: SourceMapper): Profile;
/**

@@ -48,2 +48,2 @@ * Converts v8 heap profile into into a profile proto.

*/
export declare function serializeHeapProfile(prof: AllocationProfileNode, startTimeNanos: number, intervalBytes: number, ignoreSamplesPath?: string, sourceMapper?: SourceMapper): perftools.profiles.IProfile;
export declare function serializeHeapProfile(prof: AllocationProfileNode, startTimeNanos: number, intervalBytes: number, ignoreSamplesPath?: string, sourceMapper?: SourceMapper): Profile;

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

exports.serializeHeapProfile = exports.serializeCpuProfile = exports.serializeTimeProfile = void 0;
const profile_1 = require("../../proto/profile");
const pprof_format_1 = require("pprof-format");
function isGeneratedLocation(location) {

@@ -27,26 +27,2 @@ return (location.column !== undefined &&

/**
* Used to build string table and access strings and their ids within the table
* when serializing a profile.
*/
class StringTable {
constructor() {
this.strings = [];
this.stringsMap = new Map();
this.getIndexOrAdd('');
}
/**
* @return index of str within the table. Also adds str to string table if
* str is not in the table already.
*/
getIndexOrAdd(str) {
let idx = this.stringsMap.get(str);
if (idx !== undefined) {
return idx;
}
idx = this.strings.push(str) - 1;
this.stringsMap.set(str, idx);
return idx;
}
}
/**
* Takes v8 profile and populates sample, location, and function fields of

@@ -92,3 +68,3 @@ * profile.proto.

profile.function = functions;
profile.stringTable = stringTable.strings;
profile.stringTable = stringTable;
function getLocation(node, sourceMapper) {

@@ -115,3 +91,3 @@ let profLoc = {

const line = getLine(node.scriptId, profLoc.file, profLoc.name, profLoc.line);
const location = new profile_1.perftools.profiles.Location({ id, line: [line] });
const location = new pprof_format_1.Location({ id, line: [line] });
locations.push(location);

@@ -121,3 +97,3 @@ return location;

function getLine(scriptId, scriptName, name, line) {
return new profile_1.perftools.profiles.Line({
return new pprof_format_1.Line({
functionId: getFunction(scriptId, scriptName, name).id,

@@ -136,8 +112,8 @@ line,

functionIdMap.set(keyStr, id);
const nameId = stringTable.getIndexOrAdd(name || '(anonymous)');
const f = new profile_1.perftools.profiles.Function({
const nameId = stringTable.dedup(name || '(anonymous)');
const f = new pprof_format_1.Function({
id,
name: nameId,
systemName: nameId,
filename: stringTable.getIndexOrAdd(scriptName || ''),
filename: stringTable.dedup(scriptName || ''),
});

@@ -153,5 +129,5 @@ functions.push(f);

function createSampleCountValueType(table) {
return new profile_1.perftools.profiles.ValueType({
type: table.getIndexOrAdd('sample'),
unit: table.getIndexOrAdd('count'),
return new pprof_format_1.ValueType({
type: table.dedup('sample'),
unit: table.dedup('count'),
});

@@ -164,5 +140,5 @@ }

function createTimeValueType(table) {
return new profile_1.perftools.profiles.ValueType({
type: table.getIndexOrAdd('wall'),
unit: table.getIndexOrAdd('nanoseconds'),
return new pprof_format_1.ValueType({
type: table.dedup('wall'),
unit: table.dedup('nanoseconds'),
});

@@ -175,5 +151,5 @@ }

function createCpuValueType(table) {
return new profile_1.perftools.profiles.ValueType({
type: table.getIndexOrAdd('cpu'),
unit: table.getIndexOrAdd('nanoseconds'),
return new pprof_format_1.ValueType({
type: table.dedup('cpu'),
unit: table.dedup('nanoseconds'),
});

@@ -186,5 +162,5 @@ }

function createObjectCountValueType(table) {
return new profile_1.perftools.profiles.ValueType({
type: table.getIndexOrAdd('objects'),
unit: table.getIndexOrAdd('count'),
return new pprof_format_1.ValueType({
type: table.dedup('objects'),
unit: table.dedup('count'),
});

@@ -197,5 +173,5 @@ }

function createAllocationValueType(table) {
return new profile_1.perftools.profiles.ValueType({
type: table.getIndexOrAdd('space'),
unit: table.getIndexOrAdd('bytes'),
return new pprof_format_1.ValueType({
type: table.dedup('space'),
unit: table.dedup('bytes'),
});

@@ -214,3 +190,3 @@ }

if (entry.node.hitCount > 0) {
const sample = new profile_1.perftools.profiles.Sample({
const sample = new pprof_format_1.Sample({
locationId: entry.stack,

@@ -222,3 +198,3 @@ value: [entry.node.hitCount, entry.node.hitCount * intervalNanos],

};
const stringTable = new StringTable();
const stringTable = new pprof_format_1.StringTable();
const sampleValueType = createSampleCountValueType(stringTable);

@@ -234,3 +210,3 @@ const timeValueType = createTimeValueType(stringTable);

serialize(profile, prof.topDownRoot, appendTimeEntryToSamples, stringTable, undefined, sourceMapper);
return profile;
return new pprof_format_1.Profile(profile);
}

@@ -242,7 +218,7 @@ exports.serializeTimeProfile = serializeTimeProfile;

if (typeof value === 'number' || typeof value === 'string') {
const label = new profile_1.perftools.profiles.Label({
key: stringTable.getIndexOrAdd(key),
const label = new pprof_format_1.Label({
key: stringTable.dedup(key),
num: typeof value === 'number' ? value : undefined,
str: typeof value === 'string'
? stringTable.getIndexOrAdd(value)
? stringTable.dedup(value)
: undefined,

@@ -266,3 +242,3 @@ });

for (const labelCpu of entry.node.labelSets) {
const sample = new profile_1.perftools.profiles.Sample({
const sample = new pprof_format_1.Sample({
locationId: entry.stack,

@@ -275,3 +251,3 @@ value: [1, labelCpu.cpuTime],

if (entry.node.hitCount > 0) {
const sample = new profile_1.perftools.profiles.Sample({
const sample = new pprof_format_1.Sample({
locationId: entry.stack,

@@ -283,3 +259,3 @@ value: [entry.node.hitCount, entry.node.cpuTime],

};
const stringTable = new StringTable();
const stringTable = new pprof_format_1.StringTable();
const sampleValueType = createSampleCountValueType(stringTable);

@@ -296,3 +272,3 @@ // const wallValueType = createTimeValueType(stringTable);

serialize(profile, prof.topDownRoot, appendCpuEntryToSamples, stringTable, undefined, sourceMapper);
return profile;
return new pprof_format_1.Profile(profile);
}

@@ -314,3 +290,3 @@ exports.serializeCpuProfile = serializeCpuProfile;

for (const alloc of entry.node.allocations) {
const sample = new profile_1.perftools.profiles.Sample({
const sample = new pprof_format_1.Sample({
locationId: entry.stack,

@@ -324,3 +300,3 @@ value: [alloc.count, alloc.sizeBytes * alloc.count],

};
const stringTable = new StringTable();
const stringTable = new pprof_format_1.StringTable();
const sampleValueType = createObjectCountValueType(stringTable);

@@ -335,5 +311,5 @@ const allocationValueType = createAllocationValueType(stringTable);

serialize(profile, prof, appendHeapEntryToSamples, stringTable, ignoreSamplesPath, sourceMapper);
return profile;
return new pprof_format_1.Profile(profile);
}
exports.serializeHeapProfile = serializeHeapProfile;
//# sourceMappingURL=profile-serializer.js.map

@@ -34,4 +34,4 @@ /**

}
export declare function profile(options: TimeProfilerOptions): Promise<import("../../proto/profile").perftools.profiles.IProfile>;
export declare function start(intervalMicros?: Microseconds, name?: string, sourceMapper?: SourceMapper, lineNumbers?: boolean): (restart?: boolean) => import("../../proto/profile").perftools.profiles.IProfile;
export declare function profile(options: TimeProfilerOptions): Promise<import("pprof-format").Profile>;
export declare function start(intervalMicros?: Microseconds, name?: string, sourceMapper?: SourceMapper, lineNumbers?: boolean): (restart?: boolean) => import("pprof-format").Profile;
export {};
{
"name": "@datadog/pprof",
"version": "2.0.0-pre-9983949",
"version": "2.0.0-pre-b7ce6e3",
"description": "pprof support for Node.js",

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

"prepare": "npm run compile",
"pretest": "npm run compile && npm run rebuild",
"proto": "npm run proto:profile",
"proto:profile": "mkdir -p proto && npx --yes pbjs -t static-module -w commonjs -o proto/profile.js third_party/proto/profile.proto && pbts -o proto/profile.d.ts proto/profile.js"
"pretest": "npm run compile && npm run rebuild"
},

@@ -35,3 +33,3 @@ "author": {

"pify": "^5.0.0",
"protobufjs": "^7.0.0",
"pprof-format": "^2.0.5",
"source-map": "^0.7.3",

@@ -38,0 +36,0 @@ "split": "^1.0.1"

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

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