applicationinsights-native-metrics
Advanced tools
Comparing version 0.0.10 to 0.0.11
const events = require("events"); | ||
const os = require("os"); | ||
const natives = require("../build/Release/native_metrics.node"); | ||
@@ -6,2 +7,3 @@ | ||
| "Scavenge" | ||
| "MinorMarkCompact" | ||
| "MarkSweepCompact" | ||
@@ -23,2 +25,13 @@ | "IncrementalMarking" | ||
// Node 18 and newer | ||
// https://v8docs.nodesource.com/node-18.2/db/d88/v8-callbacks_8h_source.html | ||
private static GC_TYPES_NEW: { [key: number]: gcTypes } = { | ||
1: "Scavenge", | ||
2: "MinorMarkCompact", | ||
4: "MarkSweepCompact", | ||
8: "IncrementalMarking", | ||
16: "ProcessWeakCallbacks", | ||
31: "All" | ||
}; | ||
private static DEFAULT_INTERVAL = 15000; | ||
@@ -31,2 +44,3 @@ | ||
private _resourceProfiler: any; | ||
private _nodeMajVer: number; | ||
@@ -36,2 +50,4 @@ constructor(options: any) { | ||
this._nodeMajVer = parseInt(process.versions.node.split('.')[0], 10); | ||
options = options || { timeout: NativeMetricEmitter.DEFAULT_INTERVAL }; | ||
@@ -65,3 +81,9 @@ this.enabled = false; | ||
if (gcMetrics.hasOwnProperty(typeId) && gcMetrics[typeId].count > 0) { | ||
const typeName = NativeMetricEmitter.GC_TYPES[typeId]; | ||
let typeName = ""; | ||
if (this._nodeMajVer >= 18) { | ||
typeName = NativeMetricEmitter.GC_TYPES_NEW[typeId]; | ||
} | ||
else { | ||
typeName = NativeMetricEmitter.GC_TYPES[typeId]; | ||
} | ||
results[typeName] = { | ||
@@ -68,0 +90,0 @@ typeId: parseInt(typeId, 10), |
declare const events: any; | ||
declare class NativeMetricEmitter extends events.EventEmitter { | ||
private static GC_TYPES; | ||
private static GC_TYPES_NEW; | ||
private static DEFAULT_INTERVAL; | ||
@@ -10,2 +11,3 @@ private enabled; | ||
private _resourceProfiler; | ||
private _nodeMajVer; | ||
constructor(options: any); | ||
@@ -12,0 +14,0 @@ enable(enable?: boolean, pollInterval?: number): void; |
@@ -16,2 +16,3 @@ "use strict"; | ||
var events = require("events"); | ||
var os = require("os"); | ||
var natives = require("../build/Release/native_metrics.node"); | ||
@@ -22,2 +23,3 @@ var NativeMetricEmitter = /** @class */ (function (_super) { | ||
var _this = _super.call(this, options) || this; | ||
_this._nodeMajVer = parseInt(process.versions.node.split('.')[0], 10); | ||
options = options || { timeout: NativeMetricEmitter.DEFAULT_INTERVAL }; | ||
@@ -49,3 +51,9 @@ _this.enabled = false; | ||
if (gcMetrics.hasOwnProperty(typeId) && gcMetrics[typeId].count > 0) { | ||
var typeName = NativeMetricEmitter.GC_TYPES[typeId]; | ||
var typeName = ""; | ||
if (this._nodeMajVer >= 18) { | ||
typeName = NativeMetricEmitter.GC_TYPES_NEW[typeId]; | ||
} | ||
else { | ||
typeName = NativeMetricEmitter.GC_TYPES[typeId]; | ||
} | ||
results[typeName] = { | ||
@@ -99,2 +107,12 @@ typeId: parseInt(typeId, 10), | ||
}; | ||
// Node 18 and newer | ||
// https://v8docs.nodesource.com/node-18.2/db/d88/v8-callbacks_8h_source.html | ||
NativeMetricEmitter.GC_TYPES_NEW = { | ||
1: "Scavenge", | ||
2: "MinorMarkCompact", | ||
4: "MarkSweepCompact", | ||
8: "IncrementalMarking", | ||
16: "ProcessWeakCallbacks", | ||
31: "All" | ||
}; | ||
NativeMetricEmitter.DEFAULT_INTERVAL = 15000; | ||
@@ -101,0 +119,0 @@ return NativeMetricEmitter; |
{ | ||
"name": "applicationinsights-native-metrics", | ||
"description": "Native APM agent for the Application Insights Node.js SDK", | ||
"version": "0.0.10", | ||
"version": "0.0.11", | ||
"engines": { | ||
@@ -6,0 +6,0 @@ "node": ">=6.0.0", |
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
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
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
32590
270
2