Allow customization of the message sent in recordRpc (express-middleware)
See original GitHub issueHello! At the moment, message sent in recordRpc is a combination of req.method
and req.route.path
as can be seen here:
https://github.com/openzipkin/zipkin-js/blob/aeb5d09beaa3b3dd634200625f236c76ea4630d0/packages/zipkin-instrumentation-express/src/expressMiddleware.js#L58
It would be a great improvement to allow the customization of this message.
Maybe through a method passed as an argument of expressMiddleware function (like tracer, servicename and port). This method could accept req
object as argument to have access to properties like req.originalUrl
or req.baseUrl
With this improvement examples like this could be achieved.
const customMessage = function customMessage(req) {
return 'Custom message: '.concat(serviceName, ' ').concat(req.method, ' ')
.concat(req.baseUrl).concat(req.route.path);
};
// Add zipkin middleware
app.use(zipkinMiddleware({ tracer, serviceName, customMessage }));
Thanks in advance.
Issue Analytics
- State:
- Created 4 years ago
- Reactions:5
- Comments:9 (5 by maintainers)
Top Results From Across the Web
Writing middleware for use in Express apps - Express.js
Every time the app receives a request, it prints the message “LOGGED” to the terminal. The order of middleware loading is important: middleware...
Read more >Complete Guide to Express Middleware - Reflectoring
Middleware in Express are functions that come into play after the server receives the request and before the response is sent to the...
Read more >How To Create a Custom Middleware in Express.js
You can enable your custom middleware in your Express server by applying the built-in Express.js middleware, .use() . In your server.js file, ...
Read more >Cannot send audio using `RecordRTC.js` to backend
Please try this: sendMMS() { var fileType = 'audio'; // or "audio" var fileName = 'abcde.wav'; // or "wav" let formData = new...
Read more >WebRTC API - MDN Web Docs - Mozilla
Most streams consist of at least one audio track and likely also a video track, and can be used to send and receive...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Thanks for your responses @jcchavezs and @ghermeto. I will try to explain the need to customize the Rpc.
Our API framework does not allow us to include the whole endpoint inside
req.route.path
in consequence we are not able to distinguise two endpoints from two different services in Zipkin.Lets say:
Service 1:
Service 2:
With the actual behaviour of express-middleware
recordRpc
method will send the same message for both services (post /add
). If we want to apply metrics based on this field both services will be considered the same, which is a mistake. Unfortunately recode our routing system to avoid this problem is not possible, that’s why we request this change.I can’t see how the
spanCustomizer
could help to solve this problem becuse ifrecordRpc
method is not replaced, the same message will be sent anyway.A possible implementation of the change that we request could be: Add
customMessage
argument to https://github.com/openzipkin/zipkin-js/blob/aeb5d09beaa3b3dd634200625f236c76ea4630d0/packages/zipkin-instrumentation-express/src/expressMiddleware.js#L30Result:
Replace code inside if statement at https://github.com/openzipkin/zipkin-js/blob/aeb5d09beaa3b3dd634200625f236c76ea4630d0/packages/zipkin-instrumentation-express/src/expressMiddleware.js#L57-L59
Result:
I hope that this explanation helps to understand our request.
Thank you
Awesome @DavidGarNav!