Coder Social home page Coder Social logo

nilportugues / jaeger-nodejs-example Goto Github PK

View Code? Open in Web Editor NEW

This project forked from algun/jaeger-nodejs-example

0.0 2.0 0.0 280 KB

An example of Jaeger instrumentation for Node.js micro-services

Home Page: https://github.com/algun/jaeger-nodejs-example

JavaScript 100.00%

jaeger-nodejs-example's Introduction

Using Jaeger with your Node.js micro-services

My motivation for creating this repository ๐Ÿ˜บ

So you are into micro-services and you already found about OpenTracing and you want to use that fancy JaegerUI to see what is really going on between your micro-services. You already noticed that there are not many examples out there about jaeger and node.js. I hear you! This is why I created this repository, I want to help you understand how multi-micro-service tracing works with Jaeger.

You will learn how your tracers in your micro-services inject ๐Ÿ’‰ and extract ๐Ÿ‘€ headers.

Requirements ๐Ÿ“

How to setup all of these and make it work โœจ

  1. Install prerequisites

    • Make sure you have installed Node.js and Docker

    • Install PM2 globally

      npm i -g pm2
    • Run Jaeger All in One Docker Image

      docker run -d --name jaeger \
      -e COLLECTOR_ZIPKIN_HTTP_PORT=9411 \
      -p 5775:5775/udp \
      -p 6831:6831/udp \
      -p 6832:6832/udp \
      -p 5778:5778 \
      -p 16686:16686 \
      -p 14268:14268 \
      -p 9411:9411 \
      jaegertracing/all-in-one:1.8
  2. Run the example project

    • Clone this repository

      git clone [email protected]:algun/jaeger-nodejs-example.git
    • Change your directory into the project

      cd jaeger-nodejs-example
    • Install packages

      npm i
    • Use PM2 to start up all your services

      pm2 start
    • Use PM2 to watch project logs

      pm2 logs
  3. Visit your initial endpoint to create traces between all services

  4. Visit your local JaegerUI to enjoy your micro-service trace visualizations

  5. Enjoy these views jaeger traces jaeger dag jaeger force directed graph

Understanding how it works โœจ

Here are some key points to understand how this project instruments these services with jaeger:

  • Check ecosystem.config.js file to see how service names and ports are defined
  • Pay attentions to tracer.inject() and tracer.extract() commands to understand how the spans flow into another service via http headers.
  • Notice that init-service has only tracer.inject() since it is the firelight of our multi-micro-service calls.
  • Notice that service4 and service5 have only tracer.extract() since they are the end of the line for our micro-service structure in this example.
  • Notice that service4 still injects its headers with tracer.inject() but it makes no sense since it will not create request any further within this project.

Feel free to comment / give feedback โค๏ธ

This is my humble attempt to help people out who is struggling to understand tracing concept between micro-services.

jaeger-nodejs-example's People

Contributors

algun avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.