Skip to content

Commit 440ac30

Browse files
feat: add instrument hooks bindings
1 parent c9d2169 commit 440ac30

File tree

14 files changed

+247
-3
lines changed

14 files changed

+247
-3
lines changed

.eslintrc.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,8 @@
1010
"**/dist/**",
1111
"**/node_modules/**",
1212
"**/rollup.config.ts",
13-
"**/jest.config.js"
13+
"**/jest.config.js",
14+
"packages/core/src/native_core/instruments/hooks/**"
1415
],
1516
"settings": {
1617
"import/parsers": {

.github/workflows/ci.yml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ jobs:
1313
- uses: "actions/checkout@v4"
1414
with:
1515
fetch-depth: 0
16+
submodules: true
1617
- name: Install valgrind
1718
run: |
1819
sudo apt-get update
@@ -32,6 +33,9 @@ jobs:
3233
examples: ${{ steps.list-examples.outputs.examples }}
3334
steps:
3435
- uses: "actions/checkout@v4"
36+
with:
37+
fetch-depth: 0
38+
submodules: true
3539
# list the directories in ./examples and output them to a github action workflow variables as a JSON array
3640
- run: |
3741
examples=$(find ./examples -maxdepth 1 -mindepth 1 -type d -printf '%f\n' | jq -R -s -c 'split("\n") | map(select(length > 0))')
@@ -51,6 +55,7 @@ jobs:
5155
- uses: "actions/checkout@v4"
5256
with:
5357
fetch-depth: 0
58+
submodules: true
5459
- name: Install valgrind
5560
run: |
5661
sudo apt-get update

.github/workflows/codspeed.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ jobs:
1414
- uses: "actions/checkout@v4"
1515
with:
1616
fetch-depth: 0
17+
submodules: true
1718
- name: Install valgrind
1819
run: |
1920
sudo apt-get update
@@ -43,6 +44,7 @@ jobs:
4344
- uses: "actions/checkout@v4"
4445
with:
4546
fetch-depth: 0
47+
submodules: true
4648
- name: Install valgrind
4749
run: |
4850
sudo apt-get update

.github/workflows/release.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ jobs:
1717
- uses: actions/checkout@v4
1818
with:
1919
fetch-depth: 0
20+
submodules: true
2021
- uses: pnpm/action-setup@v2
2122
- uses: actions/setup-node@v3
2223
with:

.gitmodules

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
[submodule "packages/core/src/native_core/instruments/hooks"]
2+
path = packages/core/src/native_core/instruments/hooks
3+
url = [email protected]:CodSpeedHQ/instrument-hooks.git

.prettierignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,3 +2,4 @@ node_modules
22
.rollup.cache
33
dist
44
generated
5+
packages/core/src/native_core/instruments/hooks

packages/core/binding.gyp

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,14 +8,31 @@
88
"cflags_cc!": [
99
"-fno-exceptions"
1010
],
11+
"cflags": [
12+
"-Wno-maybe-uninitialized",
13+
"-Wno-unused-variable",
14+
"-Wno-unused-parameter",
15+
"-Wno-unused-but-set-variable",
16+
"-Wno-type-limits"
17+
],
18+
"cflags_cc": [
19+
"-Wno-maybe-uninitialized",
20+
"-Wno-unused-variable",
21+
"-Wno-unused-parameter",
22+
"-Wno-unused-but-set-variable",
23+
"-Wno-type-limits"
24+
],
1125
"sources": [
1226
"src/native_core/measurement/measurement.cc",
1327
"src/native_core/linux_perf/linux_perf.cc",
1428
"src/native_core/linux_perf/linux_perf_listener.cc",
29+
"src/native_core/instruments/hooks_wrapper.cc",
30+
"src/native_core/instruments/hooks/dist/core.c",
1531
"src/native_core/native_core.cc"
1632
],
1733
"include_dirs": [
18-
"<!@(node -p \"require('node-addon-api').include\")"
34+
"<!@(node -p \"require('node-addon-api').include\")",
35+
"src/native_core/instruments/hooks/includes"
1936
],
2037
"defines": [
2138
"NAPI_DISABLE_CPP_EXCEPTIONS"

packages/core/src/index.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,3 +53,4 @@ export { optimizeFunction, optimizeFunctionSync } from "./optimization";
5353
export * from "./utils";
5454
export * from "./walltime";
5555
export const Measurement = native_core.Measurement;
56+
export const InstrumentHooks = native_core.InstrumentHooks;

packages/core/src/native_core/index.ts

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,10 @@
11
import path from "path";
2+
import { InstrumentHooks } from "./instruments/hooks";
23
import { LinuxPerf } from "./linux_perf/linux_perf";
34
import { Measurement } from "./measurement/measurement";
45
interface NativeCore {
56
Measurement: Measurement;
7+
InstrumentHooks: InstrumentHooks;
68
LinuxPerf: typeof LinuxPerf;
79
}
810

@@ -37,7 +39,23 @@ try {
3739
return false;
3840
}
3941
},
40-
42+
InstrumentHooks: {
43+
isInstrumented: () => {
44+
return false;
45+
},
46+
startBenchmark: () => {
47+
return 0;
48+
},
49+
stopBenchmark: () => {
50+
return 0;
51+
},
52+
setExecutedBenchmark: (_pid: number, _uri: string) => {
53+
return 0;
54+
},
55+
setIntegration: (_name: string, _version: string) => {
56+
return 0;
57+
},
58+
},
4159
isBound: false,
4260
};
4361
}
Submodule hooks added at 568ce11

0 commit comments

Comments
 (0)