-
Notifications
You must be signed in to change notification settings - Fork 407
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
No transaction found when setting controller name #73
Comments
Thanks for the report! We haven't seen this particular behavior before. It sounds like the way your middleware stack is configured is causing the transaction-naming API to be called outside of the context of the New Relic transaction tracer sometimes. Given the way the tracer works, it should either fail all the time or none of the time, so that "sometimes" is especially problematic. Is there any chance you could paste your Express middleware configuration, or even better, a reduced test case (3rd party dependencies are fine / expected)? Also, are you seeing any other errors related to New Relic? |
It's something like this: app = express()
app.use allowCrossDomain # just sets some headers
app.use app.router
app.use errors.middleware # Handles errors on the controller, etc A route will look like this: user_show_middlewares = [
time_logger #Processes the response time and sends to the log.
body_parser
signer # validates requests based on some headers
authentication # Sets the current_user to the req based on the request token
(req, res, next) ->
newrelic.setControllerName('users', 'show')
controllers.user.show # This is the action itself.
]
app.get('/v1/users/:id', user_show_middlewares) The actual code is a bit more complicated but this is basically what ends happening from the express point of view. How does newrelic to know what's the current request when I call Thanks! |
Is there a reason you're using the Connect router? We don't actually instrument that because it's been deprecated. You should be able to comment out the The module knows what the current request is because it's using a module called Let me know if pulling the Connect middleware out of the stack makes things any less confusing. |
Ok, cool. I don't remember why that line is there, will try without and reply. Thanks! Albert Callarisa Roca On Wednesday, 30 October, 2013 at 10:05 am, Forrest L Norvell wrote:
|
Tried something like: app = express()
app.use allowCrossDomain # just sets some headers
user_show_middlewares = [
time_logger #Processes the response time and sends to the log.
body_parser
signer # validates requests based on some headers
authentication # Sets the current_user to the req based on the request token
(req, res, next) ->
newrelic.setControllerName('users', 'show')
controllers.user.show # This is the action itself.
]
app.get('/v1/users/:id', user_show_middlewares)
app.use errors.middleware # Handles errors on the controller, etc Same error on the logs, same result on newrelic. Most of the transactions has no controller/action name, somehow a few of them have. Also some requests went to |
I'll see if we can reproduce this locally. We don't really have much coverage around setting the transaction name inline like that. I'd still like to know what's causing it to behave differently on different requests, though. Have you noticed any correlation between request paths and how they get named? |
I think I found a pattern. The only requests that are setting the controller name and action name are the ones that doesn't have any token (create users and create sessions). The rest are failing. I added Also I still get a lot of Thanks! Albert Callarisa Roca On Wednesday, 30 October, 2013 at 12:19 pm, Forrest L Norvell wrote:
|
BTW, the authenticated requests have also 3 headers (plus the token in the params). Albert Callarisa Roca On Wednesday, 30 October, 2013 at 1:58 pm, Albert Callarisa Roca wrote:
|
I created a sample app that builds on what you've told me about your app, and the transaction naming is working as expected there. If there's more detail you can give me about how the tokens are created and validated (or just fork and expand that gist), maybe that will help us figure out what's going on. If you have a custom middleware that's handling those OPTION requests that's not using an Express named route, they will almost definitely be normalized to
Configuring parameters to be ignored only works when New Relic doesn't directly touch the headers at any point, either to read them or to alter them. It seems like the issue here is related to control flow, and maybe our documentation not being as clear as it could be about how transaction naming works. Does what I've explained so far make things any clearer? |
Ok, let me play with it and try to replicate. Thanks man! Albert Callarisa Roca On Wednesday, 30 October, 2013 at 2:34 pm, Forrest L Norvell wrote:
|
I forked the gist to something more like the current, but doesn't fail. |
I found the issue. I just moved the I just saw the line that says |
I'm glad you figured it out!
I should have asked you that first thing, so that's my bad. We're still figuring out how to support this thing! Thanks for working with me and thanks for your patience! |
…f2070b275fa2a00d8 [Snyk] Security upgrade newrelic from 9.5.0 to 10.3.1
Added job to automatically add issues/pr to Node.js Engineering board
Add Node.js 14 to CI
Fixes first-line indentation of license file.
Fixes first-line indentation of license file.
updated readme and docs to reflect new conventions for Next.js middleware as of 12.2.0
I have an Express app and, in a middleware, I set the controller name and action to newrelic. Randomly it logs the following message:
In newrelic I get some transactions with controller#action, some with the normalized URL and some with just
/*
.The text was updated successfully, but these errors were encountered: