2727import com .google .common .base .Preconditions ;
2828import com .microsoft .applicationinsights .TelemetryClient ;
2929import com .microsoft .applicationinsights .internal .system .SystemInformation ;
30+ import com .microsoft .applicationinsights .telemetry .MetricTelemetry ;
3031import com .microsoft .applicationinsights .telemetry .PerformanceCounterTelemetry ;
3132
3233import com .google .common .base .Strings ;
@@ -56,8 +57,9 @@ public final class WindowsPerformanceCounterAsPC extends AbstractWindowsPerforma
5657 public WindowsPerformanceCounterAsPC () throws Throwable {
5758 Preconditions .checkState (SystemInformation .INSTANCE .isWindows (), "Must be used under Windows OS." );
5859
59- register (Constants .TOTAL_CPU_PC_CATEGORY_NAME , Constants .CPU_PC_COUNTER_NAME , Constants .INSTANCE_NAME_TOTAL );
60- register (Constants .PROCESS_CATEGORY , Constants .PROCESS_IO_PC_COUNTER_NAME , JniPCConnector .translateInstanceName (JniPCConnector .PROCESS_SELF_INSTANCE_NAME ));
60+ register (Constants .TOTAL_CPU_PC_CATEGORY_NAME , Constants .CPU_PC_COUNTER_NAME , Constants .INSTANCE_NAME_TOTAL , Constants .TOTAL_CPU_PC_METRIC_NAME );
61+ register (Constants .PROCESS_CATEGORY , Constants .PROCESS_IO_PC_COUNTER_NAME , JniPCConnector .translateInstanceName (JniPCConnector .PROCESS_SELF_INSTANCE_NAME ),
62+ Constants .PROCESS_IO_PC_METRIC_NAME );
6163
6264 if (pcs .isEmpty ()) {
6365 // Failed to register, the performance counter is not needed.
@@ -100,7 +102,7 @@ public String getId() {
100102 }
101103
102104 private void send (TelemetryClient telemetryClient , double value , WindowsPerformanceCounterData data ) {
103- PerformanceCounterTelemetry telemetry = new PerformanceCounterTelemetry (data .categoryName , data . counterName , data . instanceName , value );
105+ MetricTelemetry telemetry = new MetricTelemetry (data .getDisplayName () , value );
104106 telemetryClient .track (telemetry );
105107 }
106108
@@ -111,15 +113,15 @@ private void send(TelemetryClient telemetryClient, double value, WindowsPerforma
111113 * @param counter The counter
112114 * @param instance The instnace
113115 */
114- private void register (String category , String counter , String instance ) {
116+ private void register (String category , String counter , String instance , String metricName ) {
115117 String key = JniPCConnector .addPerformanceCounter (category , counter , instance );
116118 if (!Strings .isNullOrEmpty (key )) {
117119 try {
118120 WindowsPerformanceCounterData data = new WindowsPerformanceCounterData ().
119121 setCategoryName (category ).
120122 setCounterName (counter ).
121123 setInstanceName (instance ).
122- setDisplayName (category + " " + counter );
124+ setDisplayName (metricName );
123125 pcs .put (key , data );
124126 } catch (ThreadDeath td ) {
125127 throw td ;
0 commit comments