Skip to content

Commit 27300db

Browse files
committed
Copy build/lint setup from node-profiling repository
1 parent df55ce4 commit 27300db

21 files changed

+3392
-225
lines changed

.editorconfig

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
root = true
2+
3+
[*]
4+
indent_style = space
5+
indent_size = 2
6+
charset = utf-8
7+
trim_trailing_whitespace = true
8+
insert_final_newline = true
9+
10+
[*.md]
11+
trim_trailing_whitespace = false

.eslintignore

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
node_modules/
2+
build/
3+
lib/
4+
coverage/

.eslintrc.js

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
module.exports = {
2+
extends: ['@sentry-internal/sdk'],
3+
env: {
4+
node: true,
5+
es6: true,
6+
},
7+
parserOptions: {
8+
sourceType: 'module',
9+
ecmaVersion: 2020,
10+
project: './tsconfig.json',
11+
},
12+
ignorePatterns: ['lib/**/*'],
13+
rules: {},
14+
overrides: [
15+
{
16+
files: ['test/**'],
17+
rules: {
18+
'no-console': 'off',
19+
'no-unused-vars': 'off',
20+
}
21+
},
22+
{
23+
files: ['scripts/**'],
24+
rules: {
25+
'no-console': 'off',
26+
}
27+
},
28+
],
29+
};

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,3 @@
11
node_modules/
22
build/
3+
lib/

.vscode/c_cpp_properties.json

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
{
2+
"configurations": [
3+
{
4+
"name": "Mac",
5+
"includePath": [
6+
"${workspaceFolder}/**",
7+
"${userHome}/Library/Caches/node-gyp/**"
8+
],
9+
"defines": [],
10+
"compilerPath": "/usr/bin/clang",
11+
"intelliSenseMode": "macos-clang-arm64",
12+
"cStandard": "c17",
13+
"cppStandard": "c++17"
14+
}
15+
],
16+
"version": 4
17+
}

README.md

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# `cross-thread-stack-trace`
1+
# `@sentry-internal/node-native-stacktrace`
22

33
Native Node module to capture stack traces from all registered threads.
44

@@ -8,15 +8,15 @@ thread, even if the event loops are blocked.
88
In the main or worker threads:
99

1010
```ts
11-
const { registerThread } = require("cross-thread-stack-trace");
11+
const { registerThread } = require("@sentry-internal/node-native-stacktrace");
1212

1313
registerThread();
1414
```
1515

1616
Watchdog thread:
1717

1818
```ts
19-
const { captureStackTrace } = require("cross-thread-stack-trace");
19+
const { captureStackTrace } = require("@sentry-internal/node-native-stacktrace");
2020

2121
const stacks = captureStackTrace();
2222
console.log(stacks);
@@ -87,28 +87,29 @@ In the main or worker threads if you call `registerThread()` regularly, times
8787
are recorded.
8888

8989
```ts
90-
const { registerThread } = require("cross-thread-stack-trace");
90+
const { registerThread } = require("@sentry-internal/node-native-stacktrace");
9191

9292
setInterval(() => {
9393
registerThread();
9494
}, 200);
9595
```
9696

97-
In the watchdog thread you can call `getThreadLastSeen()` to get how long it's
97+
In the watchdog thread you can call `getThreadsLastSeen()` to get how long it's
9898
been in milliseconds since each thread registered.
9999

100100
If any thread has exceeded a threshold, you can call `captureStackTrace()` to
101101
get the stack traces for all threads.
102102

103103
```ts
104-
const { captureStackTrace, getThreadLastSeen } = require(
105-
"cross-thread-stack-trace",
106-
);
104+
const {
105+
captureStackTrace,
106+
getThreadsLastSeen,
107+
} = require("@sentry-internal/node-native-stacktrace");
107108

108109
const THRESHOLD = 1000; // 1 second
109110

110111
setInterval(() => {
111-
for (const [thread, time] in Object.entries(getThreadLastSeen())) {
112+
for (const [thread, time] in Object.entries(getThreadsLastSeen())) {
112113
if (time > THRESHOLD) {
113114
const stacks = captureStackTrace();
114115
const blockedThread = stacks[thread];

binding.gyp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
{
22
"targets": [
33
{
4-
"target_name": "cross-thread-stack-trace",
4+
"target_name": "stack-trace",
55
"sources": [ "module.cc" ]
66
}
77
]
8-
}
8+
}

index.d.ts

Lines changed: 0 additions & 15 deletions
This file was deleted.

index.js

Lines changed: 0 additions & 12 deletions
This file was deleted.

0 commit comments

Comments
 (0)