Does GRPC Middleware library support grpc-node? I'm interested in logging grpc proto requests, and it seems like I might have to learn golang in order to have a logging feature?
Asked
Active
Viewed 632 times
1 Answers
1
Definitely you don't need to learn Golang for that. You just need to check how to use gRPC interceptors with node. In the interceptor code you will implement any of those features available in the gRPC middleware for Golang.
It would be something like that
const interceptors = require('grpc-interceptors');
const server = interceptors.serverProxy(new grpc.Server());
server.addService(proto.MyPackage.MyService.service, { Method1, Method2 });
const myMiddlewareFunc = function (ctx, next) {
// do stuff before call
console.log('Making gRPC call...');
await next()
// do stuff after call
console.log(ctx.status.code);
}
server.use(myMiddlewareFunc);

Alexsandro Souza
- 806
- 7
- 14
-
Thank you! Just curious what tracing libraries do people normally use for gRPC-Node? – TheRoadLessTaken Aug 05 '20 at 21:44
-
It depends what exactly you are trying to achieve. Are you talking about distributed tracing to track requests across microservices? – Alexsandro Souza Aug 06 '20 at 09:13
-
Yes ^ Exactly this. – TheRoadLessTaken Aug 07 '20 at 16:48
-
Hm.. https://github.com/oslabs-beta/Horus/ this looks promising and seems clear. Also https://github.com/malijs/mali looked promising as well, but not sure if it can trace... Not sure of any other libraries. Have you used them, or have any opinions on them? – TheRoadLessTaken Aug 08 '20 at 03:02