Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

applicationinsights

Package Overview
Dependencies
Maintainers
1
Versions
153
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

applicationinsights - npm Package Compare versions

Comparing version 2.5.0 to 2.5.1

26

out/AutoCollection/AzureFunctionsHook.js

@@ -84,15 +84,17 @@ "use strict";

extractedContext = CorrelationContextManager_1.CorrelationContextManager.startOperation(ctx);
extractedContext.customProperties.setProperty("InvocationId", ctx.invocationId);
if (ctx.traceContext.attributes) {
extractedContext.customProperties.setProperty("ProcessId", ctx.traceContext.attributes["ProcessId"]);
extractedContext.customProperties.setProperty("LogLevel", ctx.traceContext.attributes["LogLevel"]);
extractedContext.customProperties.setProperty("Category", ctx.traceContext.attributes["Category"]);
extractedContext.customProperties.setProperty("HostInstanceId", ctx.traceContext.attributes["HostInstanceId"]);
extractedContext.customProperties.setProperty("AzFuncLiveLogsSessionId", ctx.traceContext.attributes["#AzFuncLiveLogsSessionId"]);
if (extractedContext) { // Will be null if CorrelationContextManager is not enabled, we should not try to propagate context in that case
extractedContext.customProperties.setProperty("InvocationId", ctx.invocationId);
if (ctx.traceContext.attributes) {
extractedContext.customProperties.setProperty("ProcessId", ctx.traceContext.attributes["ProcessId"]);
extractedContext.customProperties.setProperty("LogLevel", ctx.traceContext.attributes["LogLevel"]);
extractedContext.customProperties.setProperty("Category", ctx.traceContext.attributes["Category"]);
extractedContext.customProperties.setProperty("HostInstanceId", ctx.traceContext.attributes["HostInstanceId"]);
extractedContext.customProperties.setProperty("AzFuncLiveLogsSessionId", ctx.traceContext.attributes["#AzFuncLiveLogsSessionId"]);
}
preInvocationContext.functionCallback = CorrelationContextManager_1.CorrelationContextManager.wrapCallback(preInvocationContext.functionCallback, extractedContext);
if (this._isHttpTrigger(ctx) && this._autoGenerateIncomingRequests) {
preInvocationContext.hookData.appInsightsExtractedContext = extractedContext;
preInvocationContext.hookData.appInsightsStartTime = Date.now(); // Start trackRequest timer
}
}
preInvocationContext.functionCallback = CorrelationContextManager_1.CorrelationContextManager.wrapCallback(preInvocationContext.functionCallback, extractedContext);
if (this._isHttpTrigger(ctx) && this._autoGenerateIncomingRequests) {
preInvocationContext.hookData.appInsightsExtractedContext = extractedContext;
preInvocationContext.hookData.appInsightsStartTime = Date.now(); // Start trackRequest timer
}
}

@@ -99,0 +101,0 @@ catch (err) {

@@ -10,3 +10,3 @@ import TelemetryClient = require("../Library/TelemetryClient");

private _isInitialized;
private _isVM;
private _uniqueProcessId;
constructor(client: TelemetryClient);

@@ -13,0 +13,0 @@ enable(isEnabled: boolean): void;

"use strict";
var crypto = require("crypto");
var os = require("os");
var Vm = require("../Library/AzureVirtualMachine");
var Constants = require("../Declarations/Constants");

@@ -41,35 +41,32 @@ var Context = require("../Library/Context");

HeartBeat.prototype.trackHeartBeat = function (config, callback) {
var _this = this;
var waiting = false;
var properties = {};
var sdkVersion = Context.sdkVersion; // "node" or "node-nativeperf"
properties["sdk"] = sdkVersion;
properties["sdkVersion"] = sdkVersion;
properties["osType"] = os.type();
if (process.env.WEBSITE_SITE_NAME) { // Web apps
properties["appSrv_SiteName"] = process.env.WEBSITE_SITE_NAME || "";
properties["appSrv_wsStamp"] = process.env.WEBSITE_HOME_STAMPNAME || "";
properties["appSrv_wsHost"] = process.env.WEBSITE_HOSTNAME || "";
properties["osVersion"] = os.release();
// Random GUID that would help in analysis when app has stopped and restarted.
if (!this._uniqueProcessId) {
this._uniqueProcessId = crypto.randomBytes(16).toString("hex");
}
else if (process.env.FUNCTIONS_WORKER_RUNTIME) { // Function apps
properties["azfunction_appId"] = process.env.WEBSITE_HOSTNAME;
properties["processSessionId"] = this._uniqueProcessId;
if (process.env.WEBSITE_SITE_NAME) {
properties["appSrv_SiteName"] = process.env.WEBSITE_SITE_NAME;
}
else if (config) {
if (this._isVM === undefined) {
waiting = true;
Vm.AzureVirtualMachine.getAzureComputeMetadata(config, function (vmInfo) {
_this._isVM = vmInfo.isVM;
if (_this._isVM) {
properties["azInst_vmId"] = vmInfo.id;
properties["azInst_subscriptionId"] = vmInfo.subscriptionId;
properties["azInst_osType"] = vmInfo.osType;
}
_this._client.trackMetric({ name: Constants.HeartBeatMetricName, value: 0, properties: properties });
callback();
});
}
if (process.env.WEBSITE_HOME_STAMPNAME) {
properties["appSrv_wsStamp"] = process.env.WEBSITE_HOME_STAMPNAME;
}
if (!waiting) {
this._client.trackMetric({ name: Constants.HeartBeatMetricName, value: 0, properties: properties });
callback();
if (process.env.WEBSITE_HOSTNAME) {
properties["appSrv_wsHost"] = process.env.WEBSITE_HOSTNAME;
}
if (process.env.WEBSITE_OWNER_NAME) {
properties["appSrv_wsOwner"] = process.env.WEBSITE_OWNER_NAME;
}
if (process.env.WEBSITE_RESOURCE_GROUP) {
properties["appSrv_ResourceGroup"] = process.env.WEBSITE_RESOURCE_GROUP;
}
if (process.env.WEBSITE_SLOT_NAME) {
properties["appSrv_SlotName"] = process.env.WEBSITE_SLOT_NAME;
}
this._client.trackMetric({ name: Constants.HeartBeatMetricName, value: 0, properties: properties });
callback();
};

@@ -76,0 +73,0 @@ HeartBeat.prototype.dispose = function () {

import Contracts = require("./Contracts");
export declare const APPLICATION_INSIGHTS_SDK_VERSION = "2.5.0";
export declare const APPLICATION_INSIGHTS_SDK_VERSION = "2.5.1";
export declare const DEFAULT_BREEZE_ENDPOINT = "https://dc.services.visualstudio.com";
export declare const DEFAULT_LIVEMETRICS_ENDPOINT = "https://rt.services.visualstudio.com";
export declare const DEFAULT_LIVEMETRICS_HOST = "rt.services.visualstudio.com";
export declare const MAX_TELEMETRY_MESSAGE_LENGTH = 32768;
export declare const MAX_PROPERTY_LENGTH = 8192;
export declare const MAX_URL_LENGTH = 2048;
export declare const MAX_NAME_LENGTH = 1024;
export declare const MAX_SHORT_NAME_LENGTH = 512;
export declare const MAX_KEY_LENGTH = 150;
export declare enum QuickPulseCounter {

@@ -58,3 +64,3 @@ COMMITTED_BYTES = "\\Memory\\Committed Bytes",

};
export declare const HeartBeatMetricName = "HeartBeat";
export declare const HeartBeatMetricName = "HeartbeatState";
export declare const StatsbeatTelemetryName = "Statsbeat";

@@ -61,0 +67,0 @@ export declare const StatsbeatResourceProvider: {

"use strict";
var _a;
Object.defineProperty(exports, "__esModule", { value: true });
exports.WEB_INSTRUMENTATION_DEPRECATED_SOURCE = exports.WEB_INSTRUMENTATION_DEFAULT_SOURCE = 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.5.0";
exports.WEB_INSTRUMENTATION_DEPRECATED_SOURCE = exports.WEB_INSTRUMENTATION_DEFAULT_SOURCE = 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.MAX_KEY_LENGTH = exports.MAX_SHORT_NAME_LENGTH = exports.MAX_NAME_LENGTH = exports.MAX_URL_LENGTH = exports.MAX_PROPERTY_LENGTH = exports.MAX_TELEMETRY_MESSAGE_LENGTH = 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.5.1";
exports.DEFAULT_BREEZE_ENDPOINT = "https://dc.services.visualstudio.com";
exports.DEFAULT_LIVEMETRICS_ENDPOINT = "https://rt.services.visualstudio.com";
exports.DEFAULT_LIVEMETRICS_HOST = "rt.services.visualstudio.com";
exports.MAX_TELEMETRY_MESSAGE_LENGTH = 32768;
exports.MAX_PROPERTY_LENGTH = 8192;
exports.MAX_URL_LENGTH = 2048;
exports.MAX_NAME_LENGTH = 1024;
exports.MAX_SHORT_NAME_LENGTH = 512;
exports.MAX_KEY_LENGTH = 150;
var QuickPulseCounter;

@@ -107,3 +113,3 @@ (function (QuickPulseCounter) {

};
exports.HeartBeatMetricName = "HeartBeat";
exports.HeartBeatMetricName = "HeartbeatState";
exports.StatsbeatTelemetryName = "Statsbeat";

@@ -110,0 +116,0 @@ exports.StatsbeatResourceProvider = {

@@ -20,2 +20,3 @@ import Contracts = require("../Declarations/Contracts");

private static addAzureFunctionsCorrelationProperties;
private static truncateProperties;
private static createTraceData;

@@ -22,0 +23,0 @@ private static createDependencyData;

@@ -5,2 +5,3 @@ "use strict";

var CorrelationContextManager_1 = require("../AutoCollection/CorrelationContextManager");
var Logging = require("./Logging");
/**

@@ -122,6 +123,28 @@ * Manages the logic of creating envelopes from Telemetry objects

};
EnvelopeFactory.truncateProperties = function (telemetry) {
if (telemetry.properties) {
try {
var properties = {};
var propertiesKeys = Object.keys(telemetry.properties);
var propertiesValues = Object.values(telemetry.properties);
for (var i = 0; i < propertiesKeys.length; i++) {
if (propertiesKeys[i].length <= 150) {
if (typeof (propertiesValues[i]) === "object") {
propertiesValues[i] = Util.stringify(propertiesValues[i]);
}
properties[propertiesKeys[i]] = String(propertiesValues[i]).substring(0, 8192);
}
}
return properties;
}
catch (error) {
Logging.warn("Failed to properly truncate telemetry properties: ", error);
}
}
};
EnvelopeFactory.createTraceData = function (telemetry) {
var _a;
var trace = new Contracts.MessageData();
trace.message = telemetry.message;
trace.properties = telemetry.properties;
trace.message = (_a = telemetry.message) === null || _a === void 0 ? void 0 : _a.substring(0, 32768);
trace.properties = this.truncateProperties(telemetry);
if (!isNaN(telemetry.severity)) {

@@ -139,12 +162,11 @@ trace.severityLevel = telemetry.severity;

EnvelopeFactory.createDependencyData = function (telemetry) {
var _a, _b, _c;
var remoteDependency = new Contracts.RemoteDependencyData();
if (typeof telemetry.name === "string") {
remoteDependency.name = telemetry.name.length > 1024 ? telemetry.name.slice(0, 1021) + "..." : telemetry.name;
}
remoteDependency.data = telemetry.data;
remoteDependency.target = telemetry.target;
remoteDependency.name = (_a = telemetry.name) === null || _a === void 0 ? void 0 : _a.substring(0, 1024);
remoteDependency.data = (_b = telemetry.data) === null || _b === void 0 ? void 0 : _b.substring(0, 8192);
remoteDependency.target = (_c = telemetry.target) === null || _c === void 0 ? void 0 : _c.substring(0, 1024);
remoteDependency.duration = Util.msToTimeSpan(telemetry.duration);
remoteDependency.success = telemetry.success;
remoteDependency.type = telemetry.dependencyTypeName;
remoteDependency.properties = telemetry.properties;
remoteDependency.properties = this.truncateProperties(telemetry);
remoteDependency.resultCode = (telemetry.resultCode ? telemetry.resultCode.toString() : "0");

@@ -163,5 +185,6 @@ if (telemetry.id) {

EnvelopeFactory.createEventData = function (telemetry) {
var _a;
var event = new Contracts.EventData();
event.name = telemetry.name;
event.properties = telemetry.properties;
event.name = (_a = telemetry.name) === null || _a === void 0 ? void 0 : _a.substring(0, 512);
event.properties = this.truncateProperties(telemetry);
event.measurements = telemetry.measurements;

@@ -174,4 +197,5 @@ var data = new Contracts.Data();

EnvelopeFactory.createExceptionData = function (telemetry) {
var _a, _b;
var exception = new Contracts.ExceptionData();
exception.properties = telemetry.properties;
exception.properties = this.truncateProperties(telemetry);
if (!isNaN(telemetry.severity)) {

@@ -187,4 +211,4 @@ exception.severityLevel = telemetry.severity;

var exceptionDetails = new Contracts.ExceptionDetails();
exceptionDetails.message = telemetry.exception.message;
exceptionDetails.typeName = telemetry.exception.name;
exceptionDetails.message = (_a = telemetry.exception.message) === null || _a === void 0 ? void 0 : _a.substring(0, 32768);
exceptionDetails.typeName = (_b = telemetry.exception.name) === null || _b === void 0 ? void 0 : _b.substring(0, 1024);
exceptionDetails.parsedStack = this.parseStack(stack);

@@ -199,2 +223,3 @@ exceptionDetails.hasFullStack = Util.isArray(exceptionDetails.parsedStack) && exceptionDetails.parsedStack.length > 0;

EnvelopeFactory.createRequestData = function (telemetry) {
var _a, _b, _c, _d;
var requestData = new Contracts.RequestData();

@@ -207,9 +232,9 @@ if (telemetry.id) {

}
requestData.name = telemetry.name;
requestData.url = telemetry.url;
requestData.source = telemetry.source;
requestData.name = (_a = telemetry.name) === null || _a === void 0 ? void 0 : _a.substring(0, 1024);
requestData.url = (_b = telemetry.url) === null || _b === void 0 ? void 0 : _b.substring(0, 2048);
requestData.source = (_c = telemetry.source) === null || _c === void 0 ? void 0 : _c.substring(0, 1024);
requestData.duration = Util.msToTimeSpan(telemetry.duration);
requestData.responseCode = (telemetry.resultCode ? telemetry.resultCode.toString() : "0");
requestData.responseCode = (_d = (telemetry.resultCode ? telemetry.resultCode.toString() : "0")) === null || _d === void 0 ? void 0 : _d.substring(0, 1024);
requestData.success = telemetry.success;
requestData.properties = telemetry.properties;
requestData.properties = this.truncateProperties(telemetry);
requestData.measurements = telemetry.measurements;

@@ -222,2 +247,3 @@ var data = new Contracts.Data();

EnvelopeFactory.createMetricData = function (telemetry) {
var _a;
var metrics = new Contracts.MetricData(); // todo: enable client-batching of these

@@ -230,3 +256,3 @@ metrics.metrics = [];

metric.min = !isNaN(telemetry.min) ? telemetry.min : telemetry.value;
metric.name = telemetry.name;
metric.name = (_a = telemetry.name) === null || _a === void 0 ? void 0 : _a.substring(0, 1024);
metric.stdDev = !isNaN(telemetry.stdDev) ? telemetry.stdDev : 0;

@@ -236,3 +262,3 @@ metric.value = telemetry.value;

metrics.metrics.push(metric);
metrics.properties = telemetry.properties;
metrics.properties = this.truncateProperties(telemetry);
var data = new Contracts.Data();

@@ -244,2 +270,3 @@ data.baseType = Contracts.telemetryTypeToBaseType(Contracts.TelemetryType.Metric);

EnvelopeFactory.createAvailabilityData = function (telemetry) {
var _a, _b;
var availabilityData = new Contracts.AvailabilityData();

@@ -252,9 +279,9 @@ if (telemetry.id) {

}
availabilityData.name = telemetry.name;
availabilityData.name = (_a = telemetry.name) === null || _a === void 0 ? void 0 : _a.substring(0, 1024);
availabilityData.duration = Util.msToTimeSpan(telemetry.duration);
availabilityData.success = telemetry.success;
availabilityData.runLocation = telemetry.runLocation;
availabilityData.message = telemetry.message;
availabilityData.message = (_b = telemetry.message) === null || _b === void 0 ? void 0 : _b.substring(0, 8192);
availabilityData.measurements = telemetry.measurements;
availabilityData.properties = telemetry.properties;
availabilityData.properties = this.truncateProperties(telemetry);
var data = new Contracts.Data();

@@ -266,8 +293,9 @@ data.baseType = Contracts.telemetryTypeToBaseType(Contracts.TelemetryType.Availability);

EnvelopeFactory.createPageViewData = function (telemetry) {
var _a, _b;
var pageViewData = new Contracts.PageViewData();
pageViewData.name = telemetry.name;
pageViewData.name = (_a = telemetry.name) === null || _a === void 0 ? void 0 : _a.substring(0, 1024);
pageViewData.duration = Util.msToTimeSpan(telemetry.duration);
pageViewData.url = telemetry.url;
pageViewData.url = (_b = telemetry.url) === null || _b === void 0 ? void 0 : _b.substring(0, 2048);
pageViewData.measurements = telemetry.measurements;
pageViewData.properties = telemetry.properties;
pageViewData.properties = this.truncateProperties(telemetry);
var data = new Contracts.Data();

@@ -274,0 +302,0 @@ data.baseType = Contracts.telemetryTypeToBaseType(Contracts.TelemetryType.PageView);

@@ -6,3 +6,3 @@ {

"bugs": "https://github.com/microsoft/ApplicationInsights-node.js/issues",
"version": "2.5.0",
"version": "2.5.1",
"description": "Microsoft Application Insights module for Node.js",

@@ -72,2 +72,3 @@ "repository": {

"@azure/core-rest-pipeline": "^1.10.0",
"@azure/opentelemetry-instrumentation-azure-sdk": "^1.0.0-beta.2",
"@microsoft/applicationinsights-web-snippet": "^1.0.1",

@@ -74,0 +75,0 @@ "@opentelemetry/api": "^1.0.4",

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

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc