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

Latest commit

 

History

History
69 lines (58 loc) · 2.03 KB

README.md

File metadata and controls

69 lines (58 loc) · 2.03 KB

OpenTracing Tutorial - Node.js

Installing

The tutorials are using CNCF Jaeger (https://github.com/jaegertracing/jaeger) as the tracing backend, see here how to install it in a Docker image.

First clone the opentracing-tutorial, then install the dependencies:

cd opentracing-tutorial/nodejs
npm install

The rest of the commands in the Node.js tutorials should be executed relative to this nodejs directory.

Under construction

This tutorial is currently incomplete. You can try following the tutorials in the other languages and adapt them to Node.js, as all the same features are available in the OpenTracing API for Javascript (https://github.com/opentracing/opentracing-javascript). Use the following code to initialize Jaeger tracer:

var initJaegerTracer = require("jaeger-client").initTracer;

function initTracer(serviceName) {
  var config = {
    serviceName: serviceName,
    sampler: {
      type: "const",
      param: 1,
    },
    reporter: {
      logSpans: true,
    },
  };
  var options = {
    logger: {
      info: function logInfo(msg) {
        console.log("INFO ", msg);
      },
      error: function logError(msg) {
        console.log("ERROR", msg);
      },
    },
  };
  return initJaegerTracer(config, options);
}

Lessons