Once my team have to track the application behavior after it had been deployed to production for a few months. We are looking for an easy way to add the tracing things on top of production-ready application. so we developed this package. nestjs-jaeger-tracing.
To use this module, you just import TracingModule
to your AppModule and initiate with forRoot()
to add app level interceptor to deserialize microservice payload. Then add serializer which will inject tracing id to payload, like this.
import { TracingModule } from '@dollarsign/nestjs-jaeger-tracing';
import { Module } from '@nestjs/common';
import { ClientsModule, Transport } from '@nestjs/microservices';
@Module({
imports: [
TracingModule.forRoot({
exporterConfig: {
serviceName: 'core-service', // service name that will be shown in jaeger dashboard
},
isSimpleSpanProcessor: true, // true for development.
}),
ClientsModule.register([
{
name: 'MATH_SERVICE',
transport: Transport.TCP,
options: {
port: 3001,
...TracingModule.getParserOptions(), // this method will return serializer that inject tracing id to microservice payload.
},
},
]),
],
})
export class AppModule {}
Now, your application will be sent data to jaeger agent so you can trace your application in Jaeger Dashboard. hurayyyy!
It has so much work to do more, so feel free to use and contribute for your works.
Top comments (2)
Thank you for making such a great library, I have a question, should this be integrated inside of the API Gateway or it needs to be set up within each micro services?
In current version, it should inject to each microservice you want to trace it, and should start with API Gateway (RESTful, Graphql)