@datadog/pprof
Advanced tools
Comparing version 1.0.3 to 1.1.0
@@ -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 labelSet of entry.node.labelSets) { | ||
const sample = new profile_1.perftools.profiles.Sample({ | ||
const sample = new pprof_format_1.Sample({ | ||
locationId: entry.stack, | ||
@@ -276,3 +252,3 @@ value: [1, intervalNanos], | ||
if (unknownEntryCount > 0) { | ||
const sample = new profile_1.perftools.profiles.Sample({ | ||
const sample = new pprof_format_1.Sample({ | ||
locationId: entry.stack, | ||
@@ -288,3 +264,3 @@ value: [ | ||
}; | ||
const stringTable = new StringTable(); | ||
const stringTable = new pprof_format_1.StringTable(); | ||
const sampleValueType = createSampleCountValueType(stringTable); | ||
@@ -301,3 +277,3 @@ // const wallValueType = createTimeValueType(stringTable); | ||
serialize(profile, prof.topDownRoot, appendCpuEntryToSamples, stringTable, undefined, sourceMapper); | ||
return profile; | ||
return new pprof_format_1.Profile(profile); | ||
} | ||
@@ -319,3 +295,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, | ||
@@ -329,3 +305,3 @@ value: [alloc.count, alloc.sizeBytes * alloc.count], | ||
}; | ||
const stringTable = new StringTable(); | ||
const stringTable = new pprof_format_1.StringTable(); | ||
const sampleValueType = createObjectCountValueType(stringTable); | ||
@@ -340,5 +316,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": "1.0.3", | ||
"version": "1.1.0", | ||
"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" | ||
}, | ||
@@ -33,7 +31,6 @@ "author": { | ||
"findit2": "^2.2.3", | ||
"nan": "^2.16.0", | ||
"node-gyp-build": "^3.9.0", | ||
"p-limit": "^3.1.0", | ||
"pify": "^5.0.0", | ||
"protobufjs": "^7.0.0", | ||
"pprof-format": "^2.0.4", | ||
"source-map": "^0.7.3", | ||
@@ -66,2 +63,3 @@ "split": "^1.0.1" | ||
"mocha": "^9.2.2", | ||
"nan": "^2.17.0", | ||
"nyc": "^15.0.0", | ||
@@ -68,0 +66,0 @@ "protobufjs-cli": "^1.0.2", |
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
Native code
Supply chain riskContains native code (e.g., compiled binaries or shared libraries). Including native code can obscure malicious behavior.
Found 14 instances 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
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
Uses eval
Supply chain riskPackage uses dynamic code execution (e.g., eval()), which is a dangerous practice. This can prevent the code from running in certain environments and increases the risk that the code may contain exploits or malicious behavior.
Found 1 instance in 1 package
10683112
8
104
34
1569
65
+ Addedpprof-format@^2.0.4
+ Addedpprof-format@2.1.0(transitive)
- Removednan@^2.16.0
- Removedprotobufjs@^7.0.0
- Removed@protobufjs/aspromise@1.1.2(transitive)
- Removed@protobufjs/base64@1.1.2(transitive)
- Removed@protobufjs/codegen@2.0.4(transitive)
- Removed@protobufjs/eventemitter@1.1.0(transitive)
- Removed@protobufjs/fetch@1.1.0(transitive)
- Removed@protobufjs/float@1.0.2(transitive)
- Removed@protobufjs/inquire@1.1.0(transitive)
- Removed@protobufjs/path@1.1.2(transitive)
- Removed@protobufjs/pool@1.1.0(transitive)
- Removed@protobufjs/utf8@1.1.0(transitive)
- Removed@types/node@22.10.2(transitive)
- Removedlong@5.2.3(transitive)
- Removednan@2.22.0(transitive)
- Removedprotobufjs@7.4.0(transitive)
- Removedundici-types@6.20.0(transitive)