Skip to content

test(node): Add hapi auto instrumentation test for @sentry/node-experimental #10382

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Jan 29, 2024
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
9 changes: 5 additions & 4 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,10 +37,11 @@ able to use it. From the top level of the repo, there are three commands availab
dependencies (`utils`, `core`, `browser`, etc), and all packages which depend on it (currently `gatsby` and `nextjs`))
- `yarn build:dev:watch`, which runs `yarn build:dev` in watch mode (recommended)

You can also run a production build via `yarn build`, which will build everything except for the tarballs for publishing to NPM.
You can use this if you want to bundle Sentry yourself. The build output can be found in the packages `build/` folder, e.g. `packages/browser/build`.
Bundled files can be found in `packages/browser/build/bundles`.
Note that there are no guarantees about the produced file names etc., so make sure to double check which files are generated after upgrading.
You can also run a production build via `yarn build`, which will build everything except for the tarballs for publishing
to NPM. You can use this if you want to bundle Sentry yourself. The build output can be found in the packages `build/`
folder, e.g. `packages/browser/build`. Bundled files can be found in `packages/browser/build/bundles`. Note that there
are no guarantees about the produced file names etc., so make sure to double check which files are generated after
upgrading.

## Testing SDK Packages Locally

Expand Down
1 change: 1 addition & 0 deletions dev-packages/node-integration-tests/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
"test:watch": "yarn test --watch"
},
"dependencies": {
"@hapi/hapi": "^20.3.0",
"@prisma/client": "3.15.2",
"@sentry/node": "7.98.0",
"@sentry/tracing": "7.98.0",
Expand Down
8 changes: 8 additions & 0 deletions dev-packages/node-integration-tests/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,3 +29,11 @@ export function startExpressServerAndSendPortToRunner(app: Express): void {
console.log(`{"port":${address.port}}`);
});
}

/**
* Sends the port to the runner
*/
export function sendPortToRunner(port: number): void {
// eslint-disable-next-line no-console
console.log(`{"port":${port}}`);
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
const { loggingTransport, sendPortToRunner } = require('@sentry-internal/node-integration-tests');
const Sentry = require('@sentry/node-experimental');

Sentry.init({
dsn: 'https://[email protected]/1337',
release: '1.0',
debug: true,
tracesSampleRate: 1.0,
transport: loggingTransport,
});

const Hapi = require('@hapi/hapi');

const port = 5999;

const init = async () => {
const server = Hapi.server({
host: 'localhost',
port,
});

server.route({
method: 'GET',
path: '/',
handler: (_request, _h) => {
return 'Hello World!';
},
});

await server.start();

sendPortToRunner(port);
};

init();
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
import { conditionalTest } from '../../../utils';
import { cleanupChildProcesses, createRunner } from '../../../utils/runner';

jest.setTimeout(20000);

conditionalTest({ min: 14 })('hapi auto-instrumentation', () => {
afterAll(async () => {
cleanupChildProcesses();
});

const EXPECTED_TRANSACTION = {
transaction: 'GET /',
spans: expect.arrayContaining([
expect.objectContaining({
data: expect.objectContaining({
'http.route': '/',
'http.method': 'GET',
'hapi.type': 'router',
'sentry.origin': 'manual',
'sentry.op': 'http',
}),
description: 'GET /',
op: 'http',
status: 'ok',
}),
]),
};

test('CJS - should auto-instrument `@hapi/hapi` package.', done => {
createRunner(__dirname, 'scenario.js')
.expect({ transaction: EXPECTED_TRANSACTION })
.start(done)
.makeRequest('get', '/');
});
});
193 changes: 186 additions & 7 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -3541,6 +3541,21 @@
"@hapi/boom" "9.x.x"
"@hapi/hoek" "9.x.x"

"@hapi/accept@^5.0.1":
version "5.0.2"
resolved "https://registry.yarnpkg.com/@hapi/accept/-/accept-5.0.2.tgz#ab7043b037e68b722f93f376afb05e85c0699523"
integrity sha512-CmzBx/bXUR8451fnZRuZAJRlzgm0Jgu5dltTX/bszmR2lheb9BpyN47Q1RbaGTsvFzn0PXAEs+lXDKfshccYZw==
dependencies:
"@hapi/boom" "9.x.x"
"@hapi/hoek" "9.x.x"

"@hapi/ammo@^5.0.1":
version "5.0.1"
resolved "https://registry.yarnpkg.com/@hapi/ammo/-/ammo-5.0.1.tgz#9d34560f5c214eda563d838c01297387efaab490"
integrity sha512-FbCNwcTbnQP4VYYhLNGZmA76xb2aHg9AMPiy18NZyWMG310P5KdFGyA9v2rm5ujrIny77dEEIkMOwl0Xv+fSSA==
dependencies:
"@hapi/hoek" "9.x.x"

"@hapi/[email protected]":
version "5.0.0"
resolved "https://registry.yarnpkg.com/@hapi/b64/-/b64-5.0.0.tgz#b8210cbd72f4774985e78569b77e97498d24277d"
Expand All @@ -3555,36 +3570,115 @@
dependencies:
"@hapi/hoek" "9.x.x"

"@hapi/boom@^9.0.0":
"@hapi/boom@^9.0.0", "@hapi/boom@^9.1.0":
version "9.1.4"
resolved "https://registry.yarnpkg.com/@hapi/boom/-/boom-9.1.4.tgz#1f9dad367c6a7da9f8def24b4a986fc5a7bd9db6"
integrity sha512-Ls1oH8jaN1vNsqcaHVYJrKmgMcKsC1wcp8bujvXrHaAqD2iDYq3HoOwsxwo09Cuda5R5nC0o0IxlrlTuvPuzSw==
dependencies:
"@hapi/hoek" "9.x.x"

"@hapi/[email protected]", "@hapi/bounce@^2.0.0":
version "2.0.0"
resolved "https://registry.yarnpkg.com/@hapi/bounce/-/bounce-2.0.0.tgz#e6ef56991c366b1e2738b2cd83b01354d938cf3d"
integrity sha512-JesW92uyzOOyuzJKjoLHM1ThiOvHPOLDHw01YV8yh5nCso7sDwJho1h0Ad2N+E62bZyz46TG3xhAi/78Gsct6A==
dependencies:
"@hapi/boom" "9.x.x"
"@hapi/hoek" "9.x.x"

"@hapi/[email protected]":
version "2.1.0"
resolved "https://registry.yarnpkg.com/@hapi/bourne/-/bourne-2.1.0.tgz#66aff77094dc3080bd5df44ec63881f2676eb020"
integrity sha512-i1BpaNDVLJdRBEKeJWkVO6tYX6DMFBuwMhSuWqLsY4ufeTKGVuV5rBsUhxPayXqnnWHgXUAmWK16H/ykO5Wj4Q==

"@hapi/call@^8.0.0":
version "8.0.1"
resolved "https://registry.yarnpkg.com/@hapi/call/-/call-8.0.1.tgz#9e64cd8ba6128eb5be6e432caaa572b1ed8cd7c0"
integrity sha512-bOff6GTdOnoe5b8oXRV3lwkQSb/LAWylvDMae6RgEWWntd0SHtkYbQukDHKlfaYtVnSAgIavJ0kqszF/AIBb6g==
dependencies:
"@hapi/boom" "9.x.x"
"@hapi/hoek" "9.x.x"

"@hapi/catbox-memory@^5.0.0":
version "5.0.1"
resolved "https://registry.yarnpkg.com/@hapi/catbox-memory/-/catbox-memory-5.0.1.tgz#cb63fca0ded01d445a2573b38eb2688df67f70ac"
integrity sha512-QWw9nOYJq5PlvChLWV8i6hQHJYfvdqiXdvTupJFh0eqLZ64Xir7mKNi96d5/ZMUAqXPursfNDIDxjFgoEDUqeQ==
dependencies:
"@hapi/boom" "9.x.x"
"@hapi/hoek" "9.x.x"

"@hapi/catbox@^11.1.1":
version "11.1.1"
resolved "https://registry.yarnpkg.com/@hapi/catbox/-/catbox-11.1.1.tgz#d277e2d5023fd69cddb33d05b224ea03065fec0c"
integrity sha512-u/8HvB7dD/6X8hsZIpskSDo4yMKpHxFd7NluoylhGrL6cUfYxdQPnvUp9YU2C6F9hsyBVLGulBd9vBN1ebfXOQ==
dependencies:
"@hapi/boom" "9.x.x"
"@hapi/hoek" "9.x.x"
"@hapi/podium" "4.x.x"
"@hapi/validate" "1.x.x"

"@hapi/content@^5.0.2":
version "5.0.2"
resolved "https://registry.yarnpkg.com/@hapi/content/-/content-5.0.2.tgz#ae57954761de570392763e64cdd75f074176a804"
integrity sha512-mre4dl1ygd4ZyOH3tiYBrOUBzV7Pu/EOs8VLGf58vtOEECWed8Uuw6B4iR9AN/8uQt42tB04qpVaMyoMQh0oMw==
dependencies:
"@hapi/boom" "9.x.x"

"@hapi/[email protected]":
version "5.1.0"
resolved "https://registry.yarnpkg.com/@hapi/cryptiles/-/cryptiles-5.1.0.tgz#655de4cbbc052c947f696148c83b187fc2be8f43"
integrity sha512-fo9+d1Ba5/FIoMySfMqPBR/7Pa29J2RsiPrl7bkwo5W5o+AN1dAYQRi4SPrPwwVxVGKjgLOEWrsvt1BonJSfLA==
dependencies:
"@hapi/boom" "9.x.x"

"@hapi/[email protected]":
version "2.0.0"
resolved "https://registry.yarnpkg.com/@hapi/file/-/file-2.0.0.tgz#2ecda37d1ae9d3078a67c13b7da86e8c3237dfb9"
integrity sha512-WSrlgpvEqgPWkI18kkGELEZfXr0bYLtr16iIN4Krh9sRnzBZN6nnWxHFxtsnP684wueEySBbXPDg/WfA9xJdBQ==

"@hapi/hapi@^20.3.0":
version "20.3.0"
resolved "https://registry.yarnpkg.com/@hapi/hapi/-/hapi-20.3.0.tgz#1d620005afeebcb2c8170352286a4664b0107c15"
integrity sha512-zvPSRvaQyF3S6Nev9aiAzko2/hIFZmNSJNcs07qdVaVAvj8dGJSV4fVUuQSnufYJAGiSau+U5LxMLhx79se5WA==
dependencies:
"@hapi/accept" "^5.0.1"
"@hapi/ammo" "^5.0.1"
"@hapi/boom" "^9.1.0"
"@hapi/bounce" "^2.0.0"
"@hapi/call" "^8.0.0"
"@hapi/catbox" "^11.1.1"
"@hapi/catbox-memory" "^5.0.0"
"@hapi/heavy" "^7.0.1"
"@hapi/hoek" "^9.0.4"
"@hapi/mimos" "^6.0.0"
"@hapi/podium" "^4.1.1"
"@hapi/shot" "^5.0.5"
"@hapi/somever" "^3.0.0"
"@hapi/statehood" "^7.0.3"
"@hapi/subtext" "^7.1.0"
"@hapi/teamwork" "^5.1.0"
"@hapi/topo" "^5.0.0"
"@hapi/validate" "^1.1.1"

"@hapi/heavy@^7.0.1":
version "7.0.1"
resolved "https://registry.yarnpkg.com/@hapi/heavy/-/heavy-7.0.1.tgz#73315ae33b6e7682a0906b7a11e8ca70e3045874"
integrity sha512-vJ/vzRQ13MtRzz6Qd4zRHWS3FaUc/5uivV2TIuExGTM9Qk+7Zzqj0e2G7EpE6KztO9SalTbiIkTh7qFKj/33cA==
dependencies:
"@hapi/boom" "9.x.x"
"@hapi/hoek" "9.x.x"
"@hapi/validate" "1.x.x"

"@hapi/[email protected]":
version "9.2.0"
resolved "https://registry.yarnpkg.com/@hapi/hoek/-/hoek-9.2.0.tgz#f3933a44e365864f4dad5db94158106d511e8131"
integrity sha512-sqKVVVOe5ivCaXDWivIJYVSaEgdQK9ul7a4Kity5Iw7u9+wBAPbX1RMSnLLmp7O4Vzj0WOWwMAJsTL00xwaNug==

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

"@hapi/iron@^6.0.0":
"@hapi/iron@6.x.x", "@hapi/iron@^6.0.0":
version "6.0.0"
resolved "https://registry.yarnpkg.com/@hapi/iron/-/iron-6.0.0.tgz#ca3f9136cda655bdd6028de0045da0de3d14436f"
integrity sha512-zvGvWDufiTGpTJPG1Y/McN8UqWBu0k/xs/7l++HVU535NLHXsHhy54cfEMdW7EjwKfbBfM9Xy25FmTiobb7Hvw==
Expand All @@ -3595,7 +3689,34 @@
"@hapi/cryptiles" "5.x.x"
"@hapi/hoek" "9.x.x"

"@hapi/podium@^4.1.3":
"@hapi/mimos@^6.0.0":
version "6.0.0"
resolved "https://registry.yarnpkg.com/@hapi/mimos/-/mimos-6.0.0.tgz#daa523d9c07222c7e8860cb7c9c5501fd6506484"
integrity sha512-Op/67tr1I+JafN3R3XN5DucVSxKRT/Tc+tUszDwENoNpolxeXkhrJ2Czt6B6AAqrespHoivhgZBWYSuANN9QXg==
dependencies:
"@hapi/hoek" "9.x.x"
mime-db "1.x.x"

"@hapi/[email protected]":
version "4.0.2"
resolved "https://registry.yarnpkg.com/@hapi/nigel/-/nigel-4.0.2.tgz#8f84ef4bca4fb03b2376463578f253b0b8e863c4"
integrity sha512-ht2KoEsDW22BxQOEkLEJaqfpoKPXxi7tvabXy7B/77eFtOyG5ZEstfZwxHQcqAiZhp58Ae5vkhEqI03kawkYNw==
dependencies:
"@hapi/hoek" "^9.0.4"
"@hapi/vise" "^4.0.0"

"@hapi/pez@^5.1.0":
version "5.1.0"
resolved "https://registry.yarnpkg.com/@hapi/pez/-/pez-5.1.0.tgz#c03a5e01f8be01cfabc4c0017631e619586321c1"
integrity sha512-YfB0btnkLB3lb6Ry/1KifnMPBm5ZPfaAHWFskzOMAgDgXgcBgA+zjpIynyEiBfWEz22DBT8o1e2tAaBdlt8zbw==
dependencies:
"@hapi/b64" "5.x.x"
"@hapi/boom" "9.x.x"
"@hapi/content" "^5.0.2"
"@hapi/hoek" "9.x.x"
"@hapi/nigel" "4.x.x"

"@hapi/[email protected]", "@hapi/podium@^4.1.1", "@hapi/podium@^4.1.3":
version "4.1.3"
resolved "https://registry.yarnpkg.com/@hapi/podium/-/podium-4.1.3.tgz#91e20838fc2b5437f511d664aabebbb393578a26"
integrity sha512-ljsKGQzLkFqnQxE7qeanvgGj4dejnciErYd30dbrYzUOF/FyS/DOF97qcrT3bhoVwCYmxa6PEMhxfCPlnUcD2g==
Expand All @@ -3604,7 +3725,49 @@
"@hapi/teamwork" "5.x.x"
"@hapi/validate" "1.x.x"

"@hapi/[email protected]":
"@hapi/shot@^5.0.5":
version "5.0.5"
resolved "https://registry.yarnpkg.com/@hapi/shot/-/shot-5.0.5.tgz#a25c23d18973bec93c7969c51bf9579632a5bebd"
integrity sha512-x5AMSZ5+j+Paa8KdfCoKh+klB78otxF+vcJR/IoN91Vo2e5ulXIW6HUsFTCU+4W6P/Etaip9nmdAx2zWDimB2A==
dependencies:
"@hapi/hoek" "9.x.x"
"@hapi/validate" "1.x.x"

"@hapi/somever@^3.0.0":
version "3.0.1"
resolved "https://registry.yarnpkg.com/@hapi/somever/-/somever-3.0.1.tgz#9961cd5bdbeb5bb1edc0b2acdd0bb424066aadcc"
integrity sha512-4ZTSN3YAHtgpY/M4GOtHUXgi6uZtG9nEZfNI6QrArhK0XN/RDVgijlb9kOmXwCR5VclDSkBul9FBvhSuKXx9+w==
dependencies:
"@hapi/bounce" "2.x.x"
"@hapi/hoek" "9.x.x"

"@hapi/statehood@^7.0.3":
version "7.0.4"
resolved "https://registry.yarnpkg.com/@hapi/statehood/-/statehood-7.0.4.tgz#6acb9d0817b5c657089356f7d9fd60af0bce4f41"
integrity sha512-Fia6atroOVmc5+2bNOxF6Zv9vpbNAjEXNcUbWXavDqhnJDlchwUUwKS5LCi5mGtCTxRhUKKHwuxuBZJkmLZ7fw==
dependencies:
"@hapi/boom" "9.x.x"
"@hapi/bounce" "2.x.x"
"@hapi/bourne" "2.x.x"
"@hapi/cryptiles" "5.x.x"
"@hapi/hoek" "9.x.x"
"@hapi/iron" "6.x.x"
"@hapi/validate" "1.x.x"

"@hapi/subtext@^7.1.0":
version "7.1.0"
resolved "https://registry.yarnpkg.com/@hapi/subtext/-/subtext-7.1.0.tgz#b4d1ea2aeab1923ac130a24e75921e38fab5b15b"
integrity sha512-n94cU6hlvsNRIpXaROzBNEJGwxC+HA69q769pChzej84On8vsU14guHDub7Pphr/pqn5b93zV3IkMPDU5AUiXA==
dependencies:
"@hapi/boom" "9.x.x"
"@hapi/bourne" "2.x.x"
"@hapi/content" "^5.0.2"
"@hapi/file" "2.x.x"
"@hapi/hoek" "9.x.x"
"@hapi/pez" "^5.1.0"
"@hapi/wreck" "17.x.x"

"@hapi/[email protected]", "@hapi/teamwork@^5.1.0":
version "5.1.1"
resolved "https://registry.yarnpkg.com/@hapi/teamwork/-/teamwork-5.1.1.tgz#4d2ba3cac19118a36c44bf49a3a47674de52e4e4"
integrity sha512-1oPx9AE5TIv+V6Ih54RP9lTZBso3rP8j4Xhb6iSVwPXtAM+sDopl5TFMv5Paw73UnpZJ9gjcrTE1BXrWt9eQrg==
Expand All @@ -3616,14 +3779,30 @@
dependencies:
"@hapi/hoek" "^9.0.0"

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

"@hapi/vise@^4.0.0":
version "4.0.0"
resolved "https://registry.yarnpkg.com/@hapi/vise/-/vise-4.0.0.tgz#c6a94fe121b94a53bf99e7489f7fcc74c104db02"
integrity sha512-eYyLkuUiFZTer59h+SGy7hUm+qE9p+UemePTHLlIWppEd+wExn3Df5jO04bFQTm7nleF5V8CtuYQYb+VFpZ6Sg==
dependencies:
"@hapi/hoek" "9.x.x"

"@hapi/[email protected]":
version "17.2.0"
resolved "https://registry.yarnpkg.com/@hapi/wreck/-/wreck-17.2.0.tgz#a5b69b724fa8fa25550fb02f55c649becfc59f63"
integrity sha512-pJ5kjYoRPYDv+eIuiLQqhGon341fr2bNIYZjuotuPJG/3Ilzr/XtI+JAp0A86E2bYfsS3zBPABuS2ICkaXFT8g==
dependencies:
"@hapi/boom" "9.x.x"
"@hapi/bourne" "2.x.x"
"@hapi/hoek" "9.x.x"

"@humanwhocodes/config-array@^0.5.0":
version "0.5.0"
resolved "https://registry.yarnpkg.com/@humanwhocodes/config-array/-/config-array-0.5.0.tgz#1407967d4c6eecd7388f83acf1eaf4d0c6e58ef9"
Expand Down Expand Up @@ -21706,7 +21885,7 @@ miller-rabin@^4.0.0:
bn.js "^4.0.0"
brorand "^1.0.1"

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