Repository: microsoft/ApplicationInsights-node.js
Pull request #1325 (2024-05-05 01:16:38)

Update Performance Counter Names
Update perf counter names to OTel valid names that will be converted in the exporter to those that are valid for Breeze.


Patch:
diff --git a/src/metrics/types.ts b/src/metrics/types.ts
index d2713ee..6976145 100644
--- a/src/metrics/types.ts
+++ b/src/metrics/types.ts
@@ -33,10 +33,10 @@ export enum StandardMetricNames {
 }
 
 export enum PerformanceCounterMetricNames {
-  PRIVATE_BYTES = "\\Process(??APP_WIN32_PROC??)\\Private Bytes",
-  AVAILABLE_BYTES = "\\Memory\\Available Bytes",
-  PROCESSOR_TIME = "\\Processor(_Total)\\% Processor Time",
-  PROCESS_TIME = "\\Process(??APP_WIN32_PROC??)\\% Processor Time",
-  REQUEST_RATE = "\\ASP.NET Applications(??APP_W3SVC_PROC??)\\Requests/Sec",
-  REQUEST_DURATION = "\\ASP.NET Applications(??APP_W3SVC_PROC??)\\Request Execution Time",
+  PRIVATE_BYTES = "Private_Bytes",
+  AVAILABLE_BYTES = "Available_Bytes",
+  PROCESSOR_TIME = "Processor_Time",
+  PROCESS_TIME = "Process_Time",
+  REQUEST_RATE = "Request_Rate",
+  REQUEST_DURATION = "Request_Execution_Time",
 }


Test patch:
diff --git a/test/unitTests/metrics/performanceCounters.tests.ts b/test/unitTests/metrics/performanceCounters.tests.ts
index 104f9d2..1bdb13b 100644
--- a/test/unitTests/metrics/performanceCounters.tests.ts
+++ b/test/unitTests/metrics/performanceCounters.tests.ts
@@ -73,7 +73,7 @@ describe("PerformanceCounterMetricsHandler", () => {
 
       assert.deepStrictEqual(
         metrics[0].descriptor.name,
-        "\\ASP.NET Applications(??APP_W3SVC_PROC??)\\Request Execution Time"
+        "Request_Execution_Time"
       );
       assert.strictEqual(metrics[0].dataPoints.length, 1, "dataPoints count");
       assert.strictEqual((metrics[0].dataPoints[0].value as Histogram).count, 10, "dataPoint count");
@@ -83,25 +83,25 @@ describe("PerformanceCounterMetricsHandler", () => {
       
       assert.deepStrictEqual(
         metrics[1].descriptor.name,
-        "\\ASP.NET Applications(??APP_W3SVC_PROC??)\\Requests/Sec"
+        "Request_Rate"
       );
       assert.ok(metrics[1].dataPoints[0].value> 0, "Wrong request rate value");
 
       assert.deepStrictEqual(
         metrics[2].descriptor.name,
-        "\\Process(??APP_WIN32_PROC??)\\Private Bytes"
+        "Private_Bytes"
       );
       assert.ok(metrics[2].dataPoints[0].value > 0, "Wrong private bytes value");
-      assert.deepStrictEqual(metrics[3].descriptor.name, "\\Memory\\Available Bytes");
+      assert.deepStrictEqual(metrics[3].descriptor.name, "Available_Bytes");
       assert.ok(metrics[3].dataPoints[0].value > 0, "Wrong available bytes value");
-      assert.deepStrictEqual(metrics[4].descriptor.name, "\\Processor(_Total)\\% Processor Time");
+      assert.deepStrictEqual(metrics[4].descriptor.name, "Processor_Time");
       assert.ok(
         metrics[4].dataPoints[0].value >= 0 && metrics[4].dataPoints[0].value <= 100,
         `Wrong Processor Time value: ${metrics[4].dataPoints[0].value}`
       );
       assert.deepStrictEqual(
         metrics[5].descriptor.name,
-        "\\Process(??APP_WIN32_PROC??)\\% Processor Time"
+        "Process_Time"
       );
       assert.ok(
         metrics[5].dataPoints[0].value >= 0 && metrics[5].dataPoints[0].value <= 100,