-
Notifications
You must be signed in to change notification settings - Fork 390
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 for incomplete transaction names on new-relic dashboard #214
Conversation
sandeep89
commented
Mar 31, 2016
- Avoid polluting the partial name, which eventaully is the transaction name
- Hence do not worry it at cleanup
Avoid polluting partialname and hence removed the worry of storing original route/partialname which was causing issue while logging transaction on newrelic
@sandeep89 can you please provide a test case? |
Yes sure, will do. |
Actually we do have test-case for this change, the problem was in the nested routes where the callback chains are nested (a specific express 4.0 version issue)
|
@sandeep89 This does not show me the issue you are trying to solve. Can you please add a test to this file that shows the specific Express setup that causes incorrect transaction name? |
@martinkuba , added testcase which if you try to run with the original repo would fail and is a valid part of express ecosystem. |
@sandeep89 We are naming based on the route that actually responded. In your case router2/path1 did not respond. Consider adding the following route to your test case app.get('/:var1/:var2/:var3', function(req, res, next) {
next()
}) What should the name be now - /:router1/:router2/path1 or /:var1/:var2/:var3? |
@martinkuba , In my case the middleware did pass through the route, and eventually it passes through the success callback handler which is the last app.use
so for a route '/:var1/:var2/:var3', in route2 we should expect transaction to be logged as /:router1/:router2/:var1/:var2/:var3, since the call back corresponding to the matching address was called and eventually the required data is passed to a success handler which generalizes the output and sends it. |
@sandeep89 I meant adding this as a second route to the main app (not router2) - the point being that there could be multiple routes that could match the same URL.
Wouldn't you want the transaction to be named based on the route that generated the response, instead of the ones that executed but called next()? Calling next() in a route handler basically means "I am not responding, so passing control to other handlers that might". |
@martinkuba, Agree about the returning concept, but we do follow a pattern when we have common success and error handlers, both in restify and express. And duplicating the method call for each route looks painful to me :(, Also please not that the method which I am trying to use captures the exact route which matched, so even if there are conflicts in routes, it would not be our concern as the instrumentation would work on the request object and pull the required path and route. |
@martinkuba , please suggest a work around for this. Transation naming would be real pain for me I have to do it for all the routes which is around 200 in my service |
@sandeep89 We cannot accept this PR as is because it will break other use cases (see my previous comment). You can also see the broken tests by running: I would also be hesitant to make this change because it would break the opposite assumption, i.e. if I don't reply from a route, then it should not be named as that route. We cannot do both. Why not have a common function for sending the reply and calling it from each route instead of calling next()? You could also use naming rules in your configuration file. |
@martinkuba sure will try and create a workaround of my own over the existing stuff, thanks for the reply |