@@ -16,17 +16,17 @@ if (!isPreloading()) {
1616 exitError ( "pprof-it must be required using the --require flag" ) ;
1717}
1818
19- import assert from "node:assert" ;
20- import fs from "node:fs" ;
21- import path from "node:path" ;
22- import { isMainThread } from "node:worker_threads" ;
23-
24- import * as pprof from "@datadog/pprof" ;
25- import { serializeTimeProfile } from "@datadog/pprof/out/src/profile-serializer" ;
26- import { TimeProfilerOptions } from "@datadog/pprof/out/src/time-profiler" ;
27- import { TimeProfiler as PProfTimeProfiler } from "@datadog/pprof/out/src/time-profiler-bindings" ;
28- import { Profile } from "pprof-format" ;
29- import { onExit as signalExit } from "signal-exit" ;
19+ import assert = require ( "node:assert" ) ;
20+ import fs = require ( "node:fs" ) ;
21+ import path = require ( "node:path" ) ;
22+ import worker_threads = require ( "node:worker_threads" ) ;
23+
24+ import pprof = require ( "@datadog/pprof" ) ;
25+ import pprofProfileSerializer = require ( "@datadog/pprof/out/src/profile-serializer" ) ;
26+ import type { TimeProfilerOptions } from "@datadog/pprof/out/src/time-profiler" ;
27+ import pprofTimeProfilerBindings = require ( "@datadog/pprof/out/src/time-profiler-bindings" ) ;
28+ import type { Profile } from "pprof-format" ;
29+ import signalExit = require ( "signal-exit" ) ;
3030
3131enum ProfilerName {
3232 Heap = "heap" ,
@@ -254,7 +254,7 @@ const DEFAULT_OPTIONS: TimeProfilerOptions = {
254254} ;
255255
256256class TimeProfiler extends Profiler {
257- private _timeProfiler : typeof PProfTimeProfiler ;
257+ private _timeProfiler : typeof pprofTimeProfilerBindings . TimeProfiler ;
258258
259259 constructor ( ) {
260260 super ( ProfilerName . Time , Options . timeOut ) ;
@@ -267,14 +267,17 @@ class TimeProfiler extends Profiler {
267267 lineNumbers : Options . lineNumbers ,
268268 } ;
269269
270- this . _timeProfiler = new PProfTimeProfiler ( { ...options , isMainThread } ) ;
270+ this . _timeProfiler = new pprofTimeProfilerBindings . TimeProfiler ( {
271+ ...options ,
272+ isMainThread : worker_threads . isMainThread ,
273+ } ) ;
271274 this . _timeProfiler . start ( ) ;
272275 }
273276
274277 protected _stop ( ) : Profile {
275278 const profile = this . _timeProfiler . stop ( false ) ;
276279
277- const serialized_profile = serializeTimeProfile (
280+ const serialized_profile = pprofProfileSerializer . serializeTimeProfile (
278281 profile ,
279282 Options . timeInterval ,
280283 /*gSourceMapper*/ undefined ,
@@ -288,7 +291,7 @@ class TimeProfiler extends Profiler {
288291
289292function onExit ( fn : ( ) => void ) {
290293 if ( Options . signalExit ) {
291- signalExit ( fn ) ;
294+ signalExit . onExit ( fn ) ;
292295 } else {
293296 process . on ( "exit" , fn ) ;
294297 }
0 commit comments