DEV Community

Anuwong Mongkudkornburee
Anuwong Mongkudkornburee

Posted on

5 1

NestJS Jaeger(and others) Tracing Module for microservices. You'll loved it! ❤️

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 {}
Enter fullscreen mode Exit fullscreen mode

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.

Image of Timescale

🚀 pgai Vectorizer: SQLAlchemy and LiteLLM Make Vector Search Simple

We built pgai Vectorizer to simplify embedding management for AI applications—without needing a separate database or complex infrastructure. Since launch, developers have created over 3,000 vectorizers on Timescale Cloud, with many more self-hosted.

Read more

Top comments (2)

Collapse
 
dealwap profile image
Abdulrasaq Nasirudeen

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?

Collapse
 
billionaire9 profile image
Anuwong Mongkudkornburee

In current version, it should inject to each microservice you want to trace it, and should start with API Gateway (RESTful, Graphql)

Heroku

Build apps, not infrastructure.

Dealing with servers, hardware, and infrastructure can take up your valuable time. Discover the benefits of Heroku, the PaaS of choice for developers since 2007.

Visit Site