applicationinsights
Advanced tools
Comparing version 2.3.4 to 2.3.5
@@ -9,6 +9,18 @@ export declare class NetworkStatsbeat { | ||
totalSuccesfulRequestCount: number; | ||
totalFailedRequestCount: number; | ||
retryCount: number; | ||
exceptionCount: number; | ||
throttleCount: number; | ||
totalFailedRequestCount: { | ||
statusCode: number; | ||
count: number; | ||
}[]; | ||
retryCount: { | ||
statusCode: number; | ||
count: number; | ||
}[]; | ||
exceptionCount: { | ||
exceptionType: string; | ||
count: number; | ||
}[]; | ||
throttleCount: { | ||
statusCode: number; | ||
count: number; | ||
}[]; | ||
intervalRequestExecutionTime: number; | ||
@@ -15,0 +27,0 @@ lastIntervalRequestExecutionTime: number; |
@@ -10,6 +10,6 @@ "use strict"; | ||
this.totalSuccesfulRequestCount = 0; | ||
this.totalFailedRequestCount = 0; | ||
this.retryCount = 0; | ||
this.exceptionCount = 0; | ||
this.throttleCount = 0; | ||
this.totalFailedRequestCount = []; | ||
this.retryCount = []; | ||
this.exceptionCount = []; | ||
this.throttleCount = []; | ||
this.intervalRequestExecutionTime = 0; | ||
@@ -16,0 +16,0 @@ this.lastIntervalRequestExecutionTime = 0; |
@@ -40,6 +40,6 @@ import Constants = require("../Declarations/Constants"); | ||
removeInstrumentation(instrumentation: Constants.StatsbeatInstrumentation): void; | ||
countRequest(endpoint: number, host: string, duration: number, success: boolean): void; | ||
countException(endpoint: number, host: string): void; | ||
countThrottle(endpoint: number, host: string): void; | ||
countRetry(endpoint: number, host: string): void; | ||
countRequest(endpoint: number, host: string, duration: number, success: boolean, statusCode?: number): void; | ||
countException(endpoint: number, host: string, exceptionType: Error): void; | ||
countThrottle(endpoint: number, host: string, statusCode: number): void; | ||
countRetry(endpoint: number, host: string, statusCode: number): void; | ||
trackShortIntervalStatsbeats(): Promise<void>; | ||
@@ -46,0 +46,0 @@ trackLongIntervalStatsbeats(): Promise<void>; |
"use strict"; | ||
var __assign = (this && this.__assign) || function () { | ||
__assign = Object.assign || function(t) { | ||
for (var s, i = 1, n = arguments.length; i < n; i++) { | ||
s = arguments[i]; | ||
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) | ||
t[p] = s[p]; | ||
} | ||
return t; | ||
}; | ||
return __assign.apply(this, arguments); | ||
}; | ||
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { | ||
@@ -120,3 +131,3 @@ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } | ||
}; | ||
Statsbeat.prototype.countRequest = function (endpoint, host, duration, success) { | ||
Statsbeat.prototype.countRequest = function (endpoint, host, duration, success, statusCode) { | ||
if (!this.isEnabled()) { | ||
@@ -129,3 +140,12 @@ return; | ||
if (success === false) { | ||
counter.totalFailedRequestCount++; | ||
if (!statusCode) { | ||
return; | ||
} | ||
var currentStatusCounter = counter.totalFailedRequestCount.find(function (statusCounter) { return statusCode === statusCounter.statusCode; }); | ||
if (currentStatusCounter) { | ||
currentStatusCounter.count++; | ||
} | ||
else { | ||
counter.totalFailedRequestCount.push({ statusCode: statusCode, count: 1 }); | ||
} | ||
} | ||
@@ -136,3 +156,3 @@ else { | ||
}; | ||
Statsbeat.prototype.countException = function (endpoint, host) { | ||
Statsbeat.prototype.countException = function (endpoint, host, exceptionType) { | ||
if (!this.isEnabled()) { | ||
@@ -142,5 +162,11 @@ return; | ||
var counter = this._getNetworkStatsbeatCounter(endpoint, host); | ||
counter.exceptionCount++; | ||
var currentErrorCounter = counter.exceptionCount.find(function (exceptionCounter) { return exceptionType.name === exceptionCounter.exceptionType; }); | ||
if (currentErrorCounter) { | ||
currentErrorCounter.count++; | ||
} | ||
else { | ||
counter.exceptionCount.push({ exceptionType: exceptionType.name, count: 1 }); | ||
} | ||
}; | ||
Statsbeat.prototype.countThrottle = function (endpoint, host) { | ||
Statsbeat.prototype.countThrottle = function (endpoint, host, statusCode) { | ||
if (!this.isEnabled()) { | ||
@@ -150,5 +176,11 @@ return; | ||
var counter = this._getNetworkStatsbeatCounter(endpoint, host); | ||
counter.throttleCount++; | ||
var currentStatusCounter = counter.throttleCount.find(function (statusCounter) { return statusCode === statusCounter.statusCode; }); | ||
if (currentStatusCounter) { | ||
currentStatusCounter.count++; | ||
} | ||
else { | ||
counter.throttleCount.push({ statusCode: statusCode, count: 1 }); | ||
} | ||
}; | ||
Statsbeat.prototype.countRetry = function (endpoint, host) { | ||
Statsbeat.prototype.countRetry = function (endpoint, host, statusCode) { | ||
if (!this.isEnabled()) { | ||
@@ -158,3 +190,9 @@ return; | ||
var counter = this._getNetworkStatsbeatCounter(endpoint, host); | ||
counter.retryCount++; | ||
var currentStatusCounter = counter.retryCount.find(function (statusCounter) { return statusCode === statusCounter.statusCode; }); | ||
if (currentStatusCounter) { | ||
currentStatusCounter.count++; | ||
} | ||
else { | ||
counter.retryCount.push({ statusCode: statusCode, count: 1 }); | ||
} | ||
}; | ||
@@ -263,4 +301,11 @@ Statsbeat.prototype.trackShortIntervalStatsbeats = function () { | ||
// Add extra properties | ||
var properties = Object.assign({ "endpoint": this._networkStatsbeatCollection[i].endpoint, "host": this._networkStatsbeatCollection[i].host }, commonProperties); | ||
this._statbeatMetrics.push({ name: Constants.StatsbeatCounter.REQUEST_DURATION, value: averageRequestExecutionTime, properties: properties }); | ||
var properties = Object.assign({ | ||
"endpoint": this._networkStatsbeatCollection[i].endpoint, | ||
"host": this._networkStatsbeatCollection[i].host | ||
}, commonProperties); | ||
this._statbeatMetrics.push({ | ||
name: Constants.StatsbeatCounter.REQUEST_DURATION, | ||
value: averageRequestExecutionTime, | ||
properties: properties | ||
}); | ||
} | ||
@@ -287,25 +332,62 @@ // Set last counters | ||
Statsbeat.prototype._trackRequestsCount = function (commonProperties) { | ||
for (var i = 0; i < this._networkStatsbeatCollection.length; i++) { | ||
var currentCounter = this._networkStatsbeatCollection[i]; | ||
var _this = this; | ||
var _loop_1 = function (i) { | ||
currentCounter = this_1._networkStatsbeatCollection[i]; | ||
var properties = Object.assign({ "endpoint": currentCounter.endpoint, "host": currentCounter.host }, commonProperties); | ||
if (currentCounter.totalSuccesfulRequestCount > 0) { | ||
this._statbeatMetrics.push({ name: Constants.StatsbeatCounter.REQUEST_SUCCESS, value: currentCounter.totalSuccesfulRequestCount, properties: properties }); | ||
this_1._statbeatMetrics.push({ | ||
name: Constants.StatsbeatCounter.REQUEST_SUCCESS, | ||
value: currentCounter.totalSuccesfulRequestCount, | ||
properties: properties | ||
}); | ||
currentCounter.totalSuccesfulRequestCount = 0; //Reset | ||
} | ||
if (currentCounter.totalFailedRequestCount > 0) { | ||
this._statbeatMetrics.push({ name: Constants.StatsbeatCounter.REQUEST_FAILURE, value: currentCounter.totalFailedRequestCount, properties: properties }); | ||
currentCounter.totalFailedRequestCount = 0; //Reset | ||
if (currentCounter.totalFailedRequestCount.length > 0) { | ||
currentCounter.totalFailedRequestCount.forEach(function (currentCounter) { | ||
properties = Object.assign(__assign(__assign({}, properties), { "statusCode": currentCounter.statusCode })); | ||
_this._statbeatMetrics.push({ | ||
name: Constants.StatsbeatCounter.REQUEST_FAILURE, | ||
value: currentCounter.count, | ||
properties: properties | ||
}); | ||
}); | ||
currentCounter.totalFailedRequestCount = []; //Reset | ||
} | ||
if (currentCounter.retryCount > 0) { | ||
this._statbeatMetrics.push({ name: Constants.StatsbeatCounter.RETRY_COUNT, value: currentCounter.retryCount, properties: properties }); | ||
currentCounter.retryCount = 0; //Reset | ||
if (currentCounter.retryCount.length > 0) { | ||
currentCounter.retryCount.forEach(function (currentCounter) { | ||
properties = Object.assign(__assign(__assign({}, properties), { "statusCode": currentCounter.statusCode })); | ||
_this._statbeatMetrics.push({ | ||
name: Constants.StatsbeatCounter.RETRY_COUNT, | ||
value: currentCounter.count, | ||
properties: properties | ||
}); | ||
}); | ||
currentCounter.retryCount = []; //Reset | ||
} | ||
if (currentCounter.throttleCount > 0) { | ||
this._statbeatMetrics.push({ name: Constants.StatsbeatCounter.THROTTLE_COUNT, value: currentCounter.throttleCount, properties: properties }); | ||
currentCounter.throttleCount = 0; //Reset | ||
if (currentCounter.throttleCount.length > 0) { | ||
currentCounter.throttleCount.forEach(function (currentCounter) { | ||
properties = Object.assign(__assign(__assign({}, properties), { "statusCode": currentCounter.statusCode })); | ||
_this._statbeatMetrics.push({ | ||
name: Constants.StatsbeatCounter.THROTTLE_COUNT, | ||
value: currentCounter.count, | ||
properties: properties | ||
}); | ||
}); | ||
currentCounter.throttleCount = []; //Reset | ||
} | ||
if (currentCounter.exceptionCount > 0) { | ||
this._statbeatMetrics.push({ name: Constants.StatsbeatCounter.EXCEPTION_COUNT, value: currentCounter.exceptionCount, properties: properties }); | ||
currentCounter.exceptionCount = 0; //Reset | ||
if (currentCounter.exceptionCount.length > 0) { | ||
currentCounter.exceptionCount.forEach(function (currentCounter) { | ||
properties = Object.assign(__assign(__assign({}, properties), { "exceptionType": currentCounter.exceptionType })); | ||
_this._statbeatMetrics.push({ | ||
name: Constants.StatsbeatCounter.EXCEPTION_COUNT, | ||
value: currentCounter.count, | ||
properties: properties | ||
}); | ||
}); | ||
currentCounter.exceptionCount = []; //Reset | ||
} | ||
}; | ||
var this_1 = this, currentCounter; | ||
for (var i = 0; i < this._networkStatsbeatCollection.length; i++) { | ||
_loop_1(i); | ||
} | ||
@@ -312,0 +394,0 @@ }; |
@@ -5,2 +5,11 @@ export interface AgentLogger { | ||
} | ||
export declare const DiagnosticMessageId: { | ||
attachSuccessful: string; | ||
sdkExists: string; | ||
missingIkey: string; | ||
setupAlreadyCalled: string; | ||
prefixFailed: string; | ||
aadEnabled: string; | ||
unknownError: string; | ||
}; | ||
export declare const enum SeverityLevel { | ||
@@ -15,11 +24,11 @@ ERROR = "ERROR", | ||
*/ | ||
time: string; | ||
time?: string; | ||
/** | ||
* Log severity, INFO, WARN, ERROR | ||
*/ | ||
level: SeverityLevel; | ||
level?: SeverityLevel; | ||
/** | ||
* The logger writing this message. Usually the fully-qualified class or package name | ||
*/ | ||
logger: string; | ||
logger?: string; | ||
/** | ||
@@ -26,0 +35,0 @@ * The log message |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.DiagnosticMessageId = void 0; | ||
exports.DiagnosticMessageId = { | ||
"attachSuccessful": "3000", | ||
"sdkExists": "3001", | ||
"missingIkey": "3002", | ||
"setupAlreadyCalled": "3003", | ||
"prefixFailed": "3004", | ||
"aadEnabled": "3005", | ||
"unknownError": "3006", | ||
}; | ||
//# sourceMappingURL=DataModel.js.map |
@@ -20,2 +20,3 @@ "use strict"; | ||
var Config = require("../Library/Config"); | ||
var DataModel_1 = require("./DataModel"); | ||
// Private configuration vars | ||
@@ -57,9 +58,14 @@ var _appInsights; | ||
if (!forceStart && Helpers.sdkAlreadyExists(_logger)) { | ||
_statusLogger.logStatus(__assign(__assign({}, StatusLogger_1.StatusLogger.DEFAULT_STATUS), { AgentInitializedSuccessfully: false, SDKPresent: true, Reason: "SDK already exists" })); | ||
_statusLogger.logStatus(__assign(__assign({}, StatusLogger_1.StatusLogger.DEFAULT_STATUS), { AgentInitializedSuccessfully: false, SDKPresent: true, Reason: "Application Insights SDK already exists." })); | ||
return null; | ||
} | ||
if (!exports.defaultConfig.instrumentationKey) { | ||
var message = "Application Insights wanted to be started, but no Connection String was provided"; | ||
_logger.logError(message); | ||
_statusLogger.logStatus(__assign(__assign({}, StatusLogger_1.StatusLogger.DEFAULT_STATUS), { AgentInitializedSuccessfully: false, Reason: message })); | ||
var diagnosticLog = { | ||
message: "Application Insights wanted to be started, but no Connection String was provided", | ||
properties: { | ||
"msgId": DataModel_1.DiagnosticMessageId.missingIkey | ||
} | ||
}; | ||
_logger.logError(diagnosticLog); | ||
_statusLogger.logStatus(__assign(__assign({}, StatusLogger_1.StatusLogger.DEFAULT_STATUS), { AgentInitializedSuccessfully: false, Reason: diagnosticLog.message })); | ||
return null; | ||
@@ -71,3 +77,9 @@ } | ||
// setupAndStart was already called, return the result | ||
_logger.logError("Setup was attempted on the Application Insights Client multiple times. Aborting and returning the first client instance"); | ||
var diagnosticLog_1 = { | ||
message: "Setup was attempted on the Application Insights Client multiple times. Aborting and returning the first client instance.", | ||
properties: { | ||
"msgId": DataModel_1.DiagnosticMessageId.setupAlreadyCalled | ||
} | ||
}; | ||
_logger.logError(diagnosticLog_1); | ||
return _appInsights; | ||
@@ -81,3 +93,10 @@ } | ||
catch (e) { | ||
_logger.logError("Error prefixing SDK version", e); | ||
var diagnosticLog_2 = { | ||
message: "Error prefixing SDK version.", | ||
exception: e, | ||
properties: { | ||
"msgId": DataModel_1.DiagnosticMessageId.prefixFailed | ||
} | ||
}; | ||
_logger.logError(diagnosticLog_2); | ||
} | ||
@@ -101,3 +120,9 @@ return true; | ||
if (aadTokenCredential) { | ||
_logger.logMessage("Using AAD Token Credential"); | ||
var diagnosticLog_3 = { | ||
message: "Application Insights using AAD Token Credential.", | ||
properties: { | ||
"msgId": DataModel_1.DiagnosticMessageId.aadEnabled | ||
} | ||
}; | ||
_logger.logMessage(diagnosticLog_3); | ||
_appInsights.defaultClient.config.aadTokenCredential = aadTokenCredential; | ||
@@ -112,7 +137,20 @@ } | ||
// Agent successfully instrumented the SDK | ||
_logger.logMessage("Application Insights was started"); | ||
var diagnosticLog = { | ||
message: "Application Insights was started succesfully.", | ||
properties: { | ||
"msgId": DataModel_1.DiagnosticMessageId.attachSuccessful | ||
} | ||
}; | ||
_logger.logMessage(diagnosticLog); | ||
_statusLogger.logStatus(__assign(__assign({}, StatusLogger_1.StatusLogger.DEFAULT_STATUS), { AgentInitializedSuccessfully: true })); | ||
} | ||
catch (e) { | ||
_logger.logError("Error setting up Application Insights", e); | ||
var diagnosticLog = { | ||
message: "Error setting up Application Insights.", | ||
exception: e, | ||
properties: { | ||
"msgId": DataModel_1.DiagnosticMessageId.unknownError | ||
} | ||
}; | ||
_logger.logError(diagnosticLog); | ||
_statusLogger.logStatus(__assign(__assign({}, StatusLogger_1.StatusLogger.DEFAULT_STATUS), { AgentInitializedSuccessfully: false, Reason: "Error setting up Application Insights: " + (e && e.message) })); | ||
@@ -119,0 +157,0 @@ } |
@@ -6,6 +6,6 @@ import * as DataModel from "./DataModel"; | ||
static readonly DEFAULT_LOG_DIR: string; | ||
static DefaultEnvelope: DataModel.DiagnosticLog; | ||
private _defaultProperties; | ||
constructor(_writer?: DataModel.AgentLogger, instrumentationKey?: string); | ||
logMessage(message: DataModel.DiagnosticLog | string): void; | ||
logError(message: DataModel.DiagnosticLog | string, err?: Error): void; | ||
logMessage(diagnosticLog: DataModel.DiagnosticLog): void; | ||
logError(diagnosticLog: DataModel.DiagnosticLog): void; | ||
} |
"use strict"; | ||
var __assign = (this && this.__assign) || function () { | ||
__assign = Object.assign || function(t) { | ||
for (var s, i = 1, n = arguments.length; i < n; i++) { | ||
s = arguments[i]; | ||
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) | ||
t[p] = s[p]; | ||
} | ||
return t; | ||
}; | ||
return __assign.apply(this, arguments); | ||
}; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
@@ -19,2 +8,3 @@ exports.DiagnosticLogger = void 0; | ||
var Util = require("../Library/Util"); | ||
var LOGGER_NAME = "applicationinsights.extension.diagnostics"; | ||
var DiagnosticLogger = /** @class */ (function () { | ||
@@ -25,38 +15,3 @@ function DiagnosticLogger(_writer, instrumentationKey) { | ||
this._writer = _writer; | ||
DiagnosticLogger.DefaultEnvelope.properties.ikey = instrumentationKey; | ||
} | ||
DiagnosticLogger.prototype.logMessage = function (message) { | ||
if (typeof message === "string") { | ||
var diagnosticMessage = __assign(__assign({}, DiagnosticLogger.DefaultEnvelope), { message: message, level: "INFO" /* INFO */, time: new Date().toISOString() }); | ||
this._writer.log(diagnosticMessage); | ||
} | ||
else { | ||
if (message.level === "ERROR" /* ERROR */) { | ||
this._writer.error(message); | ||
} | ||
else { | ||
this._writer.log(message); | ||
} | ||
} | ||
}; | ||
DiagnosticLogger.prototype.logError = function (message, err) { | ||
if (err) { | ||
message += " " + Util.dumpObj(err); | ||
} | ||
if (typeof message === "string") { | ||
var diagnosticMessage = __assign(__assign({}, DiagnosticLogger.DefaultEnvelope), { message: message, level: "ERROR" /* ERROR */, time: new Date().toUTCString() }); | ||
this._writer.error(diagnosticMessage); | ||
} | ||
else { | ||
this._writer.error(message); | ||
} | ||
}; | ||
DiagnosticLogger.DEFAULT_FILE_NAME = "application-insights-extension.log"; | ||
DiagnosticLogger.DEFAULT_LOG_DIR = process.env.APPLICATIONINSIGHTS_LOGDIR || path.join(FileHelpers_1.homedir, "LogFiles/ApplicationInsights"); | ||
DiagnosticLogger.DefaultEnvelope = { | ||
message: null, | ||
level: null, | ||
time: null, | ||
logger: "applicationinsights.extension.diagnostics", | ||
properties: { | ||
this._defaultProperties = { | ||
language: "nodejs", | ||
@@ -69,4 +24,33 @@ operation: "Startup", | ||
subscriptionId: process.env.WEBSITE_OWNER_NAME ? process.env.WEBSITE_OWNER_NAME.split("+")[0] : null | ||
}; | ||
this._defaultProperties.ikey = instrumentationKey; | ||
} | ||
DiagnosticLogger.prototype.logMessage = function (diagnosticLog) { | ||
var props = Object.assign({}, this._defaultProperties, diagnosticLog.properties); | ||
var diagnosticMessage = { | ||
properties: props, | ||
logger: LOGGER_NAME, | ||
message: diagnosticLog.message, | ||
level: "INFO" /* INFO */, | ||
time: new Date().toUTCString() | ||
}; | ||
this._writer.log(diagnosticMessage); | ||
}; | ||
DiagnosticLogger.prototype.logError = function (diagnosticLog) { | ||
var message = diagnosticLog.message; | ||
if (diagnosticLog.exception) { | ||
message += " Error: " + Util.dumpObj(diagnosticLog.exception); | ||
} | ||
var props = Object.assign({}, this._defaultProperties, diagnosticLog.properties); | ||
var diagnosticMessage = { | ||
properties: props, | ||
logger: LOGGER_NAME, | ||
message: message, | ||
level: "ERROR" /* ERROR */, | ||
time: new Date().toUTCString() | ||
}; | ||
this._writer.error(diagnosticMessage); | ||
}; | ||
DiagnosticLogger.DEFAULT_FILE_NAME = "application-insights-extension.log"; | ||
DiagnosticLogger.DEFAULT_LOG_DIR = process.env.APPLICATIONINSIGHTS_LOGDIR || path.join(FileHelpers_1.homedir, "LogFiles/ApplicationInsights"); | ||
return DiagnosticLogger; | ||
@@ -73,0 +57,0 @@ }()); |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.sdkAlreadyExists = void 0; | ||
var DataModel_1 = require("./DataModel"); | ||
function sdkAlreadyExists(_logger) { | ||
@@ -18,4 +19,9 @@ try { | ||
if (appInstance.indexOf("home") > -1) { | ||
_logger.logMessage("applicationinsights module is already installed in this application; not re-attaching. Installed SDK location: " + | ||
appInstance); | ||
var diagnosticLog = { | ||
message: "Application Insights SDK already exists. Module is already installed in this application; not re-attaching. Installed SDK location: " + appInstance, | ||
properties: { | ||
"msgId": DataModel_1.DiagnosticMessageId.sdkExists | ||
} | ||
}; | ||
_logger.logError(diagnosticLog); | ||
return true; | ||
@@ -22,0 +28,0 @@ } |
import Contracts = require("./Contracts"); | ||
export declare const APPLICATION_INSIGHTS_SDK_VERSION = "2.3.4"; | ||
export declare const APPLICATION_INSIGHTS_SDK_VERSION = "2.3.5"; | ||
export declare const DEFAULT_BREEZE_ENDPOINT = "https://dc.services.visualstudio.com"; | ||
@@ -4,0 +4,0 @@ export declare const DEFAULT_LIVEMETRICS_ENDPOINT = "https://rt.services.visualstudio.com"; |
@@ -5,3 +5,3 @@ "use strict"; | ||
exports.TIME_SINCE_ENQUEUED = exports.ENQUEUED_TIME = exports.MessageBusDestination = exports.MicrosoftEventHub = exports.AzNamespace = exports.StatsbeatNetworkCategory = exports.StatsbeatFeatureType = exports.StatsbeatInstrumentation = exports.StatsbeatFeature = exports.StatsbeatCounter = exports.StatsbeatAttach = exports.StatsbeatResourceProvider = exports.StatsbeatTelemetryName = exports.HeartBeatMetricName = exports.DependencyTypeName = exports.TelemetryTypeStringToQuickPulseDocumentType = exports.TelemetryTypeStringToQuickPulseType = exports.QuickPulseType = exports.QuickPulseDocumentType = exports.PerformanceToQuickPulseCounter = exports.MetricId = exports.PerformanceCounter = exports.QuickPulseCounter = exports.DEFAULT_LIVEMETRICS_HOST = exports.DEFAULT_LIVEMETRICS_ENDPOINT = exports.DEFAULT_BREEZE_ENDPOINT = exports.APPLICATION_INSIGHTS_SDK_VERSION = void 0; | ||
exports.APPLICATION_INSIGHTS_SDK_VERSION = "2.3.4"; | ||
exports.APPLICATION_INSIGHTS_SDK_VERSION = "2.3.5"; | ||
exports.DEFAULT_BREEZE_ENDPOINT = "https://dc.services.visualstudio.com"; | ||
@@ -8,0 +8,0 @@ exports.DEFAULT_LIVEMETRICS_ENDPOINT = "https://rt.services.visualstudio.com"; |
@@ -9,4 +9,6 @@ import Config = require("./Config"); | ||
export declare class AzureVirtualMachine { | ||
static HTTP_TIMEOUT: number; | ||
private static TAG; | ||
private static _requestTimedOut; | ||
static getAzureComputeMetadata(config: Config, callback: (vm: IVirtualMachineInfo) => void): void; | ||
} |
@@ -16,2 +16,3 @@ "use strict"; | ||
var _a; | ||
var _this = this; | ||
var vmInfo = {}; | ||
@@ -26,3 +27,2 @@ var metadataRequestUrl = AIMS_URI + "?" + AIMS_API_VERSION + "&" + AIMS_FORMAT; | ||
}, | ||
_a.timeout = 2500, | ||
_a); | ||
@@ -56,8 +56,15 @@ var req = Util.makeRequest(config, metadataRequestUrl, requestOptions, function (res) { | ||
if (req) { | ||
req.on("timeout", function () { | ||
setTimeout(function () { | ||
_this._requestTimedOut = true; | ||
req.abort(); | ||
}); | ||
}, AzureVirtualMachine.HTTP_TIMEOUT); | ||
req.on("error", function (error) { | ||
// Unable to contact endpoint. | ||
// Do nothing for now. | ||
if (_this._requestTimedOut) { | ||
if (error) { | ||
error.name = "telemetry timeout"; | ||
error.message = "telemetry request timed out"; | ||
} | ||
} | ||
if (error && error.message && error.message.indexOf(ConnectionErrorMessage) > -1) { | ||
@@ -75,2 +82,3 @@ vmInfo.isVM = false; // confirm it's not in VM | ||
}; | ||
AzureVirtualMachine.HTTP_TIMEOUT = 2500; // 2.5 seconds | ||
AzureVirtualMachine.TAG = "AzureVirtualMachine"; | ||
@@ -77,0 +85,0 @@ return AzureVirtualMachine; |
@@ -22,5 +22,2 @@ "use strict"; | ||
this.instrumentationKey = csCode.instrumentationkey || iKeyCode /* === instrumentationKey */ || csEnv.instrumentationkey || instrumentationKeyEnv; | ||
if (!this.instrumentationKey || this.instrumentationKey == "") { | ||
throw new Error("Instrumentation key not found, please provide a connection string before starting the server"); | ||
} | ||
var endpoint = "" + (this.endpointUrl || csCode.ingestionendpoint || csEnv.ingestionendpoint || this._endpointBase); | ||
@@ -27,0 +24,0 @@ if (endpoint.endsWith("/")) { |
@@ -7,2 +7,3 @@ import Config = require("./Config"); | ||
static w3cEnabled: boolean; | ||
static HTTP_TIMEOUT: number; | ||
private static pendingLookups; | ||
@@ -12,2 +13,3 @@ private static completedLookups; | ||
private static currentRootId; | ||
private static _requestTimedOut; | ||
static queryCorrelationId(config: Config, callback: (correlationId: string) => void): void; | ||
@@ -14,0 +16,0 @@ static cancelCorrelationIdQuery(config: Config, callback: (correlationId: string) => void): void; |
@@ -68,5 +68,13 @@ "use strict"; | ||
if (req) { | ||
req.setTimeout(CorrelationIdManager.HTTP_TIMEOUT, function () { | ||
_this._requestTimedOut = true; | ||
req.abort(); | ||
}); | ||
req.on("error", function (error) { | ||
// Unable to contact endpoint. | ||
// Do nothing for now. | ||
if (_this._requestTimedOut) { | ||
error.name = "telemetry timeout"; | ||
error.message = "telemetry request timed out"; | ||
} | ||
Logging.warn(CorrelationIdManager.TAG, error); | ||
@@ -160,2 +168,3 @@ if (_this._handle) { | ||
CorrelationIdManager.w3cEnabled = true; | ||
CorrelationIdManager.HTTP_TIMEOUT = 2500; // 2.5 seconds | ||
// To avoid extraneous HTTP requests, we maintain a queue of callbacks waiting on a particular appId lookup, | ||
@@ -162,0 +171,0 @@ // as well as a cache of completed lookups so future requests can be resolved immediately. |
@@ -123,4 +123,3 @@ "use strict"; | ||
return __awaiter(this, void 0, void 0, function () { | ||
var data, err_1, err_2, size, err_3; | ||
var _this = this; | ||
var data, err_1, appendError_1, err_2, size, err_3; | ||
return __generator(this, function (_a) { | ||
@@ -142,37 +141,41 @@ switch (_a.label) { | ||
case 4: | ||
_a.trys.push([4, 6, , 8]); | ||
_a.trys.push([4, 6, , 11]); | ||
return [4 /*yield*/, FileSystemHelper.accessAsync(this._fileFullPath, fs.constants.F_OK)]; | ||
case 5: | ||
_a.sent(); | ||
return [3 /*break*/, 8]; | ||
return [3 /*break*/, 11]; | ||
case 6: | ||
err_2 = _a.sent(); | ||
// No file create one | ||
return [4 /*yield*/, FileSystemHelper.appendFileAsync(this._fileFullPath, data).catch(function (appendError) { | ||
console.log(_this.TAG, "Failed to put log into file: " + (appendError && appendError.message)); | ||
})]; | ||
appendError_1 = _a.sent(); | ||
_a.label = 7; | ||
case 7: | ||
// No file create one | ||
_a.trys.push([7, 9, , 10]); | ||
return [4 /*yield*/, FileSystemHelper.appendFileAsync(this._fileFullPath, data)]; | ||
case 8: | ||
_a.sent(); | ||
return [2 /*return*/]; | ||
case 8: | ||
_a.trys.push([8, 14, , 15]); | ||
case 9: | ||
err_2 = _a.sent(); | ||
console.log(this.TAG, "Failed to put log into file: " + (appendError_1 && appendError_1.message)); | ||
return [2 /*return*/]; | ||
case 10: return [3 /*break*/, 11]; | ||
case 11: | ||
_a.trys.push([11, 17, , 18]); | ||
return [4 /*yield*/, FileSystemHelper.getShallowFileSize(this._fileFullPath)]; | ||
case 9: | ||
case 12: | ||
size = _a.sent(); | ||
if (!(size > this.maxSizeBytes)) return [3 /*break*/, 11]; | ||
if (!(size > this.maxSizeBytes)) return [3 /*break*/, 14]; | ||
return [4 /*yield*/, this._createBackupFile(data)]; | ||
case 10: | ||
case 13: | ||
_a.sent(); | ||
return [3 /*break*/, 13]; | ||
case 11: return [4 /*yield*/, FileSystemHelper.appendFileAsync(this._fileFullPath, data)]; | ||
case 12: | ||
return [3 /*break*/, 16]; | ||
case 14: return [4 /*yield*/, FileSystemHelper.appendFileAsync(this._fileFullPath, data)]; | ||
case 15: | ||
_a.sent(); | ||
_a.label = 13; | ||
case 13: return [3 /*break*/, 15]; | ||
case 14: | ||
_a.label = 16; | ||
case 16: return [3 /*break*/, 18]; | ||
case 17: | ||
err_3 = _a.sent(); | ||
console.log(this.TAG, "Failed to create backup file: " + (err_3 && err_3.message)); | ||
return [3 /*break*/, 15]; | ||
case 15: return [2 /*return*/]; | ||
return [3 /*break*/, 18]; | ||
case 18: return [2 /*return*/]; | ||
} | ||
@@ -179,0 +182,0 @@ }); |
@@ -43,2 +43,3 @@ "use strict"; | ||
var Util = require("./Util"); | ||
var url = require("url"); | ||
var QuickPulseConfig = { | ||
@@ -48,3 +49,3 @@ method: "POST", | ||
pollingIntervalHint: "x-ms-qps-service-polling-interval-hint", | ||
endpointRedirect: "x-ms-qps-service-endpoint-redirect", | ||
endpointRedirect: "x-ms-qps-service-endpoint-redirect-v2", | ||
instanceName: "x-ms-qps-instance-name", | ||
@@ -143,3 +144,9 @@ streamId: "x-ms-qps-stream-id", | ||
var shouldPOSTData = res.headers[QuickPulseConfig.subscribed] === "true"; | ||
var redirectHeader = res.headers[QuickPulseConfig.endpointRedirect] ? res.headers[QuickPulseConfig.endpointRedirect].toString() : null; | ||
var redirectHeader = null; | ||
try { | ||
redirectHeader = res.headers[QuickPulseConfig.endpointRedirect] ? new url.URL(res.headers[QuickPulseConfig.endpointRedirect].toString()).host : null; | ||
} | ||
catch (error) { | ||
_this._onError("Failed to parse redirect header from QuickPulse: " + Util.dumpObj(error)); | ||
} | ||
var pollingIntervalHint = res.headers[QuickPulseConfig.pollingIntervalHint] ? parseInt(res.headers[QuickPulseConfig.pollingIntervalHint].toString()) : null; | ||
@@ -146,0 +153,0 @@ _this._consecutiveErrors = 0; |
@@ -13,2 +13,3 @@ import AuthorizationHandler = require("./AuthorizationHandler"); | ||
static TEMPDIR_PREFIX: string; | ||
static HTTP_TIMEOUT: number; | ||
private _config; | ||
@@ -30,2 +31,3 @@ private _isStatsbeatSender; | ||
private _tempDir; | ||
private _requestTimedOut; | ||
protected _resendInterval: number; | ||
@@ -32,0 +34,0 @@ protected _maxBytesOnDisk: number; |
@@ -207,6 +207,6 @@ "use strict"; | ||
if (res.statusCode == throttleStatusCode || res.statusCode == legacyThrottleStatusCode) { // Throttle | ||
_this._statsbeat.countThrottle(Constants.StatsbeatNetworkCategory.Breeze, endpointHost); | ||
_this._statsbeat.countThrottle(Constants.StatsbeatNetworkCategory.Breeze, endpointHost, res.statusCode); | ||
} | ||
else { | ||
_this._statsbeat.countRequest(Constants.StatsbeatNetworkCategory.Breeze, endpointHost, duration, res.statusCode === 200); | ||
_this._statsbeat.countRequest(Constants.StatsbeatNetworkCategory.Breeze, endpointHost, duration, res.statusCode === 200, res.statusCode); | ||
} | ||
@@ -228,3 +228,3 @@ } | ||
if (_this._statsbeat) { | ||
_this._statsbeat.countRetry(Constants.StatsbeatNetworkCategory.Breeze, endpointHost); | ||
_this._statsbeat.countRetry(Constants.StatsbeatNetworkCategory.Breeze, endpointHost, res.statusCode); | ||
} | ||
@@ -235,3 +235,4 @@ var breezeResponse = JSON.parse(responseString); | ||
breezeResponse.errors.forEach(function (error) { | ||
if (_this._isRetriable(error.statusCode)) { | ||
// Only retry errors if 429, 500 or 503 response codes | ||
if (error.statusCode == 429 || error.statusCode == 500 || error.statusCode == 503) { | ||
filteredEnvelopes_1.push(envelopes[error.index]); | ||
@@ -265,4 +266,5 @@ } | ||
else { | ||
var circularRedirectError = { name: "Circular Redirect", message: "Error sending telemetry because of circular redirects." }; | ||
if (_this._statsbeat) { | ||
_this._statsbeat.countException(Constants.StatsbeatNetworkCategory.Breeze, endpointHost); | ||
_this._statsbeat.countException(Constants.StatsbeatNetworkCategory.Breeze, endpointHost, circularRedirectError); | ||
} | ||
@@ -287,2 +289,8 @@ if (typeof callback === "function") { | ||
var req = Util.makeRequest(_this._config, endpointUrl, options, requestCallback); | ||
// Needed as of Node.js v13 default timeouts on HTTP requests are no longer default | ||
// Timeout should trigger the request on error function to run | ||
req.setTimeout(Sender.HTTP_TIMEOUT, function () { | ||
_this._requestTimedOut = true; | ||
req.abort(); | ||
}); | ||
req.on("error", function (error) { | ||
@@ -295,3 +303,3 @@ if (_this._isStatsbeatSender && !_this._statsbeatHasReachedIngestionAtLeastOnce) { | ||
if (_this._statsbeat) { | ||
_this._statsbeat.countException(Constants.StatsbeatNetworkCategory.Breeze, endpointHost); | ||
_this._statsbeat.countException(Constants.StatsbeatNetworkCategory.Breeze, endpointHost, error); | ||
} | ||
@@ -315,2 +323,7 @@ // Only use warn level if retries are disabled or we've had some number of consecutive failures sending data | ||
if (error) { | ||
// If the error type is a timeout we want to provide more meaningful output | ||
if (_this._requestTimedOut) { | ||
error.name = "telemetry timeout"; | ||
error.message = "telemetry request timed out"; | ||
} | ||
callback(Util.dumpObj(error)); | ||
@@ -347,3 +360,5 @@ } | ||
statusCode === 500 || // Server Error | ||
statusCode === 503 // Server Unavailable | ||
statusCode === 502 || // Bad Gateway | ||
statusCode === 503 || // Server Unavailable | ||
statusCode === 504 // Gateway Timeout | ||
); | ||
@@ -560,2 +575,3 @@ }; | ||
Sender.TEMPDIR_PREFIX = "appInsights-node"; | ||
Sender.HTTP_TIMEOUT = 20000; // 20 seconds | ||
return Sender; | ||
@@ -562,0 +578,0 @@ }()); |
@@ -29,2 +29,5 @@ "use strict"; | ||
this.config = config; | ||
if (!this.config.instrumentationKey || this.config.instrumentationKey == "") { | ||
throw new Error("Instrumentation key not found, please provide a connection string before starting Application Insights SDK."); | ||
} | ||
this.context = new Context(); | ||
@@ -31,0 +34,0 @@ this.commonProperties = {}; |
@@ -6,3 +6,3 @@ { | ||
"bugs": "https://github.com/microsoft/ApplicationInsights-node.js/issues", | ||
"version": "2.3.4", | ||
"version": "2.3.5", | ||
"description": "Microsoft Application Insights module for Node.js", | ||
@@ -9,0 +9,0 @@ "repository": { |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
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
1483351
13464