GithubHelp home page GithubHelp logo

opportunitylivetv / zipkin-middleware Goto Github PK

View Code? Open in Web Editor NEW

This project forked from samgiles/zipkin-middleware

1.0 3.0 1.0 156 KB

Zipkin middleware for express applications

License: MIT License

JavaScript 100.00%

zipkin-middleware's Introduction

Zipkin express middleware

API

The zipkin-middleware object can be created with an options object that accepts the following options:

Key Description Default
'scribeHost' The host the scribe daemon is running on 'localhost'
'scribePort' The port the scribe daemon is listening on 1463
'scribeCategory' The name of the category to send the Zipkin traces to 'zipkin'
'serviceName' The name of the service to identify it in Zipkin traces 'default-express-app'

For example:

var zipkinMiddleware = new ZipkinMiddleware({
	scribeHost: '10.0.0.3',
	scribePort: 1234,
	scribeCategory: 'my-custom-category',
	serviceName: "my-service"
});

Using the middleware

The created middleware object needs to be installed on a route using the install method, for example:

var zipkinMiddleware = new ZipkinMiddleware();
app.use(zipkinMiddleware.install());

Additionally the middleware must be initialised before starting the HTTP server using the initialize, async method.

var zipkinMiddleware = new ZipkinMiddleware();
zipkinMiddleware.initialize(function(error, ready) {
	if (error) { throw error; }
	app.listen(myAppsPort, bindAddress);
});

Basic Usage

var express = require('express');
var app = express();

var ZipkinMiddleware = require('zipkin-middleware');

// Create a new Middleware object
var zipkinMiddleware = new ZipkinMiddleware({
	serviceName: "my-service"
});

// Install the middleware
app.use(zipkinMiddleware.install());

// Create routes etc. as normal
app.get('/', function(request, response) {
	request.addTraceAnnotation('some', 'extra data to attach to the trace');

	response.send("Hello World");
});

// Because the middleware needs to asynchronously connect to the scribe daemon
// we need to initialise it for the first time before serving requests in
// order to capture all requests.
zipkinMiddleware.initialise(function(error, ready) {
	if (error) {
		throw error;
	}

	// Once connected, start the http server
	app.listen(8080, 'localhost');
});

License

MIT

zipkin-middleware's People

Contributors

samgiles avatar

Stargazers

 avatar

Watchers

James Cloos avatar  avatar  avatar

Forkers

martina6hall

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.