Skip to content

Commit 87ad0fe

Browse files
authored
test(node): Add hapi auto instrumentation test for @sentry/node-experimental (#10382)
Ref #9907 This actually tests `@hapi/[email protected]` because the latest v21 is not supported by the otel auto-instrumentation.
1 parent b3af0dc commit 87ad0fe

File tree

5 files changed

+265
-7
lines changed

5 files changed

+265
-7
lines changed

dev-packages/node-integration-tests/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@
2727
"test:watch": "yarn test --watch"
2828
},
2929
"dependencies": {
30+
"@hapi/hapi": "^20.3.0",
3031
"@prisma/client": "3.15.2",
3132
"@sentry/node": "7.98.0",
3233
"@sentry/tracing": "7.98.0",

dev-packages/node-integration-tests/src/index.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,3 +29,11 @@ export function startExpressServerAndSendPortToRunner(app: Express): void {
2929
console.log(`{"port":${address.port}}`);
3030
});
3131
}
32+
33+
/**
34+
* Sends the port to the runner
35+
*/
36+
export function sendPortToRunner(port: number): void {
37+
// eslint-disable-next-line no-console
38+
console.log(`{"port":${port}}`);
39+
}
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
const { loggingTransport, sendPortToRunner } = require('@sentry-internal/node-integration-tests');
2+
const Sentry = require('@sentry/node-experimental');
3+
4+
Sentry.init({
5+
dsn: 'https://[email protected]/1337',
6+
release: '1.0',
7+
debug: true,
8+
tracesSampleRate: 1.0,
9+
transport: loggingTransport,
10+
});
11+
12+
const Hapi = require('@hapi/hapi');
13+
14+
const port = 5999;
15+
16+
const init = async () => {
17+
const server = Hapi.server({
18+
host: 'localhost',
19+
port,
20+
});
21+
22+
server.route({
23+
method: 'GET',
24+
path: '/',
25+
handler: (_request, _h) => {
26+
return 'Hello World!';
27+
},
28+
});
29+
30+
await server.start();
31+
32+
sendPortToRunner(port);
33+
};
34+
35+
init();
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
import { conditionalTest } from '../../../utils';
2+
import { cleanupChildProcesses, createRunner } from '../../../utils/runner';
3+
4+
jest.setTimeout(20000);
5+
6+
conditionalTest({ min: 14 })('hapi auto-instrumentation', () => {
7+
afterAll(async () => {
8+
cleanupChildProcesses();
9+
});
10+
11+
const EXPECTED_TRANSACTION = {
12+
transaction: 'GET /',
13+
spans: expect.arrayContaining([
14+
expect.objectContaining({
15+
data: expect.objectContaining({
16+
'http.route': '/',
17+
'http.method': 'GET',
18+
'hapi.type': 'router',
19+
'sentry.origin': 'manual',
20+
'sentry.op': 'http',
21+
}),
22+
description: 'GET /',
23+
op: 'http',
24+
status: 'ok',
25+
}),
26+
]),
27+
};
28+
29+
test('CJS - should auto-instrument `@hapi/hapi` package.', done => {
30+
createRunner(__dirname, 'scenario.js')
31+
.expect({ transaction: EXPECTED_TRANSACTION })
32+
.start(done)
33+
.makeRequest('get', '/');
34+
});
35+
});

yarn.lock

Lines changed: 186 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3541,6 +3541,21 @@
35413541
"@hapi/boom" "9.x.x"
35423542
"@hapi/hoek" "9.x.x"
35433543

3544+
"@hapi/accept@^5.0.1":
3545+
version "5.0.2"
3546+
resolved "https://registry.yarnpkg.com/@hapi/accept/-/accept-5.0.2.tgz#ab7043b037e68b722f93f376afb05e85c0699523"
3547+
integrity sha512-CmzBx/bXUR8451fnZRuZAJRlzgm0Jgu5dltTX/bszmR2lheb9BpyN47Q1RbaGTsvFzn0PXAEs+lXDKfshccYZw==
3548+
dependencies:
3549+
"@hapi/boom" "9.x.x"
3550+
"@hapi/hoek" "9.x.x"
3551+
3552+
"@hapi/ammo@^5.0.1":
3553+
version "5.0.1"
3554+
resolved "https://registry.yarnpkg.com/@hapi/ammo/-/ammo-5.0.1.tgz#9d34560f5c214eda563d838c01297387efaab490"
3555+
integrity sha512-FbCNwcTbnQP4VYYhLNGZmA76xb2aHg9AMPiy18NZyWMG310P5KdFGyA9v2rm5ujrIny77dEEIkMOwl0Xv+fSSA==
3556+
dependencies:
3557+
"@hapi/hoek" "9.x.x"
3558+
35443559
35453560
version "5.0.0"
35463561
resolved "https://registry.yarnpkg.com/@hapi/b64/-/b64-5.0.0.tgz#b8210cbd72f4774985e78569b77e97498d24277d"
@@ -3555,36 +3570,115 @@
35553570
dependencies:
35563571
"@hapi/hoek" "9.x.x"
35573572

3558-
"@hapi/boom@^9.0.0":
3573+
"@hapi/boom@^9.0.0", "@hapi/boom@^9.1.0":
35593574
version "9.1.4"
35603575
resolved "https://registry.yarnpkg.com/@hapi/boom/-/boom-9.1.4.tgz#1f9dad367c6a7da9f8def24b4a986fc5a7bd9db6"
35613576
integrity sha512-Ls1oH8jaN1vNsqcaHVYJrKmgMcKsC1wcp8bujvXrHaAqD2iDYq3HoOwsxwo09Cuda5R5nC0o0IxlrlTuvPuzSw==
35623577
dependencies:
35633578
"@hapi/hoek" "9.x.x"
35643579

3580+
"@hapi/[email protected]", "@hapi/bounce@^2.0.0":
3581+
version "2.0.0"
3582+
resolved "https://registry.yarnpkg.com/@hapi/bounce/-/bounce-2.0.0.tgz#e6ef56991c366b1e2738b2cd83b01354d938cf3d"
3583+
integrity sha512-JesW92uyzOOyuzJKjoLHM1ThiOvHPOLDHw01YV8yh5nCso7sDwJho1h0Ad2N+E62bZyz46TG3xhAi/78Gsct6A==
3584+
dependencies:
3585+
"@hapi/boom" "9.x.x"
3586+
"@hapi/hoek" "9.x.x"
3587+
35653588
35663589
version "2.1.0"
35673590
resolved "https://registry.yarnpkg.com/@hapi/bourne/-/bourne-2.1.0.tgz#66aff77094dc3080bd5df44ec63881f2676eb020"
35683591
integrity sha512-i1BpaNDVLJdRBEKeJWkVO6tYX6DMFBuwMhSuWqLsY4ufeTKGVuV5rBsUhxPayXqnnWHgXUAmWK16H/ykO5Wj4Q==
35693592

3593+
"@hapi/call@^8.0.0":
3594+
version "8.0.1"
3595+
resolved "https://registry.yarnpkg.com/@hapi/call/-/call-8.0.1.tgz#9e64cd8ba6128eb5be6e432caaa572b1ed8cd7c0"
3596+
integrity sha512-bOff6GTdOnoe5b8oXRV3lwkQSb/LAWylvDMae6RgEWWntd0SHtkYbQukDHKlfaYtVnSAgIavJ0kqszF/AIBb6g==
3597+
dependencies:
3598+
"@hapi/boom" "9.x.x"
3599+
"@hapi/hoek" "9.x.x"
3600+
3601+
"@hapi/catbox-memory@^5.0.0":
3602+
version "5.0.1"
3603+
resolved "https://registry.yarnpkg.com/@hapi/catbox-memory/-/catbox-memory-5.0.1.tgz#cb63fca0ded01d445a2573b38eb2688df67f70ac"
3604+
integrity sha512-QWw9nOYJq5PlvChLWV8i6hQHJYfvdqiXdvTupJFh0eqLZ64Xir7mKNi96d5/ZMUAqXPursfNDIDxjFgoEDUqeQ==
3605+
dependencies:
3606+
"@hapi/boom" "9.x.x"
3607+
"@hapi/hoek" "9.x.x"
3608+
3609+
"@hapi/catbox@^11.1.1":
3610+
version "11.1.1"
3611+
resolved "https://registry.yarnpkg.com/@hapi/catbox/-/catbox-11.1.1.tgz#d277e2d5023fd69cddb33d05b224ea03065fec0c"
3612+
integrity sha512-u/8HvB7dD/6X8hsZIpskSDo4yMKpHxFd7NluoylhGrL6cUfYxdQPnvUp9YU2C6F9hsyBVLGulBd9vBN1ebfXOQ==
3613+
dependencies:
3614+
"@hapi/boom" "9.x.x"
3615+
"@hapi/hoek" "9.x.x"
3616+
"@hapi/podium" "4.x.x"
3617+
"@hapi/validate" "1.x.x"
3618+
3619+
"@hapi/content@^5.0.2":
3620+
version "5.0.2"
3621+
resolved "https://registry.yarnpkg.com/@hapi/content/-/content-5.0.2.tgz#ae57954761de570392763e64cdd75f074176a804"
3622+
integrity sha512-mre4dl1ygd4ZyOH3tiYBrOUBzV7Pu/EOs8VLGf58vtOEECWed8Uuw6B4iR9AN/8uQt42tB04qpVaMyoMQh0oMw==
3623+
dependencies:
3624+
"@hapi/boom" "9.x.x"
3625+
35703626
35713627
version "5.1.0"
35723628
resolved "https://registry.yarnpkg.com/@hapi/cryptiles/-/cryptiles-5.1.0.tgz#655de4cbbc052c947f696148c83b187fc2be8f43"
35733629
integrity sha512-fo9+d1Ba5/FIoMySfMqPBR/7Pa29J2RsiPrl7bkwo5W5o+AN1dAYQRi4SPrPwwVxVGKjgLOEWrsvt1BonJSfLA==
35743630
dependencies:
35753631
"@hapi/boom" "9.x.x"
35763632

3633+
3634+
version "2.0.0"
3635+
resolved "https://registry.yarnpkg.com/@hapi/file/-/file-2.0.0.tgz#2ecda37d1ae9d3078a67c13b7da86e8c3237dfb9"
3636+
integrity sha512-WSrlgpvEqgPWkI18kkGELEZfXr0bYLtr16iIN4Krh9sRnzBZN6nnWxHFxtsnP684wueEySBbXPDg/WfA9xJdBQ==
3637+
3638+
"@hapi/hapi@^20.3.0":
3639+
version "20.3.0"
3640+
resolved "https://registry.yarnpkg.com/@hapi/hapi/-/hapi-20.3.0.tgz#1d620005afeebcb2c8170352286a4664b0107c15"
3641+
integrity sha512-zvPSRvaQyF3S6Nev9aiAzko2/hIFZmNSJNcs07qdVaVAvj8dGJSV4fVUuQSnufYJAGiSau+U5LxMLhx79se5WA==
3642+
dependencies:
3643+
"@hapi/accept" "^5.0.1"
3644+
"@hapi/ammo" "^5.0.1"
3645+
"@hapi/boom" "^9.1.0"
3646+
"@hapi/bounce" "^2.0.0"
3647+
"@hapi/call" "^8.0.0"
3648+
"@hapi/catbox" "^11.1.1"
3649+
"@hapi/catbox-memory" "^5.0.0"
3650+
"@hapi/heavy" "^7.0.1"
3651+
"@hapi/hoek" "^9.0.4"
3652+
"@hapi/mimos" "^6.0.0"
3653+
"@hapi/podium" "^4.1.1"
3654+
"@hapi/shot" "^5.0.5"
3655+
"@hapi/somever" "^3.0.0"
3656+
"@hapi/statehood" "^7.0.3"
3657+
"@hapi/subtext" "^7.1.0"
3658+
"@hapi/teamwork" "^5.1.0"
3659+
"@hapi/topo" "^5.0.0"
3660+
"@hapi/validate" "^1.1.1"
3661+
3662+
"@hapi/heavy@^7.0.1":
3663+
version "7.0.1"
3664+
resolved "https://registry.yarnpkg.com/@hapi/heavy/-/heavy-7.0.1.tgz#73315ae33b6e7682a0906b7a11e8ca70e3045874"
3665+
integrity sha512-vJ/vzRQ13MtRzz6Qd4zRHWS3FaUc/5uivV2TIuExGTM9Qk+7Zzqj0e2G7EpE6KztO9SalTbiIkTh7qFKj/33cA==
3666+
dependencies:
3667+
"@hapi/boom" "9.x.x"
3668+
"@hapi/hoek" "9.x.x"
3669+
"@hapi/validate" "1.x.x"
3670+
35773671
35783672
version "9.2.0"
35793673
resolved "https://registry.yarnpkg.com/@hapi/hoek/-/hoek-9.2.0.tgz#f3933a44e365864f4dad5db94158106d511e8131"
35803674
integrity sha512-sqKVVVOe5ivCaXDWivIJYVSaEgdQK9ul7a4Kity5Iw7u9+wBAPbX1RMSnLLmp7O4Vzj0WOWwMAJsTL00xwaNug==
35813675

3582-
"@hapi/hoek@^9.0.0":
3676+
"@hapi/hoek@^9.0.0", "@hapi/hoek@^9.0.4":
35833677
version "9.3.0"
35843678
resolved "https://registry.yarnpkg.com/@hapi/hoek/-/hoek-9.3.0.tgz#8368869dcb735be2e7f5cb7647de78e167a251fb"
35853679
integrity sha512-/c6rf4UJlmHlC9b5BaNvzAcFv7HZ2QHaV0D4/HNlBdvFnvQq8RI4kYdhyPCl7Xj+oWvTWQ8ujhqS53LIgAe6KQ==
35863680

3587-
"@hapi/iron@^6.0.0":
3681+
"@hapi/iron@6.x.x", "@hapi/iron@^6.0.0":
35883682
version "6.0.0"
35893683
resolved "https://registry.yarnpkg.com/@hapi/iron/-/iron-6.0.0.tgz#ca3f9136cda655bdd6028de0045da0de3d14436f"
35903684
integrity sha512-zvGvWDufiTGpTJPG1Y/McN8UqWBu0k/xs/7l++HVU535NLHXsHhy54cfEMdW7EjwKfbBfM9Xy25FmTiobb7Hvw==
@@ -3595,7 +3689,34 @@
35953689
"@hapi/cryptiles" "5.x.x"
35963690
"@hapi/hoek" "9.x.x"
35973691

3598-
"@hapi/podium@^4.1.3":
3692+
"@hapi/mimos@^6.0.0":
3693+
version "6.0.0"
3694+
resolved "https://registry.yarnpkg.com/@hapi/mimos/-/mimos-6.0.0.tgz#daa523d9c07222c7e8860cb7c9c5501fd6506484"
3695+
integrity sha512-Op/67tr1I+JafN3R3XN5DucVSxKRT/Tc+tUszDwENoNpolxeXkhrJ2Czt6B6AAqrespHoivhgZBWYSuANN9QXg==
3696+
dependencies:
3697+
"@hapi/hoek" "9.x.x"
3698+
mime-db "1.x.x"
3699+
3700+
3701+
version "4.0.2"
3702+
resolved "https://registry.yarnpkg.com/@hapi/nigel/-/nigel-4.0.2.tgz#8f84ef4bca4fb03b2376463578f253b0b8e863c4"
3703+
integrity sha512-ht2KoEsDW22BxQOEkLEJaqfpoKPXxi7tvabXy7B/77eFtOyG5ZEstfZwxHQcqAiZhp58Ae5vkhEqI03kawkYNw==
3704+
dependencies:
3705+
"@hapi/hoek" "^9.0.4"
3706+
"@hapi/vise" "^4.0.0"
3707+
3708+
"@hapi/pez@^5.1.0":
3709+
version "5.1.0"
3710+
resolved "https://registry.yarnpkg.com/@hapi/pez/-/pez-5.1.0.tgz#c03a5e01f8be01cfabc4c0017631e619586321c1"
3711+
integrity sha512-YfB0btnkLB3lb6Ry/1KifnMPBm5ZPfaAHWFskzOMAgDgXgcBgA+zjpIynyEiBfWEz22DBT8o1e2tAaBdlt8zbw==
3712+
dependencies:
3713+
"@hapi/b64" "5.x.x"
3714+
"@hapi/boom" "9.x.x"
3715+
"@hapi/content" "^5.0.2"
3716+
"@hapi/hoek" "9.x.x"
3717+
"@hapi/nigel" "4.x.x"
3718+
3719+
"@hapi/[email protected]", "@hapi/podium@^4.1.1", "@hapi/podium@^4.1.3":
35993720
version "4.1.3"
36003721
resolved "https://registry.yarnpkg.com/@hapi/podium/-/podium-4.1.3.tgz#91e20838fc2b5437f511d664aabebbb393578a26"
36013722
integrity sha512-ljsKGQzLkFqnQxE7qeanvgGj4dejnciErYd30dbrYzUOF/FyS/DOF97qcrT3bhoVwCYmxa6PEMhxfCPlnUcD2g==
@@ -3604,7 +3725,49 @@
36043725
"@hapi/teamwork" "5.x.x"
36053726
"@hapi/validate" "1.x.x"
36063727

3607-
3728+
"@hapi/shot@^5.0.5":
3729+
version "5.0.5"
3730+
resolved "https://registry.yarnpkg.com/@hapi/shot/-/shot-5.0.5.tgz#a25c23d18973bec93c7969c51bf9579632a5bebd"
3731+
integrity sha512-x5AMSZ5+j+Paa8KdfCoKh+klB78otxF+vcJR/IoN91Vo2e5ulXIW6HUsFTCU+4W6P/Etaip9nmdAx2zWDimB2A==
3732+
dependencies:
3733+
"@hapi/hoek" "9.x.x"
3734+
"@hapi/validate" "1.x.x"
3735+
3736+
"@hapi/somever@^3.0.0":
3737+
version "3.0.1"
3738+
resolved "https://registry.yarnpkg.com/@hapi/somever/-/somever-3.0.1.tgz#9961cd5bdbeb5bb1edc0b2acdd0bb424066aadcc"
3739+
integrity sha512-4ZTSN3YAHtgpY/M4GOtHUXgi6uZtG9nEZfNI6QrArhK0XN/RDVgijlb9kOmXwCR5VclDSkBul9FBvhSuKXx9+w==
3740+
dependencies:
3741+
"@hapi/bounce" "2.x.x"
3742+
"@hapi/hoek" "9.x.x"
3743+
3744+
"@hapi/statehood@^7.0.3":
3745+
version "7.0.4"
3746+
resolved "https://registry.yarnpkg.com/@hapi/statehood/-/statehood-7.0.4.tgz#6acb9d0817b5c657089356f7d9fd60af0bce4f41"
3747+
integrity sha512-Fia6atroOVmc5+2bNOxF6Zv9vpbNAjEXNcUbWXavDqhnJDlchwUUwKS5LCi5mGtCTxRhUKKHwuxuBZJkmLZ7fw==
3748+
dependencies:
3749+
"@hapi/boom" "9.x.x"
3750+
"@hapi/bounce" "2.x.x"
3751+
"@hapi/bourne" "2.x.x"
3752+
"@hapi/cryptiles" "5.x.x"
3753+
"@hapi/hoek" "9.x.x"
3754+
"@hapi/iron" "6.x.x"
3755+
"@hapi/validate" "1.x.x"
3756+
3757+
"@hapi/subtext@^7.1.0":
3758+
version "7.1.0"
3759+
resolved "https://registry.yarnpkg.com/@hapi/subtext/-/subtext-7.1.0.tgz#b4d1ea2aeab1923ac130a24e75921e38fab5b15b"
3760+
integrity sha512-n94cU6hlvsNRIpXaROzBNEJGwxC+HA69q769pChzej84On8vsU14guHDub7Pphr/pqn5b93zV3IkMPDU5AUiXA==
3761+
dependencies:
3762+
"@hapi/boom" "9.x.x"
3763+
"@hapi/bourne" "2.x.x"
3764+
"@hapi/content" "^5.0.2"
3765+
"@hapi/file" "2.x.x"
3766+
"@hapi/hoek" "9.x.x"
3767+
"@hapi/pez" "^5.1.0"
3768+
"@hapi/wreck" "17.x.x"
3769+
3770+
"@hapi/[email protected]", "@hapi/teamwork@^5.1.0":
36083771
version "5.1.1"
36093772
resolved "https://registry.yarnpkg.com/@hapi/teamwork/-/teamwork-5.1.1.tgz#4d2ba3cac19118a36c44bf49a3a47674de52e4e4"
36103773
integrity sha512-1oPx9AE5TIv+V6Ih54RP9lTZBso3rP8j4Xhb6iSVwPXtAM+sDopl5TFMv5Paw73UnpZJ9gjcrTE1BXrWt9eQrg==
@@ -3616,14 +3779,30 @@
36163779
dependencies:
36173780
"@hapi/hoek" "^9.0.0"
36183781

3619-
3782+
"@hapi/[email protected]", "@hapi/validate@^1.1.1":
36203783
version "1.1.3"
36213784
resolved "https://registry.yarnpkg.com/@hapi/validate/-/validate-1.1.3.tgz#f750a07283929e09b51aa16be34affb44e1931ad"
36223785
integrity sha512-/XMR0N0wjw0Twzq2pQOzPBZlDzkekGcoCtzO314BpIEsbXdYGthQUbxgkGDf4nhk1+IPDAsXqWjMohRQYO06UA==
36233786
dependencies:
36243787
"@hapi/hoek" "^9.0.0"
36253788
"@hapi/topo" "^5.0.0"
36263789

3790+
"@hapi/vise@^4.0.0":
3791+
version "4.0.0"
3792+
resolved "https://registry.yarnpkg.com/@hapi/vise/-/vise-4.0.0.tgz#c6a94fe121b94a53bf99e7489f7fcc74c104db02"
3793+
integrity sha512-eYyLkuUiFZTer59h+SGy7hUm+qE9p+UemePTHLlIWppEd+wExn3Df5jO04bFQTm7nleF5V8CtuYQYb+VFpZ6Sg==
3794+
dependencies:
3795+
"@hapi/hoek" "9.x.x"
3796+
3797+
3798+
version "17.2.0"
3799+
resolved "https://registry.yarnpkg.com/@hapi/wreck/-/wreck-17.2.0.tgz#a5b69b724fa8fa25550fb02f55c649becfc59f63"
3800+
integrity sha512-pJ5kjYoRPYDv+eIuiLQqhGon341fr2bNIYZjuotuPJG/3Ilzr/XtI+JAp0A86E2bYfsS3zBPABuS2ICkaXFT8g==
3801+
dependencies:
3802+
"@hapi/boom" "9.x.x"
3803+
"@hapi/bourne" "2.x.x"
3804+
"@hapi/hoek" "9.x.x"
3805+
36273806
"@humanwhocodes/config-array@^0.5.0":
36283807
version "0.5.0"
36293808
resolved "https://registry.yarnpkg.com/@humanwhocodes/config-array/-/config-array-0.5.0.tgz#1407967d4c6eecd7388f83acf1eaf4d0c6e58ef9"
@@ -21706,7 +21885,7 @@ miller-rabin@^4.0.0:
2170621885
bn.js "^4.0.0"
2170721886
brorand "^1.0.1"
2170821887

21709-
[email protected], "mime-db@>= 1.43.0 < 2":
21888+
[email protected], [email protected], "mime-db@>= 1.43.0 < 2":
2171021889
version "1.52.0"
2171121890
resolved "https://registry.yarnpkg.com/mime-db/-/mime-db-1.52.0.tgz#bbabcdc02859f4987301c856e3387ce5ec43bf70"
2171221891
integrity sha512-sPU4uV7dYlvtWJxwwxHD0PuihVNiE7TyAbQ5SWxDCB9mUYvOgroQOwYQQOKPJ8CIbE+1ETVlOoK1UC2nU3gYvg==

0 commit comments

Comments
 (0)