Ninja Pirate Mutants

    koa-devstack-sleuth

    1.0.2 • Public • Published

    Koa Devstack Sleuth

    Koa middleware for traceability of requests, based on the spring sleuth headers

    Usage

    This middelware is a distributed tracing solution for Koa v2, borrowing heavily from Dapper.

    Example

    var koa = require('koa');
    var sleuth = require('koa-devstack-sleuth');
    var app = new koa();
    app.use(sleuth());

    However if you want to use in microservices, in this version of koa-devstack-sleuth, you need add the header before call to other microservices. If you use request-promise see example below:

     
    var options = {
        uri: 'https://api.github.com/user/repos',
        qs: {
            access_token: 'xxxxx xxxxx' // -> uri + '?access_token=xxxxx%20xxxxx'
        },
        headers: {
            'X-B3-SpanId': ctx.get('X-B3-SpanId'),
            'X-B3-TraceId': ctx.get('X-B3-TraceId')
        },
        json: true // Automatically parses the JSON string in the response
    };
     
    rp(options)
        .then(function (repos) {
            console.log('User has %d repos', repos.length);
        })
        .catch(function (err) {
            // API call failed...
        });

    Additional Information

    If you want to use this library, you need at least node v.7 and Harmony.

    Install

    npm i koa-devstack-sleuth

    DownloadsWeekly Downloads

    2

    Version

    1.0.2

    License

    ISC

    Last publish

    Collaborators

    • serenitydevstack