Giter Site home page Giter Site logo

zipkin-js's Introduction

Zipkin.js

Build Status npm version Gitter chat

This is a library for instrumenting Node.js applications. It uses a lot of new JavaScript features and syntax, so Node.js version 6 or newer is required.

If you'd like to try this out right away, try our example app which shows how tracing services looks.

Installation:

npm install zipkin --save

Basic Setup:

const {
  Tracer,
  BatchRecorder,
  jsonEncoder: {JSON_V2}
} = require('zipkin');
const CLSContext = require('zipkin-context-cls');
const {HttpLogger} = require('zipkin-transport-http');

// Setup the tracer to use http and implicit trace context
const tracer = new Tracer({
  ctxImpl: new CLSContext('zipkin'),
  recorder: new BatchRecorder({
    logger: new HttpLogger({
      endpoint: 'http://localhost:9411/api/v2/spans',
      jsonEncoder: JSON_V2
    })
  }),
  localServiceName: 'service-a' // name of this application
});

// now use tracer to construct instrumentation! For example, fetch
const wrapFetch = require('zipkin-instrumentation-fetch');

const remoteServiceName = 'youtube';
const zipkinFetch = wrapFetch(fetch, {tracer, remoteServiceName});

Instrumentations

Various Node.js libraries have been instrumented with Zipkin support. Every instrumentation has an npm package called zipkin-instrumentation-*.

At the time of writing, zipkin-js instruments these libraries:

  • cujojs/rest (zipkin-instrumentation-cujojs-rest)
  • express (zipkin-instrumentation-express)
  • fetch (zipkin-instrumentation-fetch)
  • hapi (zipkin-instrumentation-hapi)
  • memcached (zipkin-instrumentation-memcached)
  • redis (zipkin-instrumentation-redis)
  • restify (zipkin-instrumentation-restify)
  • postgres (zipkin-instrumentation-postgres)
  • request (zipkin-instrumentation-request)
  • connect (zipkin-instrumentation-connect)
  • superagent (zipkin-instrumentation-superagent)
  • grpc-client (zipkin-instrumentation-grpc-client)

Every module has a README.md file that describes how to use it.

Transports

You can choose between multiple transports; they are npm packages called zipkin-transport-*.

Currently, the following transports are available:

Every package has its own README.md which describes how to use it.

Clock precision

Zipkin timestamps are microsecond, not millisecond granularity. When running in node.js, process.hrtime is used to achieve this.

In browsers, microsecond precision requires installing a shim like browser-process-hrtime:

// use higher-precision time than milliseconds
process.hrtime = require('browser-process-hrtime');

Developing

The code base is a monorepo. We use Lerna for managing inter-module dependencies, which makes it easier to develop coordinated changes between the modules. Instead of running lerna directly, the commands are wrapped with npm; npm run lerna-publish.

To setup the development environment, run:

yarn

Running tests: yarn test

Note that the memcached, redis and postgres integration tests requires you to have local instances running. The Kafka integration test will start an embedded Kafka server for the test, which requires you to have Java installed on your machine.

Running code style linting: yarn lint

AppVeyor is currently broken and ignored. PR welcome from those with Windows boxes.

Publishing

If you are a user waiting for a merged feature to get released, nag us on the related pull request or gitter.

The actual publish process is easy: Log in to npm with the "OpenZipkin" user. Then, run npm run lerna-publish.

zipkin-js's People

Contributors

jcchavezs avatar adriancole avatar eirslett avatar mkante avatar ghermeto avatar yonran avatar sveisvei avatar muymoo avatar simenb avatar pbadenski avatar kevin-greene-ck avatar juhovh avatar jquatier avatar voldern avatar rexxars avatar rooftopsparrow avatar haoguanjun avatar chris-smith-zocdoc avatar hakanson avatar danielmschmidt avatar unindented avatar sebastianvera avatar struhtanov avatar seshness avatar spoulson avatar pchiwan avatar tomasalabes avatar shakuzen avatar tonypizzicato avatar zackangelo avatar

Watchers

James Cloos avatar Jorge Arco 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.