UNPKG

atatus-node

Version:

The official Atatus agent for Node.js

2 lines 93.7 kB
function Atatus(t){this.agent=t}var cachedModules=[];cachedModules[1113]={exports:{}},function(t,e){"use strict";t.exports=require("loglevel")}.call(this,cachedModules[1113],cachedModules[1113].exports),cachedModules[5544]={exports:{}},function(t,e){t.exports={name:"atatus-node",version:"0.1.7",description:"The official Atatus agent for Node.js",author:{name:"Atatus, Inc"},homepage:"https://www.atatus.com",keywords:["atatus","apm","error","errors","exceptions","monitor","monitoring","alerts","performance","ops","devops","metrics","stacktrace"],contributors:[],main:"./index.js",types:"./index.d.ts",dependencies:{shimmer:"^1.1.0",request:"2.74.0","stack-trace":"^0.0.9","json-stringify-safe":"^5.0.1",loglevel:"^1.4.1",promise:"^7.1.1",semver:"^5.3.0"},devDependencies:{"jasmine-node":"^1.14.2",istanbul:"^0.2.7"},engines:{node:">=0.6.0"},licenses:[{type:"Atatus"}],maintainers:[{name:"atatus",email:"hello@atatus.com"}]}}.call(this,cachedModules[5544],cachedModules[5544].exports),cachedModules[5376]={exports:{}},function(t,e){"use strict";function r(t){return n.resolve(__dirname,t)}var n=require("path"),o=cachedModules[1113].exports,s=cachedModules[5544].exports,i=require("os").hostname(),a={enabled:!0,notifyInterval:60,collectErrors:!0,collectTransactions:!0,ignoreStatusCodes:[404],filters:["password"],projectRoot:void 0===require.main?null:n.dirname(require.main.filename),useSSL:!0,proxy:null,notifyHost:"apm-rx.atatus.com",notifyPath:"/track/apm/",notifyPort:void 0,uniqueHostname:i,hostname:i,apiKey:process.env.ATATUS_API_KEY,releaseStage:process.env.NODE_ENV||"production",appVersion:null,customData:null,tags:null,logLevel:"info",sendCode:!0,agentName:s.name,agentVersion:s.version,beforeErrorSend:null,groupingKey:null,captureParams:!1,ignoredParams:[],apdexT:.1,configure:function(t){return a.apiKey=t.apiKey||a.apiKey,a.appVersion=t.appVersion||a.appVersion,a.releaseStage=t.releaseStage||a.releaseStage,a.useSSL=null!=t.useSSL?t.useSSL:a.useSSL,a.filters=t.filters||a.filters,a.ignoreStatusCodes=t.ignoreStatusCodes||a.ignoreStatusCodes,a.notifyHost=t.notifyHost||a.notifyHost,a.notifyPort=t.notifyPort||a.notifyPort,a.notifyPath=t.notifyPath||a.notifyPath,a.customData=t.customData||a.customData,a.tags=t.tags||a.tags,a.hostname=t.hostname||a.hostname,a.proxy=t.proxy,t.logLevel&&(a.logLevel=t.logLevel||a.logLevel,o.setLevel(a.logLevel)),null!=t.projectRoot&&(a.projectRoot=r(t.projectRoot)),"function"==typeof t.beforeErrorSend&&(a.beforeErrorSend=t.beforeErrorSend),"function"==typeof t.groupingKey&&(a.groupingKey=t.groupingKey),"boolean"==typeof t.enabled&&(a.enabled=t.enabled),"boolean"==typeof t.sendCode&&(a.sendCode=t.sendCode),a.notifyInterval=t.notifyInterval||a.notifyInterval,a}};t.exports=a}.call(this,cachedModules[5376],cachedModules[5376].exports),cachedModules[2514]={exports:{}},function(t,e){"use strict";var r="Custom",n="CustomTotalTime",o="Custom - ",s=" - ";e.recordCustom=function(t,e){var r=t.getDuration(),n=t.getExclusiveDuration(),s=t.transaction,i=o+o+t.name;e&&s.measure(i,e,r,n),s.measure(i,null,r,n)},e.recordBackground=function(t,e){var o=t.getDuration(),i=t.getExclusiveDuration(),a=t.transaction.trace.getTotalTimeDuration(),c=t.transaction,u=t.partialName,l=u+s+t.name;e&&(c.measure(e,null,o,i),c.measure(n+s+l,null,a,i)),c.measure(r+s+"/all",null,o,i),c.measure(n,null,a,i)}}.call(this,cachedModules[2514],cachedModules[2514].exports),cachedModules[4515]={exports:{}},function(t,e){"use strict";function r(t){this.limit=t||10,this.seen=0,this._data=[]}r.prototype.overflow=function(){var t=this.seen-this.limit;return t>=0?t:0},r.prototype.add=function(t){if(this.seen<this.limit)this._data.push(t);else{var e=Math.floor(Math.random()*(this.seen+2));e<this.limit&&(this._data[e]=t)}this.seen++},r.prototype.toArray=function(){return this._data},r.prototype.merge=function(t){if(t&&t.length&&t!==this._data)for(var e=0;e<t.length;e++)this.add(t[e])},t.exports=r}.call(this,cachedModules[4515],cachedModules[4515].exports),cachedModules[9062]={exports:{}},function(t,e){"use strict";var r=require("request"),n=require("util"),o="Atatus Agent:%s NodeJS:%s",s=t.exports=function(t,e){this.name=t,this.config=e.config||{},this.environment=e.environment||{},this.userAgent=n.format(o,e.config.agentVersion,process.versions.node)};s.prototype.request=function(t,e){var n=this.config,o=this.environment.toJSON();t.apiKey=n.apiKey,t.agent={name:n.agentName,version:n.agentVersion},t.uniqueHostname=o.host&&o.host.bootId||n.uniqueHostname,t.hostname=n.hostname,t.version=n.appVersion,t.tags=n.tags,t.releaseStage=n.releaseStage;var s=this,i=(s.config.useSSL?"https":"http")+"://"+s.config.notifyHost;s.config.notifyPort&&(i+=":"+s.config.notifyPort),i+=s.config.notifyPath+s.name;var a={method:"POST",url:i,proxy:s.config.proxy,body:t,json:!0,headers:{"accept-encoding":"gzip,deflate","User-Agent":s.userAgent},gzip:!0};r.post(a,function(t,r,n){return t?e(t):200===r.statusCode?e(null,n):e(new Error(n.error||"Request Failed!"))})}}.call(this,cachedModules[9062],cachedModules[9062].exports),cachedModules[4853]={exports:{}},function(t,e){"use strict";function r(t){this._agent=t,this._methods={hostInfo:new o("hostinfo",t),errors:new o("error",t),error_metrics:new o("error_metric",t),metrics:new o("txn",t)}}var n=cachedModules[1113].exports,o=cachedModules[9062].exports,s=1e3,i=[{interval:15,warn:!1},{interval:15,warn:!1},{interval:30,warn:!0},{interval:60,warn:!1},{interval:120,warn:!1},{interval:300,warn:!1}];r.prototype.sendHostInfo=function(t){function e(u,l,p){if(u&&c.push(u),!u||o>=a)return t(u,l,p);var h=i[o-1];h.warn&&n.warn("Unable to connect to Atatus server after retries:",o),n.debug("Connecting to Atatus Failed. Retrying in:",h.interval),o++,setTimeout(function(){r._sendHostInfo(e)},h.interval*s)}var r=this,o=1,a=i.length,c=[];this._sendHostInfo(e)},r.prototype._sendHostInfo=function(t){var e=this._agent,r=e.environment.toJSON(),n={settings:{nodejs:r.nodejsVersion,framework:r.framework,logLevel:e.config.logLevel,agentName:e.config.agentName,agentVersion:e.config.agentVersion,proxy:e.config.proxy,ignoreStatusCodes:e.config.ignoreStatusCodes,releaseStage:e.config.releaseStage},host:r.host||{}},o={language:"nodejs",environment:n,timestamp:Date.now()};this._methods.hostInfo.request(o,function(e,r,n){return e?t(e,r,n):void t(null,r,n)})},r.prototype.send=function(t,e,r){this._methods[t].request(e,function(e,o,s){return e?(n.error(e,"Sending metrics to Atatus failed: ",t,e["class"]),r(e,o,s)):r(e,o,s)})},t.exports=r}.call(this,cachedModules[4853],cachedModules[4853].exports),cachedModules[4007]={exports:{}},function(t,e){"use strict";function r(t,e){e=e||{};for(var r in t)t.hasOwnProperty(r)&&(e[r]=t[r]);return e}e.shallow=r}.call(this,cachedModules[4007],cachedModules[4007].exports),cachedModules[4963]={exports:{}},function(t,e){"use strict";function r(t,e){var r=[];return t&&t.ignoreStatusCodes&&(r=t.ignoreStatusCodes),r.indexOf(parseInt(e,10))>=0}var n=require("url");t.exports={isError:function(t,e){return e>=400&&!r(t,e)},isIgnoredError:function(t,e){return e>=400&&r(t,e)},scrub:function(t){"string"==typeof t&&(t=n.parse(t));var e=t.pathname;return e?(e=e.split(";")[0],"/"!==e&&"/"===e.charAt(e.length-1)&&(e=e.substring(0,e.length-1))):e="/",e},getHeadersFromHeaderString:function(t){for(var e={},r="",n="",o=0;o<t.length;++o){var s=t[o];"\r"===s?(r=r.replace(/^\s|\s$/g,""),n=n.replace(/^\s|\s$/g,""),0!==n.length&&0!==r.length&&(e[n]=r),r="",n=""):":"===s?(n=r,r=""):r+=s}return e},parseParameters:function(t){var e=t;"string"==typeof t&&(e=n.parse(t,!0));var r={};if(e.query)for(var o=Object.keys(e.query),s=0,i=o.length;i>s;++s){var a=o[s];""===e.query[a]&&-1===e.path.indexOf(a+"=")?r[a]=!0:r[a]=e.query[a]}return r},copyParameters:function(t,e,r){if(t&&t.captureParams&&e&&r)for(var n=Object.keys(e),o=0;o<n.length;o++){var s=n[o];-1!==t.ignoredParams.indexOf(s)||s in r||(r[s]=e[s])}},overwriteParameters:function(t,e,r){if(t&&e&&r)for(var n=Object.keys(e),o=0;o<n.length;o++){var s=n[o];-1===t.ignoredParams.indexOf(s)&&(r[s]=e[s])}}}}.call(this,cachedModules[4963],cachedModules[4963].exports),cachedModules[672]={exports:{}},function(t,e){"use strict";function r(t){var e=t.split(" - "),r=e.splice(0,2);return{kind:r[0],type:r[1],name:e.join(" - ")}}t.exports={SEGMENT_DELIMITER:" - ",parseName:r}}.call(this,cachedModules[672],cachedModules[672].exports),cachedModules[8671]={exports:{}},function(t,e){"use strict";function r(t,e,r,n,o){var i,p="Web/Uri/*",h="",d="Error";r=r||{},"string"==typeof e?h=e:null!==e&&"object"==typeof e&&e.message?(h=e.message,e.name?d=e.name:e.constructor&&e.constructor.name&&(d=e.constructor.name)):t&&t.statusCode&&c.isError(o,t.statusCode)&&(h="HttpError "+t.statusCode),t&&(p=t.getName()||p,i=t.trace.parameters);var f=null;if(!e)return l.debug("Error sending is ignored due to empty exception."),null;f=a(e,o),o.sendCode&&s(f,function(){});var g=p&&u.parseName(p)||{},m={timestamp:n?n:Date.now(),transaction:g.name,kind:g.kind,type:g.type,customData:r.customData,tags:r.tags,user:{id:r.userId},exceptions:[{message:h,"class":d,stacktrace:f}],request:i};return o.groupingKey&&(m.groupingKey=o.groupingKey(m)),o.beforeErrorSend&&!o.beforeErrorSend(m)?null:m}function n(t,e,r){var n=e[2],s=e[3],i=(e[4],o(t,s,n,r)),a=[i];return a}function o(t,e,r,n){var o={type:"TransactionError","error.class":e,"error.message":r,timestamp:n};return t?(o.transactionName=t.name,o.duration=t.timer.getDuration()/1e3):o.transactionName="None",o}function s(t,e){var r=4;d.all(t.map(function(t){return t.inp?new d(function(e){h.readFile(t.p,function(n,o){if(!n){var s=o.toString().split("\n");t.code=[];for(var i=t.ln-r;i<t.ln-1+r;i++)"string"==typeof s[i]&&t.code.push([""+(i+1),s[i]])}e()})}):void 0})).then(e)}function i(t,e){var r=[];return t.forEach(function(t){var n=t.getFileName();if(n&&-1===n.indexOf("node_modules/atatus-node")&&"<anonymous>"!==n){var o={f:n,p:n,m:t.getMethodName()||t.getFunctionName()||"none",ln:t.getLineNumber(),cn:t.getColumnNumber()};e&&n&&0===n.indexOf(e)&&(o.inp=-1===n.indexOf("node_modules"),o.inp||delete o.inp,o.f=o.f.substr(e.length+1)),r.push(o)}}),r}function a(t,e){var r=p.parse(t);return 0===r.length&&(r=p.get()),i(r,e.projectRoot)}var c=cachedModules[4963].exports,u=cachedModules[672].exports,l=cachedModules[1113].exports,p=(require("util"),require("stack-trace")),h=require("fs"),d=require("promise");t.exports.createError=r,t.exports.createEvent=n}.call(this,cachedModules[8671],cachedModules[8671].exports),cachedModules[1923]={exports:{}},function(t,e){"use strict";function r(){this.startTime=Date.now(),this.metrics={}}var n=cachedModules[672].exports;r.prototype.incrementErrorCount=function(t,e,r){r=r||1;var n=this.getPerfStat(t);return n.statusCodes[e]?n.statusCodes[e]+=r:n.statusCodes[e]=r,n},r.prototype.getPerfStat=function(t){if(!t)throw new Error("Stat name is missing!");var e=this._resolve(t);return e||(e={statusCodes:{}},this.metrics[t]=e),e},r.prototype.getMetric=function(t){if(!t)throw new Error("Stat name is missing!");return this._resolve(t)},r.prototype._resolve=function(t){var e=this.metrics[t];return e},r.prototype.merge=function(t){this.startTime=Math.min(this.startTime,t.startTime),Object.keys(t.metrics).forEach(function(e){var r=this._resolve(e);r?Object.keys(t.metrics[e].statusCodes).forEach(function(r){var n=t.metrics[e].statusCodes,o=this.metrics[e].statusCodes;o[r]?o[r]+=n[r]:o[r]=n[r]},this):this.metrics[e]=t.metrics[e]},this)},r.prototype.toJSON=function(){var t=[];return Object.keys(this.metrics).forEach(function(e){var r=n.parseName(e);r.statusCodes=this.metrics[e].statusCodes,t.push(r)},this),t},t.exports=r}.call(this,cachedModules[1923],cachedModules[1923].exports),cachedModules[3120]={exports:{}},function(t,e){"use strict";function r(t){this.config=t,this.errorCount=0,this.errors=[],this.seen=[],this.metrics=new s,this.metricCount=0}var n=(cachedModules[4007].exports,cachedModules[4963].exports),o=(cachedModules[1113].exports,cachedModules[8671].exports),s=cachedModules[1923].exports,i=o.createError;o.createEvent;t.exports=r;var a=20;r.prototype.onTransactionCompleted=function(t,e){if(!t)throw new Error("ET: Missing transaction.");if(!e)throw new Error("ET: Missing perf data.");if(!t.ignore){var r,o,s=0;if(t.userErrors.length>0)for(o=0;o<t.userErrors.length;o++)r=t.userErrors[o],this.aggregate(t,r[0],r[1],r[2])&&s++;var i=t.exceptions.length>0,a=n.isError(this.config,t.statusCode),c=n.isIgnoredError(this.config,t.statusCode);if(i&&!c)for(o=0;o<t.exceptions.length;o++)r=t.exceptions[o],this.aggregate(t,r[0],r[1],r[2])&&s++;else a&&this.aggregate(t)&&s++}},r.prototype.add=function(t,e,r){if(e){var n=Date.now();t?t.addException(e,r,n):this.aggregate(t,e,r,n)}},r.prototype.addUserError=function(t,e,r){if(e){var n=Date.now();t?t.addUserError(e,r,n):this.aggregate(t,e,r,n)}},r.prototype.aggregate=function(t,e,r,o){if(e){if(-1!==this.seen.indexOf(e))return;"string"==typeof e||e.message||e.stack||(e=null)}if(!e){if(!t)return;if(!t.statusCode)return;if(t.error)return}if(this.config.collectErrors){e&&this.seen.push(e);var s=i(t,e,r,o,this.config);if(t&&t.name&&t.statusCode&&!n.isIgnoredError(this.config,t.statusCode)&&(this.metrics.incrementErrorCount(t.name,t.statusCode,1),this.metricCount++),s)return this.errorCount++,this.errors.length<a&&this.errors.push(s),!0}},r.prototype.getErrors=function(){return this.errors},r.prototype.getMetrics=function(){return this.metrics},r.prototype.getTotalErrorCount=function(){return this.errorCount},r.prototype.getTotalMetricCount=function(){return this.metricCount},r.prototype.merge=function(t){if(t)for(var e=Math.min(t.length,a-this.errors.length),r=0;e>r;r++)this.errors.push(t[r])},r.prototype.mergeMetrics=function(t){this.metrics.merge(t)},r.prototype.clearMetrics=function(){this.metrics=new s,this.metricCount=0},r.prototype.clearErrors=function(){this.errors=[],this.seen=[],this.errorCount=0}}.call(this,cachedModules[3120],cachedModules[3120].exports),cachedModules[7494]={exports:{}},function(t,e){"use strict";function r(){this.total=0,this.min=0,this.max=0,this.callCount=0}function n(t,e){this.storeValue(t,e>=0?e:null)}r.prototype.storeValue=function(t,e){0===t||t||(t=0),0===e||e||(e=t),this.callCount>0?this.min=Math.min(t,this.min):this.min=t,this.max=Math.max(t,this.max),this.callCount+=1,this.total+=t},r.prototype.storeDuration=n,r.prototype.incrementCallCount=function(t){"undefined"==typeof t&&(t=1),this.callCount+=t},r.prototype.merge=function(t){t.callCount>0&&(this.callCount>0?this.min=Math.min(this.min,t.min):this.min=t.min),this.max=Math.max(this.max,t.max),this.total+=t.total,this.callCount+=t.callCount},r.prototype.toJSON=function(){return[this.callCount,this.total,this.min,this.max]},t.exports=r}.call(this,cachedModules[7494],cachedModules[7494].exports),cachedModules[5278]={exports:{}},function(t,e){"use strict";function r(t){if(!t&&0!==t)throw new Error("ApdexT is missing!");this.apdexT=t,this.satisfying=0,this.tolerating=0,this.frustrating=0}r.prototype.storeValue=function(t){t<=this.apdexT?this.satisfying++:t<=4*this.apdexT?this.tolerating++:this.frustrating++},r.prototype.storeDuration=function(t){this.storeValue(t)},r.prototype.incrementFrustrating=function(){this.frustrating++},r.prototype.merge=function(t){this.satisfying+=t.satisfying,this.tolerating+=t.tolerating,this.frustrating+=t.frustrating},r.prototype.toJSON=function(){return[this.satisfying,this.tolerating,this.frustrating,this.apdexT,this.apdexT,0]},t.exports=r}.call(this,cachedModules[5278],cachedModules[5278].exports),cachedModules[8280]={exports:{}},function(t,e){"use strict";function r(t,e,r){if(void 0===t||null===t||""===t)throw new Error("ApdexT is missing");if(!e)throw new Error("Argument is missing!");if(!r)throw new Error("Argument is missing!");this.startTime=Date.now(),this.apdexT=t,this.mapper=e,this.normalizer=r,this.perfMetric={},this.txnMetric={}}function n(t,e,r,n){var o=this.getPerfStat(t,e);return o.storeDuration(r,n),o}function o(t,e,r){if(!t)throw new Error("Stat name is missing");var n=this._resolve(e),o=r>0?r:this.apdexT;return n[t]||(n[t]=new i(o)),n[t]}var s=cachedModules[7494].exports,i=cachedModules[5278].exports,a=cachedModules[672].exports;r.prototype.measureDuration=n,r.prototype.getPerfStat=function(t,e){if(!t)throw new Error("Stat name is missing");var r=this._resolve(e);return r[t]||(r[t]=new s),r[t]},r.prototype.getApdexStat=o,r.prototype.getMetric=function(t,e){if(!t)throw new Error("Stat name is missing");return this._resolve(e)[t]},r.prototype.toJSON=function(){return this._toTxnMetricData()},r.prototype.merge=function(t){this.startTime=Math.min(this.startTime,t.startTime),Object.keys(t.perfMetric).forEach(function(e){this.perfMetric[e]?this.perfMetric[e].merge(t.perfMetric[e]):this.perfMetric[e]=t.perfMetric[e]},this),Object.keys(t.txnMetric).forEach(function(e){Object.keys(t.txnMetric[e]).forEach(function(r){if(t.txnMetric[e][r]){var n=this._resolve(e);n[r]?n[r].merge(t.txnMetric[e][r]):n[r]=t.txnMetric[e][r]}},this)},this)},r.prototype._resolve=function(t){var e;return t?(this.txnMetric[t]||(this.txnMetric[t]={}),e=this.txnMetric[t]):e=this.perfMetric,e},r.prototype._getPerfMetricData=function(t){if(this.perfMetric[t]){var e=this.normalizer.normalize(t);if(e){var r=a.parseName(e);return r.durations=this.perfMetric[t],r}}},r.prototype._getTxnMetricData=function(t,e){if(this.txnMetric[e][t]){var r=this.normalizer.normalize(t);if(r){var n=a.parseName(r);return n.durations=this.txnMetric[e][t],n}}},r.prototype._toPerfMetricData=function(){var t={};return Object.keys(this.perfMetric).forEach(function(e){var r=this._getPerfMetricData(e);r&&t.push(r)},this),t},r.prototype._toTxnMetricData=function(){var t=[];return Object.keys(this.txnMetric).forEach(function(e){var r=this._getPerfMetricData(e);r.traces=[],t.push(r),Object.keys(this.txnMetric[e]).forEach(function(t){var n=this._getTxnMetricData(t,e);n&&r.traces.push(n)},this)},this),t},t.exports=r}.call(this,cachedModules[8280],cachedModules[8280].exports),cachedModules[3538]={exports:{}},function(t,e){"use strict";function r(t){return"[object Arguments]"===Object.prototype.toString.call(t)}function n(t){var e,r=t.length,n=[];for(e=0;r>e;e++)n[e]=t[e];return n}function o(t,e,s,i){if(t===e)return!0;if("object"!=typeof t||"object"!=typeof e)return!1;if(null===t||null===e)return!1;if(Buffer.isBuffer(t)&&Buffer.isBuffer(e)){if(t.length!==e.length)return!1;for(var a=0;a<t.length;a++)if(t[a]!==e[a])return!1;return!0}if(t instanceof Date&&e instanceof Date)return t.getTime()===e.getTime();if(t instanceof RegExp&&e instanceof RegExp)return t.source===e.source&&t.global===e.global&&t.multiline===e.multiline&&t.lastIndex===e.lastIndex&&t.ignoreCase===e.ignoreCase;if(r(t)||r(e))return r(t)&&r(e)?o(n(t),n(e),s,i):!1;if(t.constructor!==e.constructor)return!1;var c=Object.keys(t),u=Object.keys(e);if(c.length!==u.length)return!1;for(var l=s.length;l--;)if(s[l]===t)return i[l]===e;s.push(t),i.push(e),c.sort(),u.sort();for(var p=c.length-1;p>=0;p--)if(c[p]!==u[p])return!1;for(var h,d=c.length-1;d>=0;d--)if(h=c[d],!o(t[h],e[h],s,i))return!1;return s.pop(),i.pop(),!0}t.exports=function(t,e){return o(t,e,[],[])}}.call(this,cachedModules[3538],cachedModules[3538].exports),cachedModules[585]={exports:{}},function(t,e){"use strict";function r(t){t||(t={}),this.eachSegment=t.each_segment||!1,this.precedence=t.eval_order||0,this.isTerminal=t.terminate_chain||!1,this.replacement=n(t.replacement||"$0"),this.replaceAll=t.replace_all||!1,this.ignore=t.ignore||!1;var e="";if(this.replaceAll&&(e+="g"),t.match_expression instanceof RegExp)this.pattern=t.match_expression;else try{this.pattern=new RegExp(t.match_expression||"^$",e)}catch(r){this.pattern=/^$/}}var n=(cachedModules[1113].exports,function(t){return t.replace(/\\/g,"$")});r.prototype.getSegments=function(t){return this.eachSegment?t.split("/"):[t]},r.prototype.matches=function(t){for(var e=this.getSegments(t),r=0;r<e.length;r++)if(e[r].match(this.pattern))return!0;return!1},r.prototype.apply=function(t){return this.getSegments(t).map(function(t){return""===t?t:t.replace(this.pattern,this.replacement)}.bind(this)).join("/")},r.prototype.toJSON=function(){return{eachSegment:this.eachSegment,precedence:this.precedence,isTerminal:this.isTerminal,replacement:this.replacement,replaceAll:this.replaceAll,ignore:this.ignore,pattern:this.pattern.source}},t.exports=r}.call(this,cachedModules[585],cachedModules[585].exports),cachedModules[6234]={exports:{}},function(t,e){"use strict";function r(t,e,r){return t?a+t:e}function n(t,e){return t?t:e}function o(t,e){if(!t)throw new Error("normalizer must be created with configuration.");if(!e)throw new Error("normalizer must be created with a type.");this.config=t,this.type=e,"URL"===e?this.formatter=r:this.formatter=n,this.rules=[]}var s=(cachedModules[1113].exports,cachedModules[3538].exports),i=cachedModules[585].exports,a="CanonicaliedURL";o.prototype.load=function(t){t&&(t.forEach(function(t){var e=new i(t),r=this.rules.some(function(t){return s(t,e)});r||this.rules.push(e)},this),this.rules.sort(function(t,e){return t.precedence-e.precedence}))},o.prototype.loadFromConfig=function(){},o.prototype.addSimple=function(t,e){if(t){var r={match_expression:t,terminate_chain:!0};e?r.replacement=e:r.ignore=!0,this.rules.unshift(new i(r))}},o.prototype.isIgnored=function(t){for(var e=this.rules.length,r=0;e>r;r++){var n=this.rules[r];if(n.ignore&&n.matches(t))return!0}return!1},o.prototype.canNormalize=function(t){for(var e=this.rules.length,r=0;e>r;r++){var n=this.rules[r];if(!n.ignore&&n.matches(t))return!0}return!1},o.prototype.normalize=function(t){for(var e,r=t,n=this.rules.length,o=0;n>o;o++){var s=this.rules[o];if(s.matches(r)){if(e=s.apply(r),s.isTerminal)break;r=e}}return this.formatter(e,t,this.config)},t.exports=o}.call(this,cachedModules[6234],cachedModules[6234].exports),cachedModules[7127]={exports:{}},function(t,e){"use strict";function r(){this.terms=[]}function n(t){for(var e={},r=0,n=t.length;n>r;++r){var o=t[r].prefix;if(o&&"string"==typeof o){"/"!==o[o.length-1]&&(o+="/",t[r].prefix=o);var s=o.split("/");3===s.length&&s[0]&&s[1]&&!s[3]&&Array.isArray(t[r].terms)&&(e[o]=t[r])}}var i=Object.keys(e),a=new Array(i.length);for(r=0,n=i.length;n>r;++r)a[r]=e[i[r]];return a}cachedModules[1113].exports;t.exports=r,r.prototype.normalize=function(t){for(var e,r,n=0;n<this.terms.length;n++)if(e=this.terms[n],r=e.prefix,-1!==t.lastIndexOf(r,0)){for(var o,s,i=t.slice(r.length),a=i.split("/"),c=[],u=0;u<a.length&&(s=a[u],""!==s||u+1!==a.length);u++)if(-1===e.terms.indexOf(s)){if("*"===o)continue;c.push(o="*")}else c.push(o=s);return r+c.join("/")}return t},r.prototype.load=function(t){Array.isArray(t)&&(this.terms=n(t))}}.call(this,cachedModules[7127],cachedModules[7127].exports),cachedModules[9721]={exports:{}},function(t,e){"use strict";function r(t){this.perfMetric={},this.txnMetric={},this.length=0,this.load(t)}cachedModules[1113].exports;r.prototype.load=function(t){if(t&&t.length)for(var e=0;e<t.length;e++){var r,n=t[e][0],o=n.scope,s=n.name,i=t[e][1];o?(this.txnMetric[o]||(this.txnMetric[o]={}),r=this.txnMetric[o]):r=this.perfMetric,r[s]||this.length++,r[s]=i}},r.prototype.map=function(t,e){return e?this.txnMetric[e]&&this.txnMetric[e][t]?this.txnMetric[e][t]:{name:t,scope:e}:this.perfMetric[t]?this.perfMetric[t]:{name:t}},t.exports=r}.call(this,cachedModules[9721],cachedModules[9721].exports),cachedModules[6487]={exports:{}},function(t,e){"use strict";function r(t,e,r){"string"==typeof r&&(r=parseInt(r,16));var o=(r<<1|r>>>31)>>>0,s=n(t,e),i=(o^s)>>>0,a=("00000000"+i.toString(16)).substr(-8);return a}function n(t,e){var r=o.createHash("md5");r.update(new Buffer(t+";"+e),"utf8");var n=new Buffer(r.digest("base64"),"base64");return n.slice(n.length-4,n.length).readUInt32BE(0)}var o=require("crypto");e.calculatePathHash=r,e.getHash=n}.call(this,cachedModules[6487],cachedModules[6487].exports),cachedModules[5283]={exports:{}},function(t,e){"use strict";function r(){if(u.length>0){var t="Atatus should be the first module before:";u.forEach(function(e){t+="\n "+e}),a.warn(t)}}function n(t){}function o(t){var e=i.basename(t,".js");if("index"!==e)return e;for(var r=t.split(i.sep).slice(0,-1),n=r.length-1;n>=0;n--)if("lib"!==r[n])return r[n]}function s(){for(var t in require.cache){if(require.hasOwnProperty(t))return;var e=o(t);-1!==c.indexOf(e)&&u.push(e)}r(u)}var i=require("path"),a=cachedModules[1113].exports;t.exports={check:s,createMetrics:n};var c=["connect","express","hapi","memcached","mongodb","mysql","pg","redis","ioredis","restify"],u=[]}.call(this,cachedModules[5283],cachedModules[5283].exports),cachedModules[6703]={exports:{}},function(t,e){"use strict";function r(){process.nextTick((()=>{"linux"===a&&i("cat /proc/sys/kernel/random/boot_id",function(t,e){t||(e=e||"",c.host.bootId=e.toString().split("\n")[0].trim().toLowerCase(),c.host.hostId=c.host.bootId||c.host.hostId)})}))}function n(){for(var t=s.cpus(),e=0;e<t.length;e++)c.host.cpu.push({cores:1,mhz:t[e].speed,model:t[e].model})}function o(){r(),n()}var s=require("os"),i=require("child_process").exec,a=process.platform,c={framework:"",releaseStage:process.env.NODE_ENV,nodejsVersion:process.version,host:{os:"Windows_NT"===a?"Windows":a,platform:s.type(),kernel:s.release(),arch:s.arch(),hostname:s.hostname(),hostId:s.hostname(),bootId:"",ram:s.totalmem(),cpu:[]}};o(),e.toJSON=function(){return c},e.setFramework=function(t){c.framework=t}}.call(this,cachedModules[6703],cachedModules[6703].exports),cachedModules[3751]={exports:{}},function(t,e){"use strict";function r(t){return 1e3*t[0]+t[1]/1e6}function n(){this.state=s,this.touched=!1,this.duration=null,this.hrDuration=null,this.hrstart=null,this.durationInMillis=null}function o(t){this.touched=!0,this.durationInMillis=t,this.state=a}var s=1,i=2,a=3;n.prototype.begin=function(){this.state>s||(this.start=Date.now(),process.hrtime&&(this.hrstart=process.hrtime()),this.state=i)},n.prototype.end=function(){this.state>i||(this.state===s&&this.begin(),process.hrtime&&(this.hrDuration=process.hrtime(this.hrstart)),this.touched=!0,this.duration=Date.now()-this.start,this.state=a)},n.prototype.touch=function(){this.touched=!0,this.state>i||(this.state===s&&this.begin(),process.hrtime&&(this.hrDuration=process.hrtime(this.hrstart)),this.duration=Date.now()-this.start)},n.prototype.softEnd=function(){return this.state>i?!1:(this.state===s&&this.begin(),this.state=a,this.touched?!1:(process.hrtime&&(this.hrDuration=process.hrtime(this.hrstart)),this.touched=!0,this.duration=Date.now()-this.start,!0))},n.prototype.isRunning=function(){return this.state===i},n.prototype.isActive=function(){return this.state<a},n.prototype.hasEnd=function(){return!!this.hrDuration},n.prototype.overwriteDurationInMillis=o,n.prototype.setDurationInMillis=function(t,e){this.state>i||(this.state===s&&(e||0===e||this.begin()),this.state=a,this.durationInMillis=t,this.hrstart=[Math.floor(e/1e3),e%1e3*1e6],this.start=e)},n.prototype.getDuration=function(){return this.state===s?0:null!==this.durationInMillis&&this.durationInMillis>=0?this.durationInMillis:this.hrDuration?r(this.hrDuration):this.duration?this.duration:process.hrtime?r(process.hrtime(this.hrstart)):Date.now()-this.start},n.prototype.toRange=function(){return[this.start,this.start+this.getDuration()]},n.prototype.startedRelativeTo=function(t){if(this.hrstart&&t.hrstart&&process.hrtime){var e=this.hrstart[0]-t.hrstart[0],n=this.hrstart[1]-t.hrstart[1];return r([e,n])}return this.start-t.start},n.prototype.endsAfter=function(t){return this.getDuration()+this.start>t.getDuration()+t.start},t.exports=n}.call(this,cachedModules[3751],cachedModules[3751].exports),cachedModules[3763]={exports:{}},function(t,e){"use strict";var r=require("zlib");t.exports={encode:function(t,e){try{r.deflate(JSON.stringify(t),function(t,r){return t?e(t):e(null,r.toString("base64"))})}catch(n){return e(n)}},decode:function(t,e){r.inflate(new Buffer(t,"base64"),function(t,r){if(t)return e(t);try{return e(null,JSON.parse(r))}catch(n){return e(n)}})}}}.call(this,cachedModules[3763],cachedModules[3763].exports),cachedModules[5287]={exports:{}},function(t,e){"use strict";function r(t,e){if(!t.length)return 0;t.sort(function(t,e){return t[0]-e[0]});for(var r,n,o=t[0][0],s=o,i=0,a=0,c=t.length;c>a&&(n=t[a],!(n[0]>e));++a)r=n[1]>e?e:n[1],n[0]>s?(i+=n[0]-s,s=r):r>s&&(s=r);return s-o-i}t.exports=r}.call(this,cachedModules[5287],cachedModules[5287].exports),cachedModules[7410]={exports:{}},function(t,e){"use strict";function r(t,e,r){if(!t)throw new Error("All segment must be associated with a transaction.");if(!e)throw new Error("All segment must be named");this.name=e,this.transaction=t,r&&t.addRecorder(r.bind(null,this)),this.parameters={atatus_exclusive_duration_millis:null},this.children=[],this.timer=new l,this.partialName=null,this._exclusiveDuration=null,this._collect=!0,this.host=null,this.port=null,this.state=p.EXTERNAL,this.async=!0,this.ignore=!1}function n(t,e){this.timer.overwriteDurationInMillis(t,e)}function o(t,e){this.timer.setDurationInMillis(t,e)}function s(t){this._exclusiveDuration=t}function i(){if(this._exclusiveDuration)return this._exclusiveDuration;var t=this.getDuration(),e=this.timer.toRange()[1];return this.children.length>0&&(t-=u(this._getChildPairs(e),e)),t}var a=require("util"),c=cachedModules[4963].exports,u=cachedModules[5287].exports,l=cachedModules[3751].exports,p={EXTERNAL:"EXTERNAL",CALLBACK:"CALLBACK"},h=900;r.prototype.moveToCallbackState=function(){this.state=p.CALLBACK},r.prototype.isInCallbackState=function(){return this.state===p.CALLBACK},r.prototype.markAsWeb=function(t){var e=this.transaction;this.name=e.name,this.partialName=e.partialName;var r=e.agent.config,n=a._extend({},this.parameters);delete n.atatus_exclusive_duration_millis,c.copyParameters(r,c.parseParameters(t),n),c.copyParameters(r,n,this.parameters),c.copyParameters(r,n,this.transaction.trace.parameters)},r.prototype.touch=function(){this.timer.touch(),this._updateRootTimer()},r.prototype.overwriteDurationInMillis=n,r.prototype.start=function(){this.timer.begin()},r.prototype.end=function(){this.timer.isActive()&&(this.timer.end(),this._updateRootTimer())},r.prototype._updateRootTimer=function(){var t=this.transaction.trace.root;if(this.timer.endsAfter(t.timer)){var e=this.timer.start+this.getDuration()-t.timer.start;t.overwriteDurationInMillis(e)}},r.prototype._isEnded=function(){return!this.timer.isActive()||this.timer.touched},r.prototype.add=function(t,e){var n=new r(this.transaction,t,e);this.transaction.agent.config;return this.transaction.trace.segmentsSeen++>=h&&(n._collect=!1),this.children.push(n),n},r.prototype.setDurationInMillis=o,r.prototype.getDuration=function(){return this.timer.getDuration()},r.prototype._setExclusiveDurationInMillis=s,r.prototype.getExclusiveDuration=i,r.prototype.getChildren=function(){for(var t=[],e=0,r=this.children.length;r>e;++e)this.children[e].ignore||t.push(this.children[e]);return t},r.prototype._getChildPairs=function(t){if(this.children.length<1)return[];t||(t=1/0);for(var e=this.getChildren(),r=[];e.length;){var n=e.pop(),o=n.timer.toRange();o[0]>=t||(e=e.concat(n.getChildren()),o[1]=Math.min(o[1],t),r.push(o))}return r},r.prototype.toJSON=function(){var t=this.timer.startedRelativeTo(this.transaction.trace.root.timer),e=this.getDuration();this.parameters.atatus_exclusive_duration_millis||(this.parameters.atatus_exclusive_duration_millis=this.getExclusiveDuration());for(var r=this.getChildren(),n=[],o=0,s=r.length;s>o;o++){var i=r[o];i._collect&&n.push(i.toJSON())}return[t,t+e,this.name,this.parameters,n]},t.exports=r}.call(this,cachedModules[7410],cachedModules[7410].exports),cachedModules[6407]={exports:{}},function(t,e){"use strict";function r(t){if(!t)throw new Error("All traces must be associated with a transaction.");this.transaction=t,this.root=new i(t,"ROOT"),this.root.start(),this.custom={},this.intrinsics={},this.segmentsSeen=0,this.totalTimeCache=null, this.parameters={},this.domain=null}function n(t,e){this.root.setDurationInMillis(t,e)}var o=cachedModules[3763].exports,s=cachedModules[4007].exports,i=cachedModules[7410].exports;r.prototype.end=function(){for(var t=[this.root];t.length;){var e=t.pop();e.timer.softEnd()&&e._updateRootTimer(),t=t.concat(e.getChildren())}},r.prototype.add=function(t,e){return this.root.add(t,e)},r.prototype.setDurationInMillis=n,r.prototype.getDuration=function(){return this.root.getDuration()},r.prototype.addParameter=function(t,e){this.parameters[t]=e},r.prototype.getExclusiveDuration=function(){return this.root.getExclusiveDuration()},r.prototype.getTotalTimeDuration=function(){if(null!==this.totalTimeCache)return this.totalTimeCache;if(0===this.root.children.length)return 0;for(var t=this.root.getChildren(),e=0;0!==t.length;){var r=t.pop();e+=r.getExclusiveDuration(),t=t.concat(r.getChildren())}return this.transaction.isActive()||(this.totalTimeCache=e),e},r.prototype.generateJSON=function(t){function e(e,r){if(e)return t(e,null,null);var n=null;i.transaction.syntheticsData&&(n=i.transaction.syntheticsData.resourceId);var o=[i.root.timer.start,i.transaction.getResponseTime(),i.transaction.name,i.transaction.url,r,"",null,!1,null,n];return t(null,o,i)}var r={agentAttributes:s.shallow(this.parameters),userAttributes:this.custom,intrinsics:this.intrinsics};delete r.agentAttributes.path;var n=[this.root.timer.start,{},{atatus_flatten_leading:!1},this.root.toJSON(),r,[]],i=this;this.transaction.agent.config.simpleCompression?process.nextTick(e.bind(null,null,n)):o.encode(n,e)},t.exports=r}.call(this,cachedModules[6407],cachedModules[6407].exports),cachedModules[5945]={exports:{}},function(t,e){"use strict";function r(t){if(!t)throw new Error("every transaction must be bound to the agent");this.agent=t,this.metrics=new i(t.config.apdexT,t.mapper,t.metricNameRuler),this.id=Math.floor(1e17*Math.random()).toString(16),this.trace=new c(this),this.exceptions=[],this.userErrors=[],this.timer=new a,this.timer.begin(),this._recorders=[],this._intrinsicAttributes={},this.bgSegment=null,this.catResponseTime=0,this.error=null,this.forceIgnore=null,this.forceName=null,this.ignore=!1,this.incomingCatId=null,this.name=null,this.partialName=null,this.pathHashes=[],this.queueTime=0,this.referringPathHash=null,this.referringTransactionGuid=null,this.invalidIncomingExternalTransaction=!1,this.statusCode=null,this.syntheticsHeader=null,this.syntheticsData=null,this.url=null,this.parsedUrl=null,this.verb=null,this.webSegment=null}function n(t,e,r){this.exceptions.push([t,e,r])}function o(t,e,r){this.userErrors.push([t,e,r])}var s=cachedModules[4963].exports,i=cachedModules[8280].exports,a=cachedModules[3751].exports,c=cachedModules[6407].exports,u=(cachedModules[6487].exports,require("util")),l=require("url"),p="Web",h="URL",d="Custom",f="CanonicaliedURL",g=" - ";r.prototype.isWeb=function(){return!!this.url},r.prototype.isActive=function(){return this.timer.isActive()},r.prototype.end=function(t){if(this.timer.isActive()){var e=this;e.trace.end(),process.nextTick(function(){e.ignore||e.record(),e.agent.emit("transactionFinished",e),"function"==typeof t&&t(e)}),e.timer.end()}},r.prototype.getResponseTime=function(){return this.isWeb()?this.timer.getDuration():this.trace.getDuration()},r.prototype.applyUserNamingRules=function(t){var e=this.agent.customRuler;e.isIgnored(t)&&(this.ignore=!0),e.canNormalize(t)&&(this.partialName=f+e.normalize(t))},r.prototype.setPartialName=function(t){this.partialName=t},r.prototype.setName=function(t,e){var r;this.url=s.scrub(t),this.statusCode=e,null!==this.forceName&&(this.partialName=this.forceName),this.applyUserNamingRules(this.url),r=this.agent.urlRuler,r.isIgnored(this.url)&&(this.ignore=!0),this.partialName||(this.partialName=h+g+r.normalize(this.url)),r=this.agent.txnNameRuler;var n=p+g+this.partialName;r.isIgnored(n)&&(this.ignore=!0),this.name=r.normalize(n),this.name=this.agent.layerNameRuler.normalize(this.name),null!==this.forceIgnore&&(this.ignore=this.forceIgnore)},r.prototype.setBackgroundName=function(t,e){this.partialName=e+g+t;var r=d+g+this.partialName,n=this.agent.txnNameRuler;n.isIgnored(r)&&(this.ignore=!0),this.name=n.normalize(r),null!==this.forceIgnore&&(this.ignore=this.forceIgnore)},r.prototype.getName=function(){if(this.isWeb()&&!this.name){var t=this.partialName;this.setName(this.url,this.statusCode),this.partialName=t}return this.name},r.prototype.getScrubbedUrl=function(){if(this.isWeb()){if(this._scrubbedUrl)return this._scrubbedUrl;if(!this.parsedUrl){if(!this.url)return;this.parsedUrl=l.parse(this.url)}var t=u._extend({},this.parsedUrl);return t.search=null,t.query=null,t.href=null,t.path=null,t.hash=null,this._scrubbedUrl=l.format(t),this._scrubbedUrl}},r.prototype.addRecorder=function(t){this._recorders.push(t)},r.prototype.record=function(){for(var t=this.name,e=0,r=this._recorders.length;r>e;++e)this._recorders[e](t)},r.prototype.measure=function(t,e,r,n){this.metrics.measureDuration(t,e,r,n)},r.prototype._setApdex=function(t,e,r){var n=this.metrics.getApdexStat(t,null,r);s.isError(this.agent.config,this.statusCode)?n.incrementFrustrating():n.storeDuration(e)},r.prototype.pushPathHash=function(t){this.pathHashes.length>=10||-1!==this.pathHashes.indexOf(t)||this.pathHashes.unshift(t)},r.prototype.includesOutboundRequests=function(){return this.pathHashes.length>0},r.prototype.cleanup=function(){this.trace&&this.trace.cleanup()},r.prototype.addException=n,r.prototype.addUserError=o,r.prototype.hasErrors=function(){var t=s.isError(this.agent.config,this.statusCode),e=this.exceptions.length>0,r=this.userErrors.length>0;return e||r||t},r.prototype.addAgentAttribute=function(t,e){-1===this.agent.config.ignoredParams.indexOf(t)&&this.trace.addParameter(t,e)},r.prototype.getIntrinsicAttributes=function(){if(!this._intrinsicAttributes.totalTime){this.agent.config;this._intrinsicAttributes.totalTime=this.trace.getTotalTimeDuration()}return u._extend({},this._intrinsicAttributes)},t.exports=r}.call(this,cachedModules[5945],cachedModules[5945].exports),cachedModules[5764]={exports:{}},function(t,e){"use strict";function r(t){if(!t)throw new Error("Must be initialized with an agent.");this.agent=t,this.segment=null}function n(){return this.segment&&this.segment.transaction&&this.segment.transaction.isActive()?this.segment.transaction:null}function o(){return this.segment}function s(t,e,r){var n=r||this.segment;return n&&n.transaction.isActive()?n.add(t,e):null}function i(t,e,r,n,o){if("function"!=typeof o)throw new Error("task must be a function");var s=this.createSegment(t,e,r);return this.bindFunction(o,s,n)(s)}function a(t){if("function"!=typeof t)return t;var e=this,r=function(){if(e.getTransaction())return t.apply(this,arguments);var r=new _(e.agent);return e.bindFunction(t,r.trace.root).apply(this,arguments)};return r[w]=t,r}function c(t,e){if(void 0===e&&"function"==typeof t&&(e=t,t=void 0),"function"!=typeof e)return e;var r=this,n=function(){var n=r.getTransaction(),o=r.segment,s=!1;return n?"web"===t&&n.bgSegment?s=!0:"custom"===t&&n.webSegment&&(s=!0):s=!0,s&&(n=new _(r.agent),o=n.trace.root),r.bindFunction(e,o).apply(this,arguments)};return n[w]=e,n}function u(t,e,r){function n(){var n=o.segment;o.segment=s,s&&r&&e.start();try{var i=t.apply(this,arguments)}catch(a){throw a}finally{s&&r&&e.touch(),o.segment=n}return i}if("function"!=typeof t)return t;var o=this,s="undefined"==typeof e?o.segment:e;return n[w]=t[w]||t,n[b]=s,n}function l(t){return t&&t[w]?t[w]:t}function p(t){return t&&t[b]?t[b]:null}function h(t,e){function r(){return n.bindFunction(s,o).apply(this,arguments)}if(!t||!t.emit)return t;var n=this,o=e||this.segment,s=t.emit[w]||t.emit;return t.emit=r,t.emit[w]=s,t}function d(t){for(var e=t.length,r=new Array(e),n=0;e>n;n++)r[n]=t[n];return r}function f(t,e,r){function n(){if(!o.getTransaction())return t.apply(this,arguments);var e=o.slice(arguments);if(void 0===r){var n=e.length-1,s=e[n];"function"==typeof s&&(e[n]=o.bindFunction(s))}else e=r(e);return t.apply(this,e)}if("function"!=typeof t)return t;var o=this;return n}function g(t,e){function r(){if(!n.getTransaction())return t.apply(this,arguments);var e=n.slice(arguments),r=e[0];return"function"==typeof r&&(e[0]=n.bindFunction(r)),t.apply(this,e)}if("function"!=typeof t)return t;var n=this;return r}function m(t,e,r){function n(){function n(){return u.touch(),c.apply(this,arguments)}var s=o.getTransaction();if(!s)return r.apply(this,arguments);var i=o.slice(arguments),a=i.length-1,c=i[a];if("function"!=typeof c)return r.apply(this,arguments);var u=o.createSegment(t,e);return i[a]=o.wrapCallback(c,u,n),u.start(),o.bindFunction(r,u).apply(this,i)}if("function"!=typeof r)return r;var o=this;return n}function y(t,e,r){function n(){function n(){c.touch();var t=a.apply(this,arguments);return t}var s=o.getTransaction();if(!s)return r.apply(this,arguments);var i=o.slice(arguments),a=i[0];if("function"!=typeof a)return r.apply(this,arguments);var c=o.createSegment(t,e);return i[0]=o.wrapCallback(a,c,n),c.start(),o.bindFunction(r,c).apply(this,i)}if("function"!=typeof r)return r;var o=this;return n}function v(t,e,r,n,o){function s(){function s(t){return t?i.wrapCallback(t,c,function(){return c.touch(),t.apply(this,arguments)}):t}var a=i.getTransaction();if(!a)return r.apply(this,arguments);var c=i.createSegment(t,e),u=n.call(this,c,i.slice(arguments),s);c.start();var l=i.bindFunction(r,c).apply(this,u);return o&&(l=o.call(this,c,l,s)),l}if("function"!=typeof r||!n)return r;var i=this;return s}function x(t,e,r){function n(){var n=o.getTransaction();if(!n)return r.apply(this,arguments);var s=o.createSegment(t,e);return s&&(s.async=!1),o.bindFunction(r,s,!0).apply(this,arguments)}if("function"!=typeof r)return r;var o=this;return n}function M(t,e,r){var n=this;return"function"!=typeof t?t:n.bindFunction(function(){r&&(r[w]=t);var o=n.createSegment("Callback: "+(t.name||"anonymous"),null,e);return o&&(o.async=!1),n.bindFunction(r||t,o,!0).apply(this,arguments)},e,!1)}var _=cachedModules[5945].exports,w=(cachedModules[1113].exports,"__atatusOriginal__"),b="__atatusSegment__";t.exports=r,r.prototype.getTransaction=n,r.prototype.getSegment=o,r.prototype.createSegment=s,r.prototype.addSegment=i,r.prototype.transactionProxy=a,r.prototype.transactionNestProxy=c,r.prototype.bindFunction=u,r.prototype.bindEmitter=h,r.prototype.getOriginal=l,r.prototype.getSegmentFromWrapped=p,r.prototype.slice=d,r.prototype.wrapFunctionNoSegment=f,r.prototype.wrapFunctionFirstNoSegment=g,r.prototype.wrapFunction=v,r.prototype.wrapFunctionLast=m,r.prototype.wrapFunctionFirst=y,r.prototype.wrapSyncFunction=x,r.prototype.wrapCallback=M}.call(this,cachedModules[5764],cachedModules[5764].exports),cachedModules[6641]={exports:{}},function(t,e){"use strict";function r(t){o.call(this),this.config=t,this.events=new s(1e4),this.environment=cachedModules[6703].exports,this.version=this.config.agentVersion,this.transporter=new a(this),this.errors=new c(this.config),this.mapper=new h,this.metricNameRuler=new l(this.config,"metric name"),this.metrics=new u(this.config.apdexT,this.mapper,this.metricNameRuler),this.txnNameRuler=new l(this.config,"transaction name"),this.urlRuler=new l(this.config,"URL"),this.layerNameRuler=new p,this.customRuler=new l(this.config,"custom"),this.customRuler.loadFromConfig(),this.tracer=this._setupTracer(),this.lifeCycleThread=null,this.on("transactionFinished",this._transactionFinished.bind(this))}var n=require("util"),o=require("events").EventEmitter,s=cachedModules[4515].exports,i=cachedModules[1113].exports,a=cachedModules[4853].exports,c=cachedModules[3120].exports,u=cachedModules[8280].exports,l=cachedModules[6234].exports,p=cachedModules[7127].exports,h=cachedModules[9721].exports,d=(cachedModules[6487].exports,cachedModules[5283].exports),f=1e3;d.check(),n.inherits(r,o),r.prototype.reconfigure=function(t){if(!t)throw new TypeError("must pass configuration")},r.prototype.start=function(t){if(!t)throw new TypeError("callback required!");var e=this;this.transporter.sendHostInfo(function(r,n){return r?t(r,n):void setTimeout(function(){e.harvest(function(r){e._startHarvester(e.config.notifyInterval),t(r,n)})},2e3)})},r.prototype.stop=function(t){if(!t)throw new TypeError("callback required!");this._stopHarvester(),process.nextTick(t)},r.prototype.harvest=function(t){function e(o){function s(r){return r||o>=n.length?t(r):void e(o)}r[n[o++]](s)}if(!t)throw new TypeError("callback required!");var r=this,n=["_sendMetrics","_sendErrors","_sendErrorMetrics","_sendHostInfo"];e(0)},r.prototype._restartHarvester=function(t){this._stopHarvester(),this._startHarvester(t)},r.prototype._stopHarvester=function(){this.lifeCycleThread&&clearInterval(this.lifeCycleThread),this.lifeCycleThread=void 0},r.prototype._startHarvester=function(t){function e(t){t&&i.info(t,"Unable to send metrics to Atatus server. Metrics are cached and will be send in next cycle:")}function r(){n.harvest(e)}var n=this;this.lifeCycleThread=setInterval(r,t*f),this.lifeCycleThread.unref&&this.lifeCycleThread.unref()},r.prototype._setupTracer=function(){var t=cachedModules[5764].exports;return new t(this)},r.prototype._sendMetrics=function(t){var e=this;if(this.metrics.toJSON().length<1)return process.nextTick(t);var r=this.metrics,n=r.startTime,o=Date.now(),s={startTime:n,endTime:o,transactions:r};this.metrics=new u(this.config.apdexT,this.mapper,this.metricNameRuler),this.transporter.send("metrics",s,function(n,o){n&&e.metrics.merge(r),o&&e.mapper.load(o),t(n)})},r.prototype._sendErrors=function(t){var e=this;if(this._processErrorMetrics(),this.config.collectErrors){if(this.errors.getTotalErrorCount()<1)return process.nextTick(t);var r=this.errors.getErrors(),n={customData:e.config.customData,errors:r};this.errors.clearErrors(),this.transporter.send("errors",n,function(n){n&&e.errors.merge(r),t(n)})}else this.errors.clearErrors(),process.nextTick(t)},r.prototype._processErrorMetrics=function(){var t=this.errors.getMetrics(),e=this.errors.getTotalMetricCount();return 0===e?void(this._lastErrorMetrics=null):void(this.config.collectErrors?(this._lastErrorMetrics=t,this.errors.clearMetrics()):e>0&&(this._lastErrorMetrics=null,this.errors.clearMetrics()))},r.prototype._sendErrorMetrics=function(t){if(this.config.collectErrors&&this._lastErrorMetrics){var e=this,r=this._lastErrorMetrics,n={startTime:r.startTime,endTime:Date.now(),errorMetrics:r};e.transporter.send("error_metrics",n,function(n){n&&413===n.statusCode||n&&e.errors.mergeMetrics(r),t(n)})}else process.nextTick(t)},r.prototype._sendHostInfo=function(t){var e=(new Date).getMinutes();if(0===e||30===e){var r=this;r.transporter.sendHostInfo(function(t){}),process.nextTick(t)}else process.nextTick(t)},r.prototype._transactionFinished=function(t){if(t.describer,t.ignore)t.forceIgnore===!0;else{t.forceIgnore===!1,this.metrics.merge(t.metrics),this.errors.onTransactionCompleted(t,this.metrics);var e=t.trace;e.intrinsics=t.getIntrinsicAttributes()}},r.prototype.getTransaction=function(){return this.tracer.getTransaction()},t.exports=r}.call(this,cachedModules[6641],cachedModules[6641].exports),cachedModules[6065]={exports:{}},function(t,e){"use strict";function r(t,e){return n.EventEmitter.listenerCount?n.EventEmitter.listenerCount(t,e):t.listeners(e).length}var n=require("events"),o=require("util");t.exports=function(t,e,n,s){function i(t){function e(r){function n(t,e){function r(e){return i.__atatusWrapper__?t(e):(i.__atatusWrapper__=l.bindFunction(a,c,!0),t(e))}function n(t){return i.__atatusSegment__=c,i.__atatusWrapper__?e(t):(i.__atatusWrapper__=l.bindFunction(a,c,!0),e(t))}var c=l.segment;o=this,s=[r,n]}if(!(this instanceof e))return t(r);if("function"!=typeof r)return new t(r);var o,s,i=new t(n);try{r.apply(o,s)}catch(c){s[1](c)}return i.__proto__=e.prototype,i}u(t.prototype,"Promise.prototype",["then","chain"],c);var r=["accept","all","defer","race","reject","resolve"];return r.forEach(function(r){e[r]=t[r]}),o.inherits(e,t),e}function a(t,e,r,n){try{var o=e.call(t,n)}finally{o instanceof Promise?r.__atatusWrapper__=function(){return(o.__atatusWrapper__||a).apply(this,arguments)}:r.__atatusWrapper__=l.bindFunction(a)}return o}function c(t){return function(){function e(t){return"function"!=typeof t?t:function(e){return r.__atatusWrapper__?r.__atatusWrapper__(this,t,n,e):t.call(this,e)}}var r=this,n=t.apply(this,[].map.call(arguments,e));return n}}var u=s.wrapMethod,l=t.tracer;process._fatalException?u(process,"process","_fatalException",function(e){return function(r){return t.errors.add(null,r),t.tracer.segment=null,e.apply(this,arguments)}}):process.on("uncaughtException",function(e){if(t.errors.add(null,e),t.tracer.segment=null,r(process,"uncaughtException")<2)throw e}),process.on("unhandledRejection",function(e,n){if(r(process,"unhandledRejection")<2){var o=n.__atatusSegment__&&n.__atatusSegment__.transaction;t.errors.add(o,e)}}),u(global,"global","Promise",i)}}.call(this,cachedModules[6065],cachedModules[6065].exports),cachedModules[6807]={exports:{}},function(module,exports){"use strict";function mangle(t){var e=t.split(" ");return t=e[e.length-1],-1!==RESERVED.indexOf(t)?t+"_":t}var logger=cachedModules[1113].exports,ORIGINAL="__atatusOriginal__",RESERVED=["class","enum","extends","super","const","export","import","implements","let","private","public","yield","interface","package","protected","static"];module.exports=function attach(agent,connect,moduleName,shimmer){function wrapHandle(__atatusHandler__){var arglist,name="";switch(__atatusHandler__.length){case 2:arglist="(req, res)";break;case 3:arglist="(req, res, next)";break;case 4:arglist="(err, req, res, next)";break;default:arglist="()"}__atatusHandler__.name&&(name=mangle(__atatusHandler__.name));var template=function(){var t=tracer.slice(arguments),e=t.length-1;"function"==typeof t[e]&&(t[e]=tracer.bindFunction(t[e])),__atatusHandler__.apply(this,t)},wrapped=eval("(function(){return