applicationinsights
Advanced tools
Comparing version 0.15.6 to 0.15.7
@@ -129,2 +129,21 @@ var AutoCollectConsole = require("./AutoCollection/Console"); | ||
}; | ||
/** | ||
* Disposes the default client and all the auto collectors so they can be reinitialized with different configuration | ||
*/ | ||
ApplicationInsights.dispose = function () { | ||
ApplicationInsights.client = null; | ||
ApplicationInsights._isStarted = false; | ||
if (ApplicationInsights._console) { | ||
ApplicationInsights._console.dispose(); | ||
} | ||
if (ApplicationInsights._exceptions) { | ||
ApplicationInsights._exceptions.dispose(); | ||
} | ||
if (ApplicationInsights._performance) { | ||
ApplicationInsights._performance.dispose(); | ||
} | ||
if (ApplicationInsights._requests) { | ||
ApplicationInsights._requests.dispose(); | ||
} | ||
}; | ||
ApplicationInsights._isConsole = true; | ||
@@ -131,0 +150,0 @@ ApplicationInsights._isExceptions = true; |
@@ -15,2 +15,5 @@ var AutoCollectConsole = (function () { | ||
}; | ||
AutoCollectConsole.prototype.dispose = function () { | ||
AutoCollectConsole.INSTANCE = null; | ||
}; | ||
AutoCollectConsole._methodNames = ["debug", "info", "log", "warn", "error"]; | ||
@@ -17,0 +20,0 @@ return AutoCollectConsole; |
@@ -108,2 +108,6 @@ ///<reference path="..\Declarations\node\node.d.ts" /> | ||
}; | ||
AutoCollectExceptions.prototype.dispose = function () { | ||
AutoCollectExceptions.INSTANCE = null; | ||
this._isInitialized = false; | ||
}; | ||
AutoCollectExceptions.INSTANCE = null; | ||
@@ -110,0 +114,0 @@ return AutoCollectExceptions; |
@@ -144,3 +144,3 @@ ///<reference path="..\Declarations\node\node.d.ts" /> | ||
var lastCpu = this._lastCpus[i]; | ||
var name = "% cpu[" + i + "] "; | ||
var name = "% cpu(" + i + ") "; | ||
var model = cpu.model; | ||
@@ -222,2 +222,6 @@ var speed = cpu.speed; | ||
}; | ||
AutoCollectPerformance.prototype.dispose = function () { | ||
AutoCollectPerformance.INSTANCE = null; | ||
this._isInitialized = false; | ||
}; | ||
AutoCollectPerformance._totalRequestCount = 0; | ||
@@ -224,0 +228,0 @@ AutoCollectPerformance._totalFailedRequestCount = 0; |
///<reference path="..\Declarations\node\node.d.ts" /> | ||
var http = require("http"); | ||
var https = require("https"); | ||
var Logging = require("../Library/Logging"); | ||
@@ -25,6 +26,6 @@ var RequestDataHelper = require("./RequestDataHelper"); | ||
this._isInitialized = true; | ||
var originalServer = http.createServer; | ||
var originalHttpServer = http.createServer; | ||
http.createServer = function (onRequest) { | ||
// todo: get a pointer to the server so the IP address can be read from server.address | ||
return originalServer(function (request, response) { | ||
return originalHttpServer(function (request, response) { | ||
if (_this._isEnabled) { | ||
@@ -38,2 +39,13 @@ AutoCollectRequests.trackRequest(_this._client, request, response); | ||
}; | ||
var originalHttpsServer = https.createServer; | ||
https.createServer = function (options, onRequest) { | ||
return originalHttpsServer(options, function (request, response) { | ||
if (_this._isEnabled) { | ||
AutoCollectRequests.trackRequest(_this._client, request, response); | ||
} | ||
if (typeof onRequest === "function") { | ||
onRequest(request, response); | ||
} | ||
}); | ||
}; | ||
}; | ||
@@ -71,3 +83,3 @@ /** | ||
if (typeof error === "string") { | ||
properties["erorr"] = error; | ||
properties["error"] = error; | ||
} | ||
@@ -84,4 +96,8 @@ else if (typeof error === "object") { | ||
}; | ||
AutoCollectRequests.prototype.dispose = function () { | ||
AutoCollectRequests.INSTANCE = null; | ||
this._isInitialized = false; | ||
}; | ||
return AutoCollectRequests; | ||
})(); | ||
module.exports = AutoCollectRequests; |
@@ -104,2 +104,22 @@ ///<reference path="..\Declarations\node\node.d.ts" /> | ||
}; | ||
Client.prototype.trackDependency = function (name, commandName, elapsedTimeMs, success, dependencyTypeName, properties, dependencyKind, async, dependencySource) { | ||
if (properties === void 0) { properties = {}; } | ||
if (dependencyKind === void 0) { dependencyKind = ContractsModule.Contracts.DependencyKind.Other; } | ||
if (async === void 0) { async = false; } | ||
if (dependencySource === void 0) { dependencySource = ContractsModule.Contracts.DependencySourceType.Undefined; } | ||
var remoteDependency = new ContractsModule.Contracts.RemoteDependencyData(); | ||
remoteDependency.name = name; | ||
remoteDependency.commandName = commandName; | ||
remoteDependency.value = elapsedTimeMs; | ||
remoteDependency.success = success; | ||
remoteDependency.dependencyTypeName = dependencyTypeName; | ||
remoteDependency.properties = properties; | ||
remoteDependency.dependencyKind = dependencyKind; | ||
remoteDependency.async = async; | ||
remoteDependency.dependencySource = dependencySource; | ||
var data = new ContractsModule.Contracts.Data(); | ||
data.baseType = "RemoteDependencyData"; | ||
data.baseData = remoteDependency; | ||
this.track(data); | ||
}; | ||
/** | ||
@@ -106,0 +126,0 @@ * Immediately send all queued telemetry. |
@@ -5,3 +5,3 @@ { | ||
"bugs": "https://github.com/Microsoft/ApplicationInsights-node.js/issues", | ||
"version": "0.15.6", | ||
"version": "0.15.7", | ||
"description": "Microsoft Application Insights module for Node.JS", | ||
@@ -8,0 +8,0 @@ "repository": { |
@@ -77,2 +77,18 @@ # Application Insights for Node.js | ||
#####Example with tracking dependency##### | ||
```javascript | ||
import appInsights = require("applicationinsights"); | ||
var client = appInsights.getClient(); | ||
var startTime = Date.now(); | ||
// execute dependency call | ||
var endTime = Date.now(); | ||
var elapsedTime = endTime - startTime; | ||
var success = true; | ||
client.trackDependency("dependency name", "command name", elapsedTime, success); | ||
``` | ||
#####Example with manual request tracking of all "GET" requests##### | ||
@@ -79,0 +95,0 @@ ```javascript |
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
81377
1703
151
5