UNPKG

@chankamlam/express-jaeger

Version:

Jaeger middleware to request tracing for express application

68 lines (59 loc) 1.88 kB
const axios = require("axios") // var handleOptions = function(opts){ // var headers = {} // headers[tags.TRACING_TAG] = JSON.stringify(tracing_tag) // tracer.inject(span, FORMAT_HTTP_HEADERS, headers); // opts.headers = {...opts.headers,...headers} // return {...opts} // } // var fn = (function(){ // return (function(){ // let obj=function(opts){ // if(opts){ // console.log(arguments) // return axios(arguments[0]) // } // } // for (const key in axios) { // if (axios.hasOwnProperty(key)) { // const element = axios[key]; // obj[key] = function(x){ // console.log(x) // console.log(arguments) // return element.apply(null,Array.prototype.slice.call(arguments)) // } // } // } // return obj // })() // })() const handler = { apply: function (target, thisArg, argumentsList) { console.log(`apply`); return Object.prototype.call(target, argumentsList); }, // construct(target, args) { // console.log(`construct`); // return target(...args); // } } const Axios = new Proxy(axios, handler) // Axios.get('http://www.baidu.com').then(res => { // console.log(res); // }) // Axios('http://www.baidu.com').then(res => { // console.log(res); // }) // fn({name:"ckl"}) // fn().get("asasas",{name:"ckl"}) // axios.get("http://www.baidu.com").then(r=>{console.log(r)}) // axios({ // url:"http://www.baidu.com" // }).then(r=>{console.log(r)}) // fn({ // url:"http://www.baidu.com" // }).then(r=>{console.log("rr")}) // fn.get("http://www.baidu.com",{},"").then(r=>{ // console.log("rrr") // }) // fn("http://www.baidu.com").then(r=>{console.log("r")})