jaeger-tracer
Advanced tools
Comparing version 1.1.3 to 1.1.4
@@ -5,3 +5,3 @@ 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: (http: any, 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 jaegarTracerMiddleware: (httpModules: import("./interfaces/httpModules.interface").httpModules, 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; | ||
@@ -8,0 +8,0 @@ export declare let unirestWrapper: <T extends { |
import { Request, Response } from "express-serve-static-core"; | ||
import { Config, Options } from "./interfaces/jaeger-client-config.interface"; | ||
export declare let jaegarTracerMiddleWare: (http: any, serviceName: string, config?: Config | undefined, options?: Options | undefined) => (req: Request, res: Response, next: Function) => void; | ||
import { httpModules } from './interfaces/httpModules.interface'; | ||
export declare let jaegarTracerMiddleWare: (httpModules: httpModules, serviceName: string, config?: Config | undefined, options?: Options | undefined) => (req: Request, res: Response, next: Function) => void; |
@@ -11,3 +11,3 @@ "use strict"; | ||
var session = continuation_local_storage_1.getNamespace(constants_1.constants.clsNamespace); | ||
exports.jaegarTracerMiddleWare = function (http, serviceName, config, options) { | ||
exports.jaegarTracerMiddleWare = function (httpModules, serviceName, config, options) { | ||
var tracer = tracer_1.initTracer(serviceName, config, options); | ||
@@ -21,3 +21,3 @@ var middleware = function (req, res, next) { | ||
var responseInterceptor = spanDataSetter_1.setResSpanData(req, res, mainReqSpan); | ||
spanDataSetter_1.putParentHeaderInOutgoingRequests(http, tracer, mainReqSpan); | ||
spanDataSetter_1.putParentHeaderInOutgoingRequests(httpModules, tracer, mainReqSpan); | ||
ClsManager_1.associateNMSWithReqBeforeGoingNext(req, res, next, mainReqSpan, responseInterceptor); | ||
@@ -24,0 +24,0 @@ }); |
import { Request, Response } from "express"; | ||
import { Span } from "./interfaces/jaegaer-span.interface"; | ||
import { Tracer } from "./interfaces/jaegar-tracer.interface"; | ||
import { httpModules } from "./interfaces/httpModules.interface"; | ||
export declare let setReqSpanData: (req: Request, res: Response, span: Span) => Span; | ||
export declare let setResSpanData: (req: Request, res: Response, span: Span) => any; | ||
export declare let putParentHeaderInOutgoingRequests: (http: any, tracer: Tracer, span: Span) => void; | ||
export declare let putParentHeaderInOutgoingRequests: ({ http, https }: httpModules, tracer: Tracer, span: Span) => void; |
@@ -54,5 +54,7 @@ "use strict"; | ||
}; | ||
exports.putParentHeaderInOutgoingRequests = function (http, tracer, span) { | ||
exports.putParentHeaderInOutgoingRequests = function (_a, tracer, span) { | ||
var http = _a.http, https = _a.https; | ||
var headers = requestWrappers_1.getInjectHeaders(tracer, span); | ||
var oldHttpRequest = http.request; | ||
var oldHttpsRequest = https.request; | ||
var newRequestHttp = function () { | ||
@@ -67,4 +69,14 @@ var args = []; | ||
}; | ||
var newRequestHttps = function () { | ||
var args = []; | ||
for (var _i = 0; _i < arguments.length; _i++) { | ||
args[_i] = arguments[_i]; | ||
} | ||
if (args[0] && args[0]['headers']) | ||
args[0]['headers'] = __assign({}, args[0]['headers'] || {}, headers || {}); | ||
return oldHttpsRequest.apply(void 0, args); | ||
}; | ||
http.request = newRequestHttp; | ||
https.request = newRequestHttps; | ||
}; | ||
//# sourceMappingURL=spanDataSetter.js.map |
{ | ||
"name": "jaeger-tracer", | ||
"version": "1.1.3", | ||
"version": "1.1.4", | ||
"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", |
@@ -9,2 +9,3 @@ import { getNamespace } from 'continuation-local-storage'; | ||
import { initTracer } from './tracer'; | ||
import { httpModules } from './interfaces/httpModules.interface'; | ||
let { FORMAT_HTTP_HEADERS } = require('opentracing'); | ||
@@ -17,3 +18,3 @@ let session = getNamespace(constants.clsNamespace); | ||
*/ | ||
export let jaegarTracerMiddleWare = function (http: any, serviceName: string, config?: Config, options?: Options) { | ||
export let jaegarTracerMiddleWare = function (httpModules: httpModules, serviceName: string, config?: Config, options?: Options) { | ||
@@ -46,3 +47,3 @@ // initiating the tracer outside the middleware so we dont have to initiate it everytime a request comes | ||
// monkey patch http and https modules to put the headers inside | ||
putParentHeaderInOutgoingRequests(http, tracer, mainReqSpan); | ||
putParentHeaderInOutgoingRequests(httpModules, tracer, mainReqSpan); | ||
@@ -49,0 +50,0 @@ // calling the cls manager and after that running the response interceptor inside it |
@@ -9,2 +9,3 @@ import { Request, Response } from "express"; | ||
import { getInjectHeaders } from "./requestWrappers"; | ||
import { httpModules } from "./interfaces/httpModules.interface"; | ||
@@ -68,6 +69,7 @@ export let setReqSpanData = (req: Request, res: Response, span: Span) => { | ||
export let putParentHeaderInOutgoingRequests = (http: any, tracer: Tracer, span: Span) => { | ||
export let putParentHeaderInOutgoingRequests = ({ http, https }: httpModules, tracer: Tracer, span: Span) => { | ||
let headers = getInjectHeaders(tracer, span); | ||
let oldHttpRequest: any = http.request; | ||
let oldHttpsRequest: any = https.request; | ||
@@ -81,3 +83,11 @@ let newRequestHttp = function (...args: any[]) { | ||
let newRequestHttps = function (...args: any[]) { | ||
if (args[0] && args[0]['headers']) | ||
args[0]['headers'] = { ...args[0]['headers'] || {}, ...headers || {} }; | ||
return oldHttpsRequest(...args); | ||
} | ||
http.request = newRequestHttp; | ||
https.request = newRequestHttps; | ||
} |
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
77469
53
1073