jaeger-tracer
Advanced tools
Comparing version 1.0.16 to 1.0.17
@@ -5,3 +5,3 @@ "use strict"; | ||
var constants_1 = require("./constants"); | ||
var session = continuation_local_storage_1.createNamespace(constants_1.constants.clsNamespace); | ||
var session = continuation_local_storage_1.getNamespace(constants_1.constants.clsNamespace); | ||
exports.associateNMSWithReqBeforeGoingNext = function (req, res, next, mainSpan, interceptorMiddleware) { | ||
@@ -8,0 +8,0 @@ session.bindEmitter(req); |
export declare let initTracer: (serviceName: string, config?: import("./interfaces/jaeger-client-config.interface").Config, options?: import("./interfaces/jaeger-client-config.interface").Options) => import("./interfaces/jaegar-tracer.interface").Tracer; | ||
export declare let makeSpan: (name: string) => import("./interfaces/jaegaer-span.interface").Span; | ||
export declare let makeSpanWithParent: (name: string, parentContext: import("./interfaces/jaegaer-span.interface").SpanContext) => import("./interfaces/jaegaer-span.interface").Span; | ||
export declare let spanMaker: (name: string, parentContext: import("./interfaces/jaegaer-span.interface").SpanContext | null, tracer: import("./interfaces/jaegar-tracer.interface").Tracer) => import("./interfaces/jaegaer-span.interface").Span; | ||
export declare let jaegarTracerMiddleware: (serviceName: string, config?: import("./interfaces/jaeger-client-config.interface").Config | undefined, options?: import("./interfaces/jaeger-client-config.interface").Options | undefined) => (req: import("express-serve-static-core").Request, res: import("express-serve-static-core").Response, next: Function) => void; | ||
export declare let getContext: () => import("continuation-local-storage").Namespace; | ||
export declare let unirestWrapper: (unirest: any) => any; | ||
export declare let requestWrapper: (request: any) => any; | ||
export declare let makeSpan: import("continuation-local-storage").Func<void>; | ||
export declare let makeSpanWithParent: import("continuation-local-storage").Func<void>; | ||
export declare let spanMaker: import("continuation-local-storage").Func<void>; | ||
export declare let jaegarTracerMiddleware: import("continuation-local-storage").Func<void>; | ||
export declare let getContext: import("continuation-local-storage").Func<void>; | ||
export declare let unirestWrapper: import("continuation-local-storage").Func<void>; | ||
export declare let requestWrapper: import("continuation-local-storage").Func<void>; |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
var continuation_local_storage_1 = require("continuation-local-storage"); | ||
var session = continuation_local_storage_1.createNamespace(constants_1.constants.clsNamespace); | ||
var tracer_1 = require("./tracer"); | ||
@@ -8,10 +10,11 @@ var span_1 = require("./span"); | ||
var requestWrappers_1 = require("./requestWrappers"); | ||
var constants_1 = require("./constants"); | ||
exports.initTracer = tracer_1.initTracer; | ||
exports.makeSpan = span_1.makeSpan; | ||
exports.makeSpanWithParent = span_1.makeSpanWithParent; | ||
exports.spanMaker = span_1.spanMaker; | ||
exports.jaegarTracerMiddleware = middleware_1.jaegarTracerMiddleWare; | ||
exports.getContext = ClsManager_1.getContext; | ||
exports.unirestWrapper = requestWrappers_1.unirestWrapper; | ||
exports.requestWrapper = requestWrappers_1.requestWrapper; | ||
exports.makeSpan = session.bind(span_1.makeSpan); | ||
exports.makeSpanWithParent = session.bind(span_1.makeSpanWithParent); | ||
exports.spanMaker = session.bind(span_1.spanMaker); | ||
exports.jaegarTracerMiddleware = session.bind(middleware_1.jaegarTracerMiddleWare); | ||
exports.getContext = session.bind(ClsManager_1.getContext); | ||
exports.unirestWrapper = session.bind(requestWrappers_1.unirestWrapper); | ||
exports.requestWrapper = session.bind(requestWrappers_1.requestWrapper); | ||
//# sourceMappingURL=index.js.map |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
var ClsManager_1 = require("./ClsManager"); | ||
var constants_1 = require("./constants"); | ||
var span_1 = require("./span"); | ||
var spanDataSetter_1 = require("./spanDataSetter"); | ||
var tracer_1 = require("./tracer"); | ||
var constants_1 = require("./constants"); | ||
var continuation_local_storage_1 = require("continuation-local-storage"); | ||
var FORMAT_HTTP_HEADERS = require('opentracing').FORMAT_HTTP_HEADERS; | ||
var session = continuation_local_storage_1.createNamespace(constants_1.constants.clsNamespace); | ||
var context = session.createContext(); | ||
exports.jaegarTracerMiddleWare = function (serviceName, config, options) { | ||
var middlewareBinded = session.runAndReturn(function () { | ||
var tracer = tracer_1.initTracer(serviceName, config, options); | ||
var middleware = function (req, res, next) { | ||
ClsManager_1.saveToCls(constants_1.constants.tracer, tracer); | ||
var parentSpanContext = tracer.extract(FORMAT_HTTP_HEADERS, req.headers); | ||
var mainReqSpan = span_1.spanMaker(req.path, parentSpanContext, tracer); | ||
spanDataSetter_1.setReqSpanData(req, res, mainReqSpan); | ||
var responseInterceptor = spanDataSetter_1.setResSpanData(req, res, mainReqSpan); | ||
ClsManager_1.associateNMSWithReqBeforeGoingNext(req, res, next, mainReqSpan, responseInterceptor); | ||
}; | ||
return middleware; | ||
}); | ||
return middlewareBinded; | ||
var tracer = tracer_1.initTracer(serviceName, config, options); | ||
var middleware = function (req, res, next) { | ||
ClsManager_1.saveToCls(constants_1.constants.tracer, tracer); | ||
var parentSpanContext = tracer.extract(FORMAT_HTTP_HEADERS, req.headers); | ||
var mainReqSpan = span_1.spanMaker(req.path, parentSpanContext, tracer); | ||
spanDataSetter_1.setReqSpanData(req, res, mainReqSpan); | ||
var responseInterceptor = spanDataSetter_1.setResSpanData(req, res, mainReqSpan); | ||
ClsManager_1.associateNMSWithReqBeforeGoingNext(req, res, next, mainReqSpan, responseInterceptor); | ||
}; | ||
return middleware; | ||
}; | ||
//# sourceMappingURL=middleware.js.map |
{ | ||
"name": "jaeger-tracer", | ||
"version": "1.0.16", | ||
"version": "1.0.17", | ||
"description": "client library for jaegar to ease out the instrumenting in express and any other backend application based on express in nodejs", | ||
@@ -5,0 +5,0 @@ "main": "build/index.js", |
@@ -1,9 +0,6 @@ | ||
import { createNamespace, Namespace } from 'continuation-local-storage'; | ||
import { createNamespace, Namespace, getNamespace } from 'continuation-local-storage'; | ||
import { constants } from './constants'; | ||
import { Span } from './interfaces/jaegaer-span.interface'; | ||
let session = getNamespace(constants.clsNamespace); | ||
let session = createNamespace(constants.clsNamespace); | ||
/** | ||
@@ -16,3 +13,3 @@ * @description this function is used before exactly going to the next route to put the span in the cls | ||
*/ | ||
export let associateNMSWithReqBeforeGoingNext = (req: any, res: any, next: Function, mainSpan: Span, interceptorMiddleware: Function) => { | ||
export let associateNMSWithReqBeforeGoingNext = function (req: any, res: any, next: Function, mainSpan: Span, interceptorMiddleware: Function) { | ||
// before rerouting just inputing binding the req , and res to the cls to | ||
@@ -19,0 +16,0 @@ // be used later to the spans |
@@ -0,1 +1,4 @@ | ||
import { createNamespace } from 'continuation-local-storage'; | ||
let session = createNamespace(constants.clsNamespace); | ||
import { initTracer as tracerFunc } from "./tracer"; | ||
@@ -6,2 +9,3 @@ import { makeSpan as ms, makeSpanWithParent as msp, spanMaker as sm } from './span'; | ||
import { requestWrapper as rw, unirestWrapper as uw } from './requestWrappers'; | ||
import { constants } from './constants'; | ||
@@ -16,5 +20,5 @@ /** | ||
*/ | ||
export let makeSpan = ms; | ||
export let makeSpanWithParent = msp; | ||
export let spanMaker = sm; | ||
export let makeSpan = session.bind(ms); | ||
export let makeSpanWithParent = session.bind(msp); | ||
export let spanMaker = session.bind(sm); | ||
@@ -24,3 +28,3 @@ /** | ||
*/ | ||
export let jaegarTracerMiddleware = jtm; | ||
export let jaegarTracerMiddleware = session.bind(jtm); | ||
@@ -31,8 +35,9 @@ | ||
*/ | ||
export let getContext = gc; | ||
export let getContext = session.bind(gc); | ||
/** | ||
* exporting the wrappers | ||
*/ | ||
export let unirestWrapper = uw; | ||
export let requestWrapper = rw; | ||
export let unirestWrapper = session.bind(uw); | ||
export let requestWrapper = session.bind(rw); |
import { Request, Response } from "express-serve-static-core"; | ||
import { associateNMSWithReqBeforeGoingNext, saveToCls, getContext } from "./ClsManager"; | ||
import { associateNMSWithReqBeforeGoingNext, saveToCls } from "./ClsManager"; | ||
import { constants } from "./constants"; | ||
import { Config, Options } from "./interfaces/jaeger-client-config.interface"; | ||
@@ -7,7 +8,3 @@ import { spanMaker } from "./span"; | ||
import { initTracer } from './tracer'; | ||
import { constants } from "./constants"; | ||
import { createNamespace } from "continuation-local-storage"; | ||
let { FORMAT_HTTP_HEADERS } = require('opentracing'); | ||
let session = createNamespace(constants.clsNamespace); | ||
let context = session.createContext(); | ||
@@ -18,37 +15,33 @@ /** | ||
*/ | ||
export let jaegarTracerMiddleWare = (serviceName: string, config?: Config, options?: Options) => { | ||
export let jaegarTracerMiddleWare = function (serviceName: string, config?: Config, options?: Options) { | ||
let middlewareBinded = session.runAndReturn(() => { | ||
// initiating the tracer outside the middleware so we dont have to initiate it everytime a request comes | ||
let tracer = initTracer(serviceName, config, options); | ||
// initiating the tracer outside the middleware so we dont have to initiate it everytime a request comes | ||
let tracer = initTracer(serviceName, config, options); | ||
/** | ||
* @description this is an express middleware to be used to instrument an application | ||
* requests and responses | ||
* @param req | ||
* @param res | ||
* @param next | ||
*/ | ||
let middleware = (req: Request, res: Response, next: Function) => { | ||
// saving the tracer in the cls after its initialization | ||
saveToCls(constants.tracer, tracer); | ||
/** | ||
* @description this is an express middleware to be used to instrument an application | ||
* requests and responses | ||
* @param req | ||
* @param res | ||
* @param next | ||
*/ | ||
let middleware = (req: Request, res: Response, next: Function) => { | ||
// saving the tracer in the cls after its initialization | ||
saveToCls(constants.tracer, tracer); | ||
// extract the parent context from the tracer | ||
let parentSpanContext = tracer.extract(FORMAT_HTTP_HEADERS, req.headers); | ||
let mainReqSpan = spanMaker(req.path, parentSpanContext, tracer); | ||
// extract the parent context from the tracer | ||
let parentSpanContext = tracer.extract(FORMAT_HTTP_HEADERS, req.headers); | ||
let mainReqSpan = spanMaker(req.path, parentSpanContext, tracer); | ||
// setting span data on the request | ||
setReqSpanData(req, res, mainReqSpan); | ||
// setting span data on the request | ||
setReqSpanData(req, res, mainReqSpan); | ||
// setting span data on the response and ending the span when the response comes | ||
let responseInterceptor = setResSpanData(req, res, mainReqSpan); | ||
// setting span data on the response and ending the span when the response comes | ||
let responseInterceptor = setResSpanData(req, res, mainReqSpan); | ||
// calling the cls manager and after that running the response interceptor inside it | ||
associateNMSWithReqBeforeGoingNext(req, res, next, mainReqSpan, responseInterceptor); | ||
}; | ||
// calling the cls manager and after that running the response interceptor inside it | ||
associateNMSWithReqBeforeGoingNext(req, res, next, mainReqSpan, responseInterceptor); | ||
}; | ||
return middleware; | ||
}); | ||
return middlewareBinded; | ||
return middleware; | ||
} | ||
@@ -55,0 +48,0 @@ |
@@ -1,3 +0,1 @@ | ||
import { saveToCls } from "./ClsManager"; | ||
import { constants } from "./constants"; | ||
import { Tracer } from "./interfaces/jaegar-tracer.interface"; | ||
@@ -4,0 +2,0 @@ import { Config, Options } from "./interfaces/jaeger-client-config.interface"; |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
69260
983