summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSung Yoon Whang <suwhang@microsoft.com>2019-06-06 17:18:27 -0700
committerGitHub <noreply@github.com>2019-06-06 17:18:27 -0700
commit6ae52c542fefea83e01e29ba592b163b0faf8321 (patch)
treeb578aafb0e7b07306f44754a9e3b03ee6c55ffa4
parent93216920549a0f574694e383d67d6d0ea5a4fed3 (diff)
downloadcoreclr-6ae52c542fefea83e01e29ba592b163b0faf8321.tar.gz
coreclr-6ae52c542fefea83e01e29ba592b163b0faf8321.tar.bz2
coreclr-6ae52c542fefea83e01e29ba592b163b0faf8321.zip
Add DisplayUnits property to DiagnosticCounter (#24981)
-rw-r--r--src/System.Private.CoreLib/shared/System/Diagnostics/Tracing/CounterPayload.cs6
-rw-r--r--src/System.Private.CoreLib/shared/System/Diagnostics/Tracing/DiagnosticCounter.cs2
-rw-r--r--src/System.Private.CoreLib/shared/System/Diagnostics/Tracing/EventCounter.cs3
-rw-r--r--src/System.Private.CoreLib/shared/System/Diagnostics/Tracing/IncrementingEventCounter.cs1
-rw-r--r--src/System.Private.CoreLib/shared/System/Diagnostics/Tracing/IncrementingPollingCounter.cs1
-rw-r--r--src/System.Private.CoreLib/shared/System/Diagnostics/Tracing/PollingCounter.cs1
6 files changed, 13 insertions, 1 deletions
diff --git a/src/System.Private.CoreLib/shared/System/Diagnostics/Tracing/CounterPayload.cs b/src/System.Private.CoreLib/shared/System/Diagnostics/Tracing/CounterPayload.cs
index 145dfbfc92..063df02152 100644
--- a/src/System.Private.CoreLib/shared/System/Diagnostics/Tracing/CounterPayload.cs
+++ b/src/System.Private.CoreLib/shared/System/Diagnostics/Tracing/CounterPayload.cs
@@ -42,6 +42,8 @@ namespace System.Diagnostics.Tracing
public string? Metadata { get; set; }
+ public string? DisplayUnits { get; set; }
+
#region Implementation of the IEnumerable interface
public IEnumerator<KeyValuePair<string, object?>> GetEnumerator()
@@ -60,6 +62,7 @@ namespace System.Diagnostics.Tracing
{
yield return new KeyValuePair<string, object?>("Name", Name);
yield return new KeyValuePair<string, object?>("DisplayName", DisplayName);
+ yield return new KeyValuePair<string, object?>("DisplayUnits", DisplayUnits);
yield return new KeyValuePair<string, object?>("Mean", Mean);
yield return new KeyValuePair<string, object?>("StandardDeviation", StandardDeviation);
yield return new KeyValuePair<string, object?>("Count", Count);
@@ -94,6 +97,8 @@ namespace System.Diagnostics.Tracing
public string? CounterType { get; set; }
+ public string? DisplayUnits { get; set; }
+
#region Implementation of the IEnumerable interface
public IEnumerator<KeyValuePair<string, object?>> GetEnumerator()
@@ -118,6 +123,7 @@ namespace System.Diagnostics.Tracing
yield return new KeyValuePair<string, object?>("Series", $"Interval={IntervalSec}");
yield return new KeyValuePair<string, object?>("CounterType", "Sum");
yield return new KeyValuePair<string, object?>("Metadata", Metadata);
+ yield return new KeyValuePair<string, object?>("DisplayUnits", DisplayUnits);
}
}
diff --git a/src/System.Private.CoreLib/shared/System/Diagnostics/Tracing/DiagnosticCounter.cs b/src/System.Private.CoreLib/shared/System/Diagnostics/Tracing/DiagnosticCounter.cs
index af48288f9a..ade22c7553 100644
--- a/src/System.Private.CoreLib/shared/System/Diagnostics/Tracing/DiagnosticCounter.cs
+++ b/src/System.Private.CoreLib/shared/System/Diagnostics/Tracing/DiagnosticCounter.cs
@@ -77,6 +77,8 @@ namespace System.Diagnostics.Tracing
public string? DisplayName { get; set; }
+ public string? DisplayUnits { get; set; }
+
public string Name { get; }
public EventSource EventSource { get; }
diff --git a/src/System.Private.CoreLib/shared/System/Diagnostics/Tracing/EventCounter.cs b/src/System.Private.CoreLib/shared/System/Diagnostics/Tracing/EventCounter.cs
index bfe0552583..43026e89dd 100644
--- a/src/System.Private.CoreLib/shared/System/Diagnostics/Tracing/EventCounter.cs
+++ b/src/System.Private.CoreLib/shared/System/Diagnostics/Tracing/EventCounter.cs
@@ -106,7 +106,8 @@ namespace System.Diagnostics.Tracing
payload.Series = $"Interval={pollingIntervalMillisec}"; // TODO: This may need to change when we support multi-session
payload.CounterType = "Mean";
payload.Metadata = GetMetadataString();
- payload.DisplayName = DisplayName;
+ payload.DisplayName = DisplayName ?? "";
+ payload.DisplayUnits = DisplayUnits ?? "";
payload.Name = Name;
ResetStatistics();
EventSource.Write("EventCounters", new EventSourceOptions() { Level = EventLevel.LogAlways }, new CounterPayloadType(payload));
diff --git a/src/System.Private.CoreLib/shared/System/Diagnostics/Tracing/IncrementingEventCounter.cs b/src/System.Private.CoreLib/shared/System/Diagnostics/Tracing/IncrementingEventCounter.cs
index e084bbb1c1..596de0c65d 100644
--- a/src/System.Private.CoreLib/shared/System/Diagnostics/Tracing/IncrementingEventCounter.cs
+++ b/src/System.Private.CoreLib/shared/System/Diagnostics/Tracing/IncrementingEventCounter.cs
@@ -68,6 +68,7 @@ namespace System.Diagnostics.Tracing
payload.CounterType = "Sum";
payload.Metadata = GetMetadataString();
payload.Increment = _increment - _prevIncrement;
+ payload.DisplayUnits = DisplayUnits ?? "";
_prevIncrement = _increment;
EventSource.Write("EventCounters", new EventSourceOptions() { Level = EventLevel.LogAlways }, new IncrementingEventCounterPayloadType(payload));
}
diff --git a/src/System.Private.CoreLib/shared/System/Diagnostics/Tracing/IncrementingPollingCounter.cs b/src/System.Private.CoreLib/shared/System/Diagnostics/Tracing/IncrementingPollingCounter.cs
index 116fbe8290..06d1d75314 100644
--- a/src/System.Private.CoreLib/shared/System/Diagnostics/Tracing/IncrementingPollingCounter.cs
+++ b/src/System.Private.CoreLib/shared/System/Diagnostics/Tracing/IncrementingPollingCounter.cs
@@ -81,6 +81,7 @@ namespace System.Diagnostics.Tracing
payload.CounterType = "Sum";
payload.Metadata = GetMetadataString();
payload.Increment = _increment - _prevIncrement;
+ payload.DisplayUnits = DisplayUnits ?? "";
_prevIncrement = _increment;
EventSource.Write("EventCounters", new EventSourceOptions() { Level = EventLevel.LogAlways }, new IncrementingPollingCounterPayloadType(payload));
}
diff --git a/src/System.Private.CoreLib/shared/System/Diagnostics/Tracing/PollingCounter.cs b/src/System.Private.CoreLib/shared/System/Diagnostics/Tracing/PollingCounter.cs
index abb472cd2e..13ff314be4 100644
--- a/src/System.Private.CoreLib/shared/System/Diagnostics/Tracing/PollingCounter.cs
+++ b/src/System.Private.CoreLib/shared/System/Diagnostics/Tracing/PollingCounter.cs
@@ -71,6 +71,7 @@ namespace System.Diagnostics.Tracing
payload.Min = value;
payload.Metadata = GetMetadataString();
payload.StandardDeviation = 0;
+ payload.DisplayUnits = DisplayUnits ?? "";
_lastVal = value;
EventSource.Write("EventCounters", new EventSourceOptions() { Level = EventLevel.LogAlways }, new PollingPayloadType(payload));
}