-
Notifications
You must be signed in to change notification settings - Fork 387
Add support for System.Diagnostics.Metrics in dotnet-monitor's collector #3587
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 9 commits
d55df48
e6b5f21
b52b4c4
ddf091e
959ebd6
f3fd8a6
c822924
5052752
1b70d14
308cffc
6f01912
149f3ad
22ff644
645c2d0
fe36113
79172f9
b47a957
887c6d4
ff4586f
4970332
ba1fac5
2c1beab
8f8bce2
b2971ce
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -8,14 +8,11 @@ | |
|
|
||
| namespace Microsoft.Diagnostics.Monitoring.EventPipe | ||
| { | ||
| /// <summary> | ||
| /// TODO This is currently a duplication of the src\Tools\dotnet-counters\CounterPayload.cs stack. The two will be unified in a separate change. | ||
| /// </summary> | ||
| internal class CounterPayload : ICounterPayload | ||
| { | ||
| #if NETSTANDARD | ||
| private static readonly IReadOnlyDictionary<string, string> Empty = new ReadOnlyDictionary<string, string>(new Dictionary<string, string>(0)); | ||
| #else | ||
| private static readonly IReadOnlyDictionary<string, string> Empty = System.Collections.Immutable.ImmutableDictionary<string, string>.Empty; | ||
| #endif | ||
|
|
||
| public CounterPayload(DateTime timestamp, | ||
| string provider, | ||
| string name, | ||
|
|
@@ -24,7 +21,7 @@ public CounterPayload(DateTime timestamp, | |
| double value, | ||
| CounterType counterType, | ||
| float interval, | ||
| Dictionary<string, string> metadata) | ||
| string metadata) | ||
| { | ||
| Timestamp = timestamp; | ||
| Name = name; | ||
|
|
@@ -34,14 +31,27 @@ public CounterPayload(DateTime timestamp, | |
| CounterType = counterType; | ||
| Provider = provider; | ||
| Interval = interval; | ||
| Metadata = metadata ?? Empty; | ||
| Metadata = metadata; | ||
| EventType = EventType.Gauge; | ||
| } | ||
|
|
||
| // Copied from dotnet-counters | ||
| public CounterPayload(string providerName, string name, string displayName, string displayUnits, string metadata, double value, DateTime timestamp, string type, EventType eventType) | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. There is a separate change for cleaning up all these constructors. |
||
| { | ||
| Provider = providerName; | ||
| Name = name; | ||
| Metadata = metadata; | ||
| Value = value; | ||
| Timestamp = timestamp; | ||
| CounterType = (CounterType)Enum.Parse(typeof(CounterType), type); | ||
| EventType = eventType; | ||
| } | ||
|
|
||
| public string Namespace { get; } | ||
|
|
||
| public string Name { get; } | ||
|
|
||
| public string DisplayName { get; } | ||
| public string DisplayName { get; protected set; } | ||
|
|
||
| public string Unit { get; } | ||
|
|
||
|
|
@@ -55,6 +65,77 @@ public CounterPayload(DateTime timestamp, | |
|
|
||
| public string Provider { get; } | ||
|
|
||
| public IReadOnlyDictionary<string, string> Metadata { get; } | ||
| public string Metadata { get; } | ||
|
|
||
| public EventType EventType { get; set; } | ||
| } | ||
|
|
||
| internal class GaugePayload : CounterPayload | ||
| { | ||
| public GaugePayload(string providerName, string name, string displayName, string displayUnits, string metadata, double value, DateTime timestamp) : | ||
| base(providerName, name, displayName, displayUnits, metadata, value, timestamp, "Metric", EventType.Gauge) | ||
| { | ||
| // In case these properties are not provided, set them to appropriate values. | ||
| string counterName = string.IsNullOrEmpty(displayName) ? name : displayName; | ||
| DisplayName = !string.IsNullOrEmpty(displayUnits) ? $"{counterName} ({displayUnits})" : counterName; | ||
| } | ||
| } | ||
|
|
||
| internal class CounterEndedPayload : CounterPayload | ||
| { | ||
| public CounterEndedPayload(string providerName, string name, string displayName, DateTime timestamp) | ||
| : base(providerName, name, displayName, string.Empty, null, 0.0, timestamp, "Metric", EventType.CounterEnded) | ||
| { | ||
|
|
||
| } | ||
| } | ||
|
|
||
| internal class RatePayload : CounterPayload | ||
| { | ||
| public RatePayload(string providerName, string name, string displayName, string displayUnits, string metadata, double value, double intervalSecs, DateTime timestamp) : | ||
| base(providerName, name, displayName, displayUnits, metadata, value, timestamp, "Rate", EventType.Rate) | ||
| { | ||
| // In case these properties are not provided, set them to appropriate values. | ||
| string counterName = string.IsNullOrEmpty(displayName) ? name : displayName; | ||
| string unitsName = string.IsNullOrEmpty(displayUnits) ? "Count" : displayUnits; | ||
| string intervalName = intervalSecs.ToString() + " sec"; | ||
| DisplayName = $"{counterName} ({unitsName} / {intervalName})"; | ||
| } | ||
| } | ||
|
|
||
| internal class PercentilePayload : CounterPayload | ||
| { | ||
| public PercentilePayload(string providerName, string name, string displayName, string displayUnits, string metadata, double val, DateTime timestamp) : | ||
| base(providerName, name, displayName, displayUnits, metadata, val, timestamp, "Metric", EventType.Histogram) | ||
| { | ||
| // In case these properties are not provided, set them to appropriate values. | ||
| string counterName = string.IsNullOrEmpty(displayName) ? name : displayName; | ||
| DisplayName = !string.IsNullOrEmpty(displayUnits) ? $"{counterName} ({displayUnits})" : counterName; | ||
| } | ||
| } | ||
|
|
||
| internal class ErrorPayload : CounterPayload | ||
| { | ||
| public ErrorPayload(string errorMessage) : this(errorMessage, DateTime.UtcNow) | ||
| { | ||
| } | ||
|
|
||
| public ErrorPayload(string errorMessage, DateTime timestamp) : | ||
| base(string.Empty, string.Empty, string.Empty, string.Empty, null, 0.0, timestamp, "Metric", EventType.Error) | ||
| { | ||
| ErrorMessage = errorMessage; | ||
| } | ||
|
|
||
| public string ErrorMessage { get; private set; } | ||
| } | ||
|
|
||
| // If keep this, should probably put it somewhere else | ||
wiktork marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| internal enum EventType : int | ||
| { | ||
| Rate, | ||
| Gauge, | ||
| Histogram, | ||
| Error, | ||
| CounterEnded | ||
| } | ||
| } | ||
Uh oh!
There was an error while loading. Please reload this page.