Skip to content
This repository has been archived by the owner on Dec 15, 2023. It is now read-only.

Instrument gRPC client and server methods with Zipkin

License

Notifications You must be signed in to change notification settings

fonoster/grpc-interceptors

 
 

Repository files navigation

Credit and source

https://github.com/echo-health/node-grpc-interceptors

grpc-interceptors

This library provides a way to instrument Node.js gRPC clients and servers with interceptors/middleware e.g. for Prometheus metrics, Zipkin tracing etc.

Usage

const interceptors = require('grpc-interceptors');
const grpc = require('grpc');

const server = interceptors.serverProxy(new grpc.Server());
server.addService(proto.MyPackage.MyService.service, { Method1, Method2 });

const myMiddlewareFunc = async function (ctx, next, errorCb) {

    try {
    // do stuff before call
    console.log('Making gRPC call...');
    await next()
    // do stuff after call
    console.log(ctx.status.code);
    } catch(e) {
        errorCb({
            code: grpc.status.INTERNAL,
            message: 'Some error occurred!'
        });
    }
}

server.use(myMiddlewareFunc);

Available Interceptors

About

Instrument gRPC client and server methods with Zipkin

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • JavaScript 98.6%
  • Makefile 1.4%