Skip to content

Commit 03ed790

Browse files
committed
feat(node-experimental): Add koa integration
This should auto-instrument Koa performance. We still needs tests for this at some point.
1 parent 2000d7e commit 03ed790

File tree

4 files changed

+127
-0
lines changed

4 files changed

+127
-0
lines changed

packages/node-experimental/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@
3838
"@opentelemetry/instrumentation-graphql": "0.35.2",
3939
"@opentelemetry/instrumentation-hapi": "0.33.1",
4040
"@opentelemetry/instrumentation-http": "0.44.0",
41+
"@opentelemetry/instrumentation-koa": "0.37.0",
4142
"@opentelemetry/instrumentation-mongodb": "0.37.1",
4243
"@opentelemetry/instrumentation-mongoose": "0.33.2",
4344
"@opentelemetry/instrumentation-mysql": "0.34.2",

packages/node-experimental/src/integrations/getAutoPerformanceIntegrations.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import { expressIntegration } from './express';
44
import { fastifyIntegration } from './fastify';
55
import { graphqlIntegration } from './graphql';
66
import { hapiIntegration } from './hapi';
7+
import { koaIntegration } from './koa';
78
import { mongoIntegration } from './mongo';
89
import { mongooseIntegration } from './mongoose';
910
import { mysqlIntegration } from './mysql';
@@ -28,5 +29,6 @@ export function getAutoPerformanceIntegrations(): Integration[] {
2829
prismaIntegration(),
2930
nestIntegration(),
3031
hapiIntegration(),
32+
koaIntegration(),
3133
];
3234
}
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
import { registerInstrumentations } from '@opentelemetry/instrumentation';
2+
import { KoaInstrumentation } from '@opentelemetry/instrumentation-koa';
3+
import { defineIntegration } from '@sentry/core';
4+
import type { IntegrationFn } from '@sentry/types';
5+
6+
const _koaIntegration = (() => {
7+
return {
8+
name: 'Koa',
9+
setupOnce() {
10+
registerInstrumentations({
11+
instrumentations: [new KoaInstrumentation()],
12+
});
13+
},
14+
};
15+
}) satisfies IntegrationFn;
16+
17+
export const koaIntegration = defineIntegration(_koaIntegration);

yarn.lock

Lines changed: 107 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4789,6 +4789,17 @@
47894789
"@opentelemetry/semantic-conventions" "1.17.1"
47904790
semver "^7.5.2"
47914791

4792+
"@opentelemetry/[email protected]":
4793+
version "0.37.0"
4794+
resolved "https://registry.yarnpkg.com/@opentelemetry/instrumentation-koa/-/instrumentation-koa-0.37.0.tgz#f12e608afb7b58cee0f27abb3c2a166ea8596c68"
4795+
integrity sha512-EfuGv1RJCSZh77dDc3PtvZXGwcsTufn9tU6T9VOTFcxovpyJ6w0og73eD0D02syR8R+kzv6rg1TeS8+lj7pyrQ==
4796+
dependencies:
4797+
"@opentelemetry/core" "^1.8.0"
4798+
"@opentelemetry/instrumentation" "^0.48.0"
4799+
"@opentelemetry/semantic-conventions" "^1.0.0"
4800+
"@types/koa" "2.14.0"
4801+
"@types/koa__router" "12.0.3"
4802+
47924803
"@opentelemetry/[email protected]":
47934804
version "0.37.1"
47944805
resolved "https://registry.yarnpkg.com/@opentelemetry/instrumentation-mongodb/-/instrumentation-mongodb-0.37.1.tgz#5957565a74a4fe39fb72ab29f3b72a20223ef3df"
@@ -4867,6 +4878,17 @@
48674878
semver "^7.5.2"
48684879
shimmer "^1.2.1"
48694880

4881+
"@opentelemetry/instrumentation@^0.48.0":
4882+
version "0.48.0"
4883+
resolved "https://registry.yarnpkg.com/@opentelemetry/instrumentation/-/instrumentation-0.48.0.tgz#a6dee936e973f1270c464657a55bb570807194aa"
4884+
integrity sha512-sjtZQB5PStIdCw5ovVTDGwnmQC+GGYArJNgIcydrDSqUTdYBnMrN9P4pwQZgS3vTGIp+TU1L8vMXGe51NVmIKQ==
4885+
dependencies:
4886+
"@types/shimmer" "^1.0.2"
4887+
import-in-the-middle "1.7.1"
4888+
require-in-the-middle "^7.1.1"
4889+
semver "^7.5.2"
4890+
shimmer "^1.2.1"
4891+
48704892
"@opentelemetry/[email protected]":
48714893
version "1.17.1"
48724894
resolved "https://registry.yarnpkg.com/@opentelemetry/propagator-b3/-/propagator-b3-1.17.1.tgz#65dbddf3763db82632ddd7ad1735e597ab7b2dc4"
@@ -5834,6 +5856,13 @@
58345856
"@tufjs/canonical-json" "1.0.0"
58355857
minimatch "^9.0.0"
58365858

5859+
"@types/accepts@*":
5860+
version "1.3.7"
5861+
resolved "https://registry.yarnpkg.com/@types/accepts/-/accepts-1.3.7.tgz#3b98b1889d2b2386604c2bbbe62e4fb51e95b265"
5862+
integrity sha512-Pay9fq2lM2wXPWbteBsRAGiWH2hig4ZE2asK+mm7kUzlxRTfL961rj89I6zV/E3PcIkDqyuBEcMxFT7rccugeQ==
5863+
dependencies:
5864+
"@types/node" "*"
5865+
58375866
"@types/accepts@^1.3.5":
58385867
version "1.3.5"
58395868
resolved "https://registry.yarnpkg.com/@types/accepts/-/accepts-1.3.5.tgz#c34bec115cfc746e04fe5a059df4ce7e7b391575"
@@ -5953,6 +5982,11 @@
59535982
dependencies:
59545983
"@types/node" "*"
59555984

5985+
"@types/content-disposition@*":
5986+
version "0.5.8"
5987+
resolved "https://registry.yarnpkg.com/@types/content-disposition/-/content-disposition-0.5.8.tgz#6742a5971f490dc41e59d277eee71361fea0b537"
5988+
integrity sha512-QVSSvno3dE0MgO76pJhmv4Qyi/j0Yk9pBp0Y7TJ2Tlj+KCgJWY6qX7nnxCOLkZ3VYRSIk1WTxCvwUSdx6CCLdg==
5989+
59565990
59575991
version "0.5.2"
59585992
resolved "https://registry.yarnpkg.com/@types/cookie/-/cookie-0.5.2.tgz#9bf9d62c838c85a07c92fdf2334c2c14fd9c59a9"
@@ -5968,6 +6002,16 @@
59686002
resolved "https://registry.yarnpkg.com/@types/cookie/-/cookie-0.6.0.tgz#eac397f28bf1d6ae0ae081363eca2f425bedf0d5"
59696003
integrity sha512-4Kh9a6B2bQciAhf7FSuMRRkUWecJgJu9nPnx3yzpsfXX/c50REIqpHY4C82bXP90qrLtXtkDxTZosYO3UpOwlA==
59706004

6005+
"@types/cookies@*":
6006+
version "0.9.0"
6007+
resolved "https://registry.yarnpkg.com/@types/cookies/-/cookies-0.9.0.tgz#a2290cfb325f75f0f28720939bee854d4142aee2"
6008+
integrity sha512-40Zk8qR147RABiQ7NQnBzWzDcjKzNrntB5BAmeGCb2p/MIyOE+4BVvc17wumsUqUw00bJYqoXFHYygQnEFh4/Q==
6009+
dependencies:
6010+
"@types/connect" "*"
6011+
"@types/express" "*"
6012+
"@types/keygrip" "*"
6013+
"@types/node" "*"
6014+
59716015
"@types/[email protected]", "@types/cors@^2.8.12":
59726016
version "2.8.12"
59736017
resolved "https://registry.yarnpkg.com/@types/cors/-/cors-2.8.12.tgz#6b2c510a7ad7039e98e7b8d3d6598f4359e5c080"
@@ -6250,6 +6294,16 @@
62506294
"@types/range-parser" "*"
62516295
"@types/send" "*"
62526296

6297+
"@types/express@*":
6298+
version "4.17.21"
6299+
resolved "https://registry.yarnpkg.com/@types/express/-/express-4.17.21.tgz#c26d4a151e60efe0084b23dc3369ebc631ed192d"
6300+
integrity sha512-ejlPM315qwLpaQlQDTjPdsUFSc6ZsP4AN6AlWnogPjQ7CVi7PYF3YVz+CY3jE2pwYf7E/7HlDAN0rV2GxTG0HQ==
6301+
dependencies:
6302+
"@types/body-parser" "*"
6303+
"@types/express-serve-static-core" "^4.17.33"
6304+
"@types/qs" "*"
6305+
"@types/serve-static" "*"
6306+
62536307
"@types/[email protected]", "@types/express@^4.17.14", "@types/express@^4.17.2":
62546308
version "4.17.14"
62556309
resolved "https://registry.yarnpkg.com/@types/express/-/express-4.17.14.tgz#143ea0557249bc1b3b54f15db4c81c3d4eb3569c"
@@ -6383,6 +6437,16 @@
63836437
resolved "https://registry.yarnpkg.com/@types/htmlbars-inline-precompile/-/htmlbars-inline-precompile-1.0.1.tgz#de564513fabb165746aecd76369c87bd85e5bbb4"
63846438
integrity sha512-sVD2e6QAAHW0Y6Btse+tTA9k9g0iKm87wjxRsgZRU5EwSooz80tenbV+fA+f2BI2g0G2CqxsS1rIlwQCtPRQow==
63856439

6440+
"@types/http-assert@*":
6441+
version "1.5.5"
6442+
resolved "https://registry.yarnpkg.com/@types/http-assert/-/http-assert-1.5.5.tgz#dfb1063eb7c240ee3d3fe213dac5671cfb6a8dbf"
6443+
integrity sha512-4+tE/lwdAahgZT1g30Jkdm9PzFRde0xwxBNUyRsCitRvCQB90iuA2uJYdUnhnANRcqGXaWOGY4FEoxeElNAK2g==
6444+
6445+
"@types/http-errors@*":
6446+
version "2.0.4"
6447+
resolved "https://registry.yarnpkg.com/@types/http-errors/-/http-errors-2.0.4.tgz#7eb47726c391b7345a6ec35ad7f4de469cf5ba4f"
6448+
integrity sha512-D0CFMMtydbJAegzOyHjtiKPLlvnm3iTZyZRSZoLq2mRhDdmLfIWOCYPfQJ4cu2erKghU++QvjcUjp/5h7hESpA==
6449+
63866450
"@types/istanbul-lib-coverage@*", "@types/istanbul-lib-coverage@^2.0.0", "@types/istanbul-lib-coverage@^2.0.1":
63876451
version "2.0.4"
63886452
resolved "https://registry.yarnpkg.com/@types/istanbul-lib-coverage/-/istanbul-lib-coverage-2.0.4.tgz#8467d4b3c087805d63580480890791277ce35c44"
@@ -6441,6 +6505,39 @@
64416505
resolved "https://registry.yarnpkg.com/@types/json5/-/json5-0.0.29.tgz#ee28707ae94e11d2b827bcbe5270bcea7f3e71ee"
64426506
integrity sha1-7ihweulOEdK4J7y+UnC86n8+ce4=
64436507

6508+
"@types/keygrip@*":
6509+
version "1.0.6"
6510+
resolved "https://registry.yarnpkg.com/@types/keygrip/-/keygrip-1.0.6.tgz#1749535181a2a9b02ac04a797550a8787345b740"
6511+
integrity sha512-lZuNAY9xeJt7Bx4t4dx0rYCDqGPW8RXhQZK1td7d4H6E9zYbLoOtjBvfwdTKpsyxQI/2jv+armjX/RW+ZNpXOQ==
6512+
6513+
"@types/koa-compose@*":
6514+
version "3.2.8"
6515+
resolved "https://registry.yarnpkg.com/@types/koa-compose/-/koa-compose-3.2.8.tgz#dec48de1f6b3d87f87320097686a915f1e954b57"
6516+
integrity sha512-4Olc63RY+MKvxMwVknCUDhRQX1pFQoBZ/lXcRLP69PQkEpze/0cr8LNqJQe5NFb/b19DWi2a5bTi2VAlQzhJuA==
6517+
dependencies:
6518+
"@types/koa" "*"
6519+
6520+
"@types/koa@*", "@types/[email protected]":
6521+
version "2.14.0"
6522+
resolved "https://registry.yarnpkg.com/@types/koa/-/koa-2.14.0.tgz#8939e8c3b695defc12f2ef9f38064509e564be18"
6523+
integrity sha512-DTDUyznHGNHAl+wd1n0z1jxNajduyTh8R53xoewuerdBzGo6Ogj6F2299BFtrexJw4NtgjsI5SMPCmV9gZwGXA==
6524+
dependencies:
6525+
"@types/accepts" "*"
6526+
"@types/content-disposition" "*"
6527+
"@types/cookies" "*"
6528+
"@types/http-assert" "*"
6529+
"@types/http-errors" "*"
6530+
"@types/keygrip" "*"
6531+
"@types/koa-compose" "*"
6532+
"@types/node" "*"
6533+
6534+
6535+
version "12.0.3"
6536+
resolved "https://registry.yarnpkg.com/@types/koa__router/-/koa__router-12.0.3.tgz#3fb74ea1991cadd6c6712b6106657aa6e64afca4"
6537+
integrity sha512-5YUJVv6NwM1z7m6FuYpKfNLTZ932Z6EF6xy2BbtpJSyn13DKNQEkXVffFVSnJHxvwwWh2SAeumpjAYUELqgjyw==
6538+
dependencies:
6539+
"@types/koa" "*"
6540+
64446541
"@types/long@^4.0.0", "@types/long@^4.0.1":
64456542
version "4.0.2"
64466543
resolved "https://registry.yarnpkg.com/@types/long/-/long-4.0.2.tgz#b74129719fc8d11c01868010082d483b7545591a"
@@ -17926,6 +18023,16 @@ [email protected]:
1792618023
cjs-module-lexer "^1.2.2"
1792718024
module-details-from-path "^1.0.3"
1792818025

18026+
18027+
version "1.7.1"
18028+
resolved "https://registry.yarnpkg.com/import-in-the-middle/-/import-in-the-middle-1.7.1.tgz#3e111ff79c639d0bde459bd7ba29dd9fdf357364"
18029+
integrity sha512-1LrZPDtW+atAxH42S6288qyDFNQ2YCty+2mxEPRtfazH6Z5QwkaBSTS2ods7hnVJioF6rkRfNoA6A/MstpFXLg==
18030+
dependencies:
18031+
acorn "^8.8.2"
18032+
acorn-import-assertions "^1.9.0"
18033+
cjs-module-lexer "^1.2.2"
18034+
module-details-from-path "^1.0.3"
18035+
1792918036
import-lazy@^2.1.0:
1793018037
version "2.1.0"
1793118038
resolved "https://registry.yarnpkg.com/import-lazy/-/import-lazy-2.1.0.tgz#05698e3d45c88e8d7e9d92cb0584e77f096f3e43"

0 commit comments

Comments
 (0)