jaeger-tracer
Advanced tools
Comparing version 1.0.15 to 1.0.16
@@ -5,5 +5,5 @@ 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 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) => import("continuation-local-storage").Func<void>; | ||
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; |
@@ -0,2 +1,3 @@ | ||
import { Request, Response } from "express-serve-static-core"; | ||
import { Config, Options } from "./interfaces/jaeger-client-config.interface"; | ||
export declare let jaegarTracerMiddleWare: (serviceName: string, config?: Config | undefined, options?: Options | undefined) => import("continuation-local-storage").Func<void>; | ||
export declare let jaegarTracerMiddleWare: (serviceName: string, config?: Config | undefined, options?: Options | undefined) => (req: Request, res: Response, next: Function) => void; |
@@ -13,14 +13,16 @@ "use strict"; | ||
exports.jaegarTracerMiddleWare = function (serviceName, config, options) { | ||
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); | ||
}; | ||
var result = session.bind(middleware, context); | ||
return result; | ||
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; | ||
}; | ||
//# sourceMappingURL=middleware.js.map |
{ | ||
"name": "jaeger-tracer", | ||
"version": "1.0.15", | ||
"version": "1.0.16", | ||
"description": "client library for jaegar to ease out the instrumenting in express and any other backend application based on express in nodejs", | ||
@@ -31,2 +31,3 @@ "main": "build/index.js", | ||
"dependencies": { | ||
"cls-hooked": "^4.2.2", | ||
"continuation-local-storage": "^3.2.1", | ||
@@ -39,2 +40,3 @@ "express-interceptor": "^1.2.0", | ||
"devDependencies": { | ||
"@types/cls-hooked": "^4.2.1", | ||
"@types/continuation-local-storage": "^3.2.1", | ||
@@ -41,0 +43,0 @@ "@types/express": "^4.16.0", |
@@ -19,33 +19,35 @@ import { Request, Response } from "express-serve-static-core"; | ||
// initiating the tracer outside the middleware so we dont have to initiate it everytime a request comes | ||
let tracer = initTracer(serviceName, config, 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); | ||
/** | ||
* @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; | ||
}); | ||
let result = session.bind(middleware, context); | ||
return result; | ||
return middlewareBinded; | ||
} | ||
@@ -52,0 +54,0 @@ |
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
69907
992
6
5
+ Addedcls-hooked@^4.2.2
+ Addedasync-hook-jl@1.7.6(transitive)
+ Addedcls-hooked@4.2.2(transitive)
+ Addedstack-chain@1.3.7(transitive)