Skip to content

Commit

Permalink
feat(node-experimental): Add koa integration (#10451)
Browse files Browse the repository at this point in the history
This should auto-instrument Koa performance. We still needs tests for
this at some point. cc @timfish / @onurtemizkan

The main reason to add this is that we have docs for this on
docs.sentry.com, and we need a way to properly replace/update them (and
they currently rely a lot on `startTransaction()` etc.) With this we can
eventually just update this to use the default koa integration we
provide.
  • Loading branch information
mydea authored and onurtemizkan committed Feb 4, 2024
1 parent 9317f85 commit 0eaa90c
Show file tree
Hide file tree
Showing 4 changed files with 125 additions and 9 deletions.
1 change: 1 addition & 0 deletions packages/node-experimental/package.json
Expand Up @@ -38,6 +38,7 @@
"@opentelemetry/instrumentation-graphql": "0.37.0",
"@opentelemetry/instrumentation-hapi": "0.34.0",
"@opentelemetry/instrumentation-http": "0.48.0",
"@opentelemetry/instrumentation-koa": "0.37.0",
"@opentelemetry/instrumentation-mongodb": "0.39.0",
"@opentelemetry/instrumentation-mongoose": "0.35.0",
"@opentelemetry/instrumentation-mysql": "0.35.0",
Expand Down
Expand Up @@ -4,6 +4,7 @@ import { expressIntegration } from './express';
import { fastifyIntegration } from './fastify';
import { graphqlIntegration } from './graphql';
import { hapiIntegration } from './hapi';
import { koaIntegration } from './koa';
import { mongoIntegration } from './mongo';
import { mongooseIntegration } from './mongoose';
import { mysqlIntegration } from './mysql';
Expand All @@ -28,5 +29,6 @@ export function getAutoPerformanceIntegrations(): Integration[] {
prismaIntegration(),
nestIntegration(),
hapiIntegration(),
koaIntegration(),
];
}
17 changes: 17 additions & 0 deletions packages/node-experimental/src/integrations/koa.ts
@@ -0,0 +1,17 @@
import { registerInstrumentations } from '@opentelemetry/instrumentation';
import { KoaInstrumentation } from '@opentelemetry/instrumentation-koa';
import { defineIntegration } from '@sentry/core';
import type { IntegrationFn } from '@sentry/types';

const _koaIntegration = (() => {
return {
name: 'Koa',
setupOnce() {
registerInstrumentations({
instrumentations: [new KoaInstrumentation()],
});
},
};
}) satisfies IntegrationFn;

export const koaIntegration = defineIntegration(_koaIntegration);
114 changes: 105 additions & 9 deletions yarn.lock
Expand Up @@ -4788,6 +4788,17 @@
"@opentelemetry/semantic-conventions" "1.21.0"
semver "^7.5.2"

"@opentelemetry/instrumentation-koa@0.37.0":
version "0.37.0"
resolved "https://registry.yarnpkg.com/@opentelemetry/instrumentation-koa/-/instrumentation-koa-0.37.0.tgz#f12e608afb7b58cee0f27abb3c2a166ea8596c68"
integrity sha512-EfuGv1RJCSZh77dDc3PtvZXGwcsTufn9tU6T9VOTFcxovpyJ6w0og73eD0D02syR8R+kzv6rg1TeS8+lj7pyrQ==
dependencies:
"@opentelemetry/core" "^1.8.0"
"@opentelemetry/instrumentation" "^0.48.0"
"@opentelemetry/semantic-conventions" "^1.0.0"
"@types/koa" "2.14.0"
"@types/koa__router" "12.0.3"

"@opentelemetry/instrumentation-mongodb@0.39.0":
version "0.39.0"
resolved "https://registry.yarnpkg.com/@opentelemetry/instrumentation-mongodb/-/instrumentation-mongodb-0.39.0.tgz#31bc92c137b578219bfaf4d15c7f247bc8d3b2c6"
Expand Down Expand Up @@ -5560,15 +5571,6 @@
"@sentry/types" "7.93.0"
"@sentry/utils" "7.93.0"

"@sentry/hub@7.93.0":
version "7.93.0"
resolved "https://registry.yarnpkg.com/@sentry/hub/-/hub-7.93.0.tgz#3db26f74dc1269650fa9ec553f0837af5caa0d30"
integrity sha512-gfPyT3DFGYYM5d+CHiS0YJHkIJHa8MKSfl32RkCMA5KQr9RF0H+GR5LZCinQOWq43fpsncSLyuoMfBjgbMLN+w==
dependencies:
"@sentry/core" "7.93.0"
"@sentry/types" "7.93.0"
"@sentry/utils" "7.93.0"

"@sentry/node@7.93.0":
version "7.93.0"
resolved "https://registry.yarnpkg.com/@sentry/node/-/node-7.93.0.tgz#7786d05d1e3e984207a866b07df1bf891355892e"
Expand Down Expand Up @@ -5892,6 +5894,13 @@
"@tufjs/canonical-json" "1.0.0"
minimatch "^9.0.0"

"@types/accepts@*":
version "1.3.7"
resolved "https://registry.yarnpkg.com/@types/accepts/-/accepts-1.3.7.tgz#3b98b1889d2b2386604c2bbbe62e4fb51e95b265"
integrity sha512-Pay9fq2lM2wXPWbteBsRAGiWH2hig4ZE2asK+mm7kUzlxRTfL961rj89I6zV/E3PcIkDqyuBEcMxFT7rccugeQ==
dependencies:
"@types/node" "*"

"@types/accepts@^1.3.5":
version "1.3.5"
resolved "https://registry.yarnpkg.com/@types/accepts/-/accepts-1.3.5.tgz#c34bec115cfc746e04fe5a059df4ce7e7b391575"
Expand Down Expand Up @@ -6011,6 +6020,11 @@
dependencies:
"@types/node" "*"

"@types/content-disposition@*":
version "0.5.8"
resolved "https://registry.yarnpkg.com/@types/content-disposition/-/content-disposition-0.5.8.tgz#6742a5971f490dc41e59d277eee71361fea0b537"
integrity sha512-QVSSvno3dE0MgO76pJhmv4Qyi/j0Yk9pBp0Y7TJ2Tlj+KCgJWY6qX7nnxCOLkZ3VYRSIk1WTxCvwUSdx6CCLdg==

"@types/cookie@0.5.2":
version "0.5.2"
resolved "https://registry.yarnpkg.com/@types/cookie/-/cookie-0.5.2.tgz#9bf9d62c838c85a07c92fdf2334c2c14fd9c59a9"
Expand All @@ -6026,6 +6040,16 @@
resolved "https://registry.yarnpkg.com/@types/cookie/-/cookie-0.6.0.tgz#eac397f28bf1d6ae0ae081363eca2f425bedf0d5"
integrity sha512-4Kh9a6B2bQciAhf7FSuMRRkUWecJgJu9nPnx3yzpsfXX/c50REIqpHY4C82bXP90qrLtXtkDxTZosYO3UpOwlA==

"@types/cookies@*":
version "0.9.0"
resolved "https://registry.yarnpkg.com/@types/cookies/-/cookies-0.9.0.tgz#a2290cfb325f75f0f28720939bee854d4142aee2"
integrity sha512-40Zk8qR147RABiQ7NQnBzWzDcjKzNrntB5BAmeGCb2p/MIyOE+4BVvc17wumsUqUw00bJYqoXFHYygQnEFh4/Q==
dependencies:
"@types/connect" "*"
"@types/express" "*"
"@types/keygrip" "*"
"@types/node" "*"

"@types/cors@2.8.12", "@types/cors@^2.8.12":
version "2.8.12"
resolved "https://registry.yarnpkg.com/@types/cors/-/cors-2.8.12.tgz#6b2c510a7ad7039e98e7b8d3d6598f4359e5c080"
Expand Down Expand Up @@ -6298,6 +6322,26 @@
"@types/qs" "*"
"@types/range-parser" "*"

"@types/express-serve-static-core@^4.17.33":
version "4.17.42"
resolved "https://registry.yarnpkg.com/@types/express-serve-static-core/-/express-serve-static-core-4.17.42.tgz#2a276952acc73d1b8dc63fd4210647abbc553a71"
integrity sha512-ckM3jm2bf/MfB3+spLPWYPUH573plBFwpOhqQ2WottxYV85j1HQFlxmnTq57X1yHY9awZPig06hL/cLMgNWHIQ==
dependencies:
"@types/node" "*"
"@types/qs" "*"
"@types/range-parser" "*"
"@types/send" "*"

"@types/express@*":
version "4.17.21"
resolved "https://registry.yarnpkg.com/@types/express/-/express-4.17.21.tgz#c26d4a151e60efe0084b23dc3369ebc631ed192d"
integrity sha512-ejlPM315qwLpaQlQDTjPdsUFSc6ZsP4AN6AlWnogPjQ7CVi7PYF3YVz+CY3jE2pwYf7E/7HlDAN0rV2GxTG0HQ==
dependencies:
"@types/body-parser" "*"
"@types/express-serve-static-core" "^4.17.33"
"@types/qs" "*"
"@types/serve-static" "*"

"@types/express@4.17.14", "@types/express@^4.17.14", "@types/express@^4.17.2":
version "4.17.14"
resolved "https://registry.yarnpkg.com/@types/express/-/express-4.17.14.tgz#143ea0557249bc1b3b54f15db4c81c3d4eb3569c"
Expand Down Expand Up @@ -6421,6 +6465,16 @@
resolved "https://registry.yarnpkg.com/@types/htmlbars-inline-precompile/-/htmlbars-inline-precompile-1.0.1.tgz#de564513fabb165746aecd76369c87bd85e5bbb4"
integrity sha512-sVD2e6QAAHW0Y6Btse+tTA9k9g0iKm87wjxRsgZRU5EwSooz80tenbV+fA+f2BI2g0G2CqxsS1rIlwQCtPRQow==

"@types/http-assert@*":
version "1.5.5"
resolved "https://registry.yarnpkg.com/@types/http-assert/-/http-assert-1.5.5.tgz#dfb1063eb7c240ee3d3fe213dac5671cfb6a8dbf"
integrity sha512-4+tE/lwdAahgZT1g30Jkdm9PzFRde0xwxBNUyRsCitRvCQB90iuA2uJYdUnhnANRcqGXaWOGY4FEoxeElNAK2g==

"@types/http-errors@*":
version "2.0.4"
resolved "https://registry.yarnpkg.com/@types/http-errors/-/http-errors-2.0.4.tgz#7eb47726c391b7345a6ec35ad7f4de469cf5ba4f"
integrity sha512-D0CFMMtydbJAegzOyHjtiKPLlvnm3iTZyZRSZoLq2mRhDdmLfIWOCYPfQJ4cu2erKghU++QvjcUjp/5h7hESpA==

"@types/istanbul-lib-coverage@*", "@types/istanbul-lib-coverage@^2.0.0", "@types/istanbul-lib-coverage@^2.0.1":
version "2.0.4"
resolved "https://registry.yarnpkg.com/@types/istanbul-lib-coverage/-/istanbul-lib-coverage-2.0.4.tgz#8467d4b3c087805d63580480890791277ce35c44"
Expand Down Expand Up @@ -6479,6 +6533,39 @@
resolved "https://registry.yarnpkg.com/@types/json5/-/json5-0.0.29.tgz#ee28707ae94e11d2b827bcbe5270bcea7f3e71ee"
integrity sha1-7ihweulOEdK4J7y+UnC86n8+ce4=

"@types/keygrip@*":
version "1.0.6"
resolved "https://registry.yarnpkg.com/@types/keygrip/-/keygrip-1.0.6.tgz#1749535181a2a9b02ac04a797550a8787345b740"
integrity sha512-lZuNAY9xeJt7Bx4t4dx0rYCDqGPW8RXhQZK1td7d4H6E9zYbLoOtjBvfwdTKpsyxQI/2jv+armjX/RW+ZNpXOQ==

"@types/koa-compose@*":
version "3.2.8"
resolved "https://registry.yarnpkg.com/@types/koa-compose/-/koa-compose-3.2.8.tgz#dec48de1f6b3d87f87320097686a915f1e954b57"
integrity sha512-4Olc63RY+MKvxMwVknCUDhRQX1pFQoBZ/lXcRLP69PQkEpze/0cr8LNqJQe5NFb/b19DWi2a5bTi2VAlQzhJuA==
dependencies:
"@types/koa" "*"

"@types/koa@*", "@types/koa@2.14.0":
version "2.14.0"
resolved "https://registry.yarnpkg.com/@types/koa/-/koa-2.14.0.tgz#8939e8c3b695defc12f2ef9f38064509e564be18"
integrity sha512-DTDUyznHGNHAl+wd1n0z1jxNajduyTh8R53xoewuerdBzGo6Ogj6F2299BFtrexJw4NtgjsI5SMPCmV9gZwGXA==
dependencies:
"@types/accepts" "*"
"@types/content-disposition" "*"
"@types/cookies" "*"
"@types/http-assert" "*"
"@types/http-errors" "*"
"@types/keygrip" "*"
"@types/koa-compose" "*"
"@types/node" "*"

"@types/koa__router@12.0.3":
version "12.0.3"
resolved "https://registry.yarnpkg.com/@types/koa__router/-/koa__router-12.0.3.tgz#3fb74ea1991cadd6c6712b6106657aa6e64afca4"
integrity sha512-5YUJVv6NwM1z7m6FuYpKfNLTZ932Z6EF6xy2BbtpJSyn13DKNQEkXVffFVSnJHxvwwWh2SAeumpjAYUELqgjyw==
dependencies:
"@types/koa" "*"

"@types/long@^4.0.0", "@types/long@^4.0.1":
version "4.0.2"
resolved "https://registry.yarnpkg.com/@types/long/-/long-4.0.2.tgz#b74129719fc8d11c01868010082d483b7545591a"
Expand Down Expand Up @@ -6793,6 +6880,14 @@
resolved "https://registry.yarnpkg.com/@types/semver/-/semver-7.5.3.tgz#9a726e116beb26c24f1ccd6850201e1246122e04"
integrity sha512-OxepLK9EuNEIPxWNME+C6WwbRAOOI2o2BaQEGzz5Lu2e4Z5eDnEo+/aVEDMIXywoJitJ7xWd641wrGLZdtwRyw==

"@types/send@*":
version "0.17.4"
resolved "https://registry.yarnpkg.com/@types/send/-/send-0.17.4.tgz#6619cd24e7270793702e4e6a4b958a9010cfc57a"
integrity sha512-x2EM6TJOybec7c52BX0ZspPodMsQUd5L6PRwOunVyVUhXiBSKf3AezDL8Dgvgt5o0UfKNfuA0eMLr2wLT4AiBA==
dependencies:
"@types/mime" "^1"
"@types/node" "*"

"@types/serve-static@*":
version "1.13.9"
resolved "https://registry.yarnpkg.com/@types/serve-static/-/serve-static-1.13.9.tgz#aacf28a85a05ee29a11fb7c3ead935ac56f33e4e"
Expand Down Expand Up @@ -12196,6 +12291,7 @@ cron@^3.1.6:
dependencies:
"@types/luxon" "~3.3.0"
luxon "~3.4.0"

cross-env@^7.0.3:
version "7.0.3"
resolved "https://registry.yarnpkg.com/cross-env/-/cross-env-7.0.3.tgz#865264b29677dc015ba8418918965dd232fc54cf"
Expand Down

0 comments on commit 0eaa90c

Please sign in to comment.