Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions .github/chainguard/self.github.release.push-tags.sts.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
issuer: https://token.actions.githubusercontent.com

subject: repo:DataDog/pprof-nodejs:environment:npm

claim_pattern:
event_name: push
job_workflow_ref: DataDog/pprof-nodejs/\.github/workflows/release\.yml@refs/heads/v[0-9]+\.x
ref: refs/heads/v[0-9]+\.x
repository: DataDog/pprof-nodejs

permissions:
contents: write
11 changes: 8 additions & 3 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,15 @@ jobs:
runs-on: ubuntu-latest
environment: npm
permissions:
id-token: write # Required for OIDC
id-token: write # Required for OIDC
contents: write
steps:
- uses: actions/checkout@v2
- uses: DataDog/dd-octo-sts-action@acaa02eee7e3bb0839e4272dacb37b8f3b58ba80 # v1.0.3
id: octo-sts
with:
scope: DataDog/pprof-nodejs
policy: self.github.release.push-tags
- uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 # v4.3.1
- uses: actions/download-artifact@v4
- uses: actions/setup-node@v3
with:
Expand All @@ -37,4 +42,4 @@ jobs:
echo "json=$content" >> $GITHUB_OUTPUT
- run: |
git tag v${{ fromJson(steps.pkg.outputs.json).version }}
git push origin v${{ fromJson(steps.pkg.outputs.json).version }}
git push https://x-access-token:${{ steps.octo-sts.outputs.token }}@github.com/${{ github.repository }}.git v${{ fromJson(steps.pkg.outputs.json).version }}
37 changes: 0 additions & 37 deletions bindings/profilers/wall.cc
Original file line number Diff line number Diff line change
Expand Up @@ -920,28 +920,6 @@ v8::ProfilerId WallProfiler::StartInternal() {
return result.id;
}

NAN_METHOD(WallProfiler::Stop) {
if (info.Length() != 1) {
return Nan::ThrowTypeError("Stop must have one argument.");
}
if (!info[0]->IsBoolean()) {
return Nan::ThrowTypeError("Restart must be a boolean.");
}

bool restart = info[0].As<Boolean>()->Value();

WallProfiler* wallProfiler =
Nan::ObjectWrap::Unwrap<WallProfiler>(info.This());

v8::Local<v8::Value> profile;
auto err = wallProfiler->StopImpl(restart, profile);

if (!err.success) {
return Nan::ThrowTypeError(err.msg.c_str());
}
info.GetReturnValue().Set(profile);
}

// stopAndCollect(restart, callback): callback result
NAN_METHOD(WallProfiler::StopAndCollect) {
if (info.Length() != 2) {
Expand Down Expand Up @@ -1100,20 +1078,6 @@ Result WallProfiler::StopCore(bool restart, ProfileBuilder&& buildProfile) {
return {};
}

Result WallProfiler::StopImpl(bool restart, v8::Local<v8::Value>& profile) {
return StopCore(restart,
[&](const v8::CpuProfile* v8_profile,
bool hasCpuTime,
int64_t nonJSThreadsCpuTime,
ContextsByNode* contextsByNodePtr) {
profile = TranslateTimeProfile(v8_profile,
includeLines_,
contextsByNodePtr,
hasCpuTime,
nonJSThreadsCpuTime);
});
}

Result WallProfiler::StopAndCollectImpl(bool restart,
v8::Local<v8::Function> callback,
v8::Local<v8::Value>& result) {
Expand Down Expand Up @@ -1148,7 +1112,6 @@ NAN_MODULE_INIT(WallProfiler::Init) {
SetContext);

Nan::SetPrototypeMethod(tpl, "start", Start);
Nan::SetPrototypeMethod(tpl, "stop", Stop);
Nan::SetPrototypeMethod(tpl, "stopAndCollect", StopAndCollect);
Nan::SetPrototypeMethod(tpl, "dispose", Dispose);
Nan::SetPrototypeMethod(tpl,
Expand Down
2 changes: 0 additions & 2 deletions bindings/profilers/wall.hh
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,6 @@ class WallProfiler : public Nan::ObjectWrap {
v8::ProfilerId StartInternal();
template <typename ProfileBuilder>
Result StopCore(bool restart, ProfileBuilder&& buildProfile);
Result StopImpl(bool restart, v8::Local<v8::Value>& profile);
Result StopAndCollectImpl(bool restart,
v8::Local<v8::Function> callback,
v8::Local<v8::Value>& result);
Expand Down Expand Up @@ -189,7 +188,6 @@ class WallProfiler : public Nan::ObjectWrap {

static NAN_METHOD(New);
static NAN_METHOD(Start);
static NAN_METHOD(Stop);
static NAN_METHOD(StopAndCollect);
static NAN_METHOD(V8ProfilerStuckEventLoopDetected);
static NAN_METHOD(Dispose);
Expand Down
12 changes: 6 additions & 6 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@datadog/pprof",
"version": "5.14.0",
"version": "5.14.1",
"description": "pprof support for Node.js",
"repository": {
"type": "git",
Expand Down Expand Up @@ -53,7 +53,7 @@
"gts": "^7.0.0",
"js-green-licenses": "^4.0.0",
"mocha": "^11.7.5",
"nan": "^2.23.1",
"nan": "^2.26.2",
"nyc": "^18.0.0",
"semver": "^7.7.4",
"sinon": "^21.0.3",
Expand Down
1 change: 0 additions & 1 deletion ts/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@ export const time = {
profile: timeProfiler.profile,
start: timeProfiler.start,
stop: timeProfiler.stop,
profileV2: timeProfiler.profileV2,
getContext: timeProfiler.getContext,
setContext: timeProfiler.setContext,
runWithContext: timeProfiler.runWithContext,
Expand Down
45 changes: 5 additions & 40 deletions ts/src/time-profiler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ type Microseconds = number;
type Milliseconds = number;

type NativeTimeProfiler = InstanceType<typeof TimeProfiler> & {
stopAndCollect?: <T>(
stopAndCollect: <T>(
restart: boolean,
callback: (profile: TimeProfile) => T,
) => T;
Expand All @@ -65,7 +65,7 @@ function handleStopRestart() {
// a loop eating 100% CPU, leading to empty profiles.
// Fully stop and restart the profiler to reset the profile to a valid state.
if (gV8ProfilerStuckEventLoopDetected > 0) {
gProfiler.stop(false);
gProfiler.stopAndCollect(false, () => undefined);
gProfiler.start();
}
}
Expand Down Expand Up @@ -126,13 +126,6 @@ export async function profile(options: TimeProfilerOptions = {}) {
return stop();
}

export async function profileV2(options: TimeProfilerOptions = {}) {
options = {...DEFAULT_OPTIONS, ...options};
start(options);
await setTimeout(options.durationMillis!);
return stopV2();
}

// Temporarily retained for backwards compatibility with older tracer
export function start(options: TimeProfilerOptions = {}) {
options = {...DEFAULT_OPTIONS, ...options};
Expand All @@ -155,39 +148,11 @@ export function start(options: TimeProfilerOptions = {}) {
}
}

export function stop(
restart = false,
generateLabels?: GenerateTimeLabelsFunction,
lowCardinalityLabels?: string[],
) {
if (!gProfiler) {
throw new Error('Wall profiler is not started');
}

const profile = gProfiler.stop(restart);
if (restart) {
handleStopRestart();
} else {
handleStopNoRestart();
}

const serializedProfile = serializeTimeProfile(
profile,
gIntervalMicros,
gSourceMapper,
true,
generateLabels,
lowCardinalityLabels,
);
return serializedProfile;
}

/**
* Same as stop() but uses the lazy callback path: serialization happens inside
* a native callback while the V8 profile is still alive.
* This reduces memory overhead.
* Serializes the profile inside a native callback while the V8 profile is
* still alive. This reduces memory overhead.
*/
export function stopV2(
export function stop(
restart = false,
generateLabels?: GenerateTimeLabelsFunction,
lowCardinalityLabels?: string[],
Expand Down
Loading
Loading