-
-
Notifications
You must be signed in to change notification settings - Fork 1.7k
feat(node): Migrate to @fastify/otel
#15542
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
base: develop
Are you sure you want to change the base?
Conversation
38047fd
to
6c347ee
Compare
packages/node/package.json
Outdated
@@ -101,7 +101,8 @@ | |||
"import-in-the-middle": "^1.13.0" | |||
}, | |||
"devDependencies": { | |||
"@types/node": "^18.19.1" | |||
"@types/node": "^18.19.1", | |||
"fastify": "4.18.0" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we avoid this and just vendor in the minimal interface we need to satisfy the types?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sure 👍
size-limit report 📦
|
88d946e
to
112c80a
Compare
@@ -0,0 +1,32 @@ | |||
/* |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For the files we vendored in from OTEL, we should also link to the git sha we used of the versioned files.
ad52eb9
to
9ca14db
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great job! This is looking nice.
packages/node/package.json
Outdated
@@ -65,6 +65,7 @@ | |||
"access": "public" | |||
}, | |||
"dependencies": { | |||
"@fastify/otel": "0.5.0", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
l: We can bump to 0.5.1
// /** | ||
// * Minimal request type containing properties around route information. | ||
// * Works for Fastify 3, 4 and presumably 5. | ||
// * | ||
// * Based on https://github.com/fastify/fastify/blob/ce3811f5f718be278bbcd4392c615d64230065a6/types/request.d.ts | ||
// */ | ||
// // eslint-disable-next-line @typescript-eslint/no-explicit-any | ||
// interface MinimalFastifyRequest extends Record<string, any> { | ||
// method?: string; | ||
// // since [email protected] | ||
// routeOptions?: { | ||
// url?: string; | ||
// }; | ||
// routerPath?: string; | ||
// } | ||
|
||
// /** | ||
// * Minimal reply type containing properties needed for error handling. | ||
// * | ||
// * Based on https://github.com/fastify/fastify/blob/ce3811f5f718be278bbcd4392c615d64230065a6/types/reply.d.ts | ||
// */ | ||
// // eslint-disable-next-line @typescript-eslint/no-explicit-any | ||
// interface MinimalFastifyReply extends Record<string, any> { | ||
// statusCode: number; | ||
// } | ||
|
||
// // We inline the types we care about here | ||
// interface Fastify { | ||
// // eslint-disable-next-line @typescript-eslint/no-explicit-any | ||
// version: string; | ||
// register: (plugin: any) => Fastify; | ||
// after: (listener?: (err: Error) => void) => Fastify; | ||
// addHook: (name: string, handler: (...params: unknown[]) => void) => Fastify; | ||
// } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
l: Do we want to keep this around?
2bd1c74
to
0308803
Compare
@andreiborza - I updated the PR. Waiting for fastify/otel#35 to be released. |
I would assume this also closes #12844? |
looks like it's been released with Make sure to update the lock file when you bump. |
bd5f0ab
to
b1847dc
Compare
b1847dc
to
275a14d
Compare
@andreiborza, @mydea. I bumped the version. I think it's ready to go now. |
43c201f
to
964cf0c
Compare
Yes, that should resolve it as well |
data: { | ||
'sentry.origin': 'manual', | ||
'fastify.type': 'middleware', | ||
'plugin.name': 'fastify -> @fastify/middie', |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
do we have no more plugin/middleware spans like this anymore? Is this "OK"?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Checked again after the updates. We still have the middie
spans, I added them back to the tests. But the problem is now that we don't have access to the requestHook
anymore, the spans are not formatted correctly in NestJS applications (when setupFastifyErrorHandler
is not used). We attempt using addFastifySpanAttributes
inside setupFastifyErrorHandler
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm now trying to use diagnosticsChannel
for it. Maybe we can reach the context from it
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can we try to PR something like the requestHook to the otel instrumentation, maybe? Or is this something they do not want?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@mydea, they released a way to reach the spans: https://github.com/fastify/otel/releases/tag/v0.6.0
The problem is that with this release, they removed the vendored types we added previously. Adding fastify
here as a devDependency
works for TypeScript 5, but not in previous versions. Should we make this an exception for TS-3.8 support/tests?
@onurtemizkan could you maybe share a link of one or two example transactions captured to Sentry with the new version, to compare with the old version? that would be great 🙏 |
5329aaa
to
8ff5f09
Compare
Resolves: #15130
Depends on: fastify/otel#25 for proper
NestJS
support.Opened an issue regarding the problem with
fastify
types: fastify/otel#32The behaviour is not exactly the same as before, mainly because the new instrumentation doesn't have a
requestHook
.