-
Notifications
You must be signed in to change notification settings - Fork 309
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
Fix nextjs resource name #2834
Fix nextjs resource name #2834
Conversation
Codecov Report
@@ Coverage Diff @@
## master #2834 +/- ##
=======================================
Coverage 89.14% 89.14%
=======================================
Files 315 313 -2
Lines 11260 11178 -82
Branches 33 33
=======================================
- Hits 10038 9965 -73
+ Misses 1222 1213 -9
... and 6 files with indirect coverage changes 📣 We’re building smart automated test selection to slash your CI/CD build times. Learn more |
f431c1e
to
86e57b8
Compare
86e57b8
to
6639038
Compare
Thanks for the PR and sorry for the delay.
Do you know if 13.1.7 works properly now that it has been released? Our tests stopped working but that doesn't always mean that the instrumentation did as well, and we didn't really have time to look into it. If it's actually broken please let me know, and also let me know if you want to attempt a fix so that we don't duplicate the work. |
@rochdev Thanks for merging!
I don't believe 13.1.7 has been released, it looks like it's still in canary. I suspect it's been "promoted" to 13.2.
And yes, I'll be attempting a fix :) Might be worth noting that next.js has recently started adding opentelemetry support: vercel/next.js#46198. It's still very early stage though. |
* add failing test * fix test --------- Co-authored-by: Selim Belhaouane <selim.belhaouane@garda.com>
* add failing test * fix test --------- Co-authored-by: Selim Belhaouane <selim.belhaouane@garda.com>
* add failing test * fix test --------- Co-authored-by: Selim Belhaouane <selim.belhaouane@garda.com>
* add failing test * fix test --------- Co-authored-by: Selim Belhaouane <selim.belhaouane@garda.com>
What does this PR do?
Fixes an issue with the
next
instrumentation where the resource name for the trace would be wrong when a dynamic route matches a path but isn't actually the one that will handle the page. For instance, given the following directory structure inpages
:then a request to
/api/other
will result in anext.request
span withresource.name = GET /api/hello/[name]
, even though theapi/hello/other.js
route will be the one to handle the request. Thus, in this case I would expectresource.name
to beGET /api/hello/other
.I can create an actual issue for this if you'd prefer.
The bug is shown as a failing test in this PR's first commit (b82e242 - add failing test). Specifically, the test that fails (on all versions) is:
for api routes -> should infer the corrrect resource path (/api/hello/other)
. Note that the new tests infor pages
do not fail, but I thought they'd be valuable to have anyway.The bug is fixed in the next commit (f431c1e - fix test).
Motivation
I wanted accurate resource names in the Trace view on Datadog.
Plugin Checklist
Additional Notes
Heads-up: I believe the
next
instrumentation will break inv13.1.7
due to Server Router Improvements. Specifically, whilehandleApiRequest
will still exist,this.dynamicRoutes
will no longer exist.However, it looks like
handleApiRequest
will have the page readily available in its parameters, so it's actually simpler.When
v13.1.7
does get released, I'd be happy to help with updating the instrumentation :). Let me know.