// Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. // See the LICENSE file in the project root for more information. #if ES_BUILD_STANDALONE using System; using System.Diagnostics; #endif using System.Collections; using System.Collections.Generic; #if ES_BUILD_STANDALONE namespace Microsoft.Diagnostics.Tracing #else namespace System.Diagnostics.Tracing #endif { [EventData] internal class CounterPayload : IEnumerable> { public string? Name { get; set; } public string? DisplayName { get; set; } public double Mean { get; set; } public double StandardDeviation { get; set; } public int Count { get; set; } public double Min { get; set; } public double Max { get; set; } public float IntervalSec { get; internal set; } public string? Series { get; set; } public string? CounterType { get; set; } public string? Metadata { get; set; } public string? DisplayUnits { get; set; } #region Implementation of the IEnumerable interface public IEnumerator> GetEnumerator() { return ForEnumeration.GetEnumerator(); } IEnumerator IEnumerable.GetEnumerator() { return ForEnumeration.GetEnumerator(); } private IEnumerable> ForEnumeration { get { yield return new KeyValuePair("Name", Name); yield return new KeyValuePair("DisplayName", DisplayName); yield return new KeyValuePair("DisplayUnits", DisplayUnits); yield return new KeyValuePair("Mean", Mean); yield return new KeyValuePair("StandardDeviation", StandardDeviation); yield return new KeyValuePair("Count", Count); yield return new KeyValuePair("Min", Min); yield return new KeyValuePair("Max", Max); yield return new KeyValuePair("IntervalSec", IntervalSec); yield return new KeyValuePair("Series", $"Interval={IntervalSec}"); yield return new KeyValuePair("CounterType", "Mean"); yield return new KeyValuePair("Metadata", Metadata); } } #endregion // Implementation of the IEnumerable interface } [EventData] internal class IncrementingCounterPayload : IEnumerable> { public string? Name { get; set; } public string? DisplayName { get; set; } public string? DisplayRateTimeScale { get; set; } public double Increment { get; set; } public float IntervalSec { get; internal set; } public string? Metadata { get; set; } public string? Series { get; set; } public string? CounterType { get; set; } public string? DisplayUnits { get; set; } #region Implementation of the IEnumerable interface public IEnumerator> GetEnumerator() { return ForEnumeration.GetEnumerator(); } IEnumerator IEnumerable.GetEnumerator() { return ForEnumeration.GetEnumerator(); } private IEnumerable> ForEnumeration { get { yield return new KeyValuePair("Name", Name); yield return new KeyValuePair("DisplayName", DisplayName); yield return new KeyValuePair("DisplayRateTimeScale", DisplayRateTimeScale); yield return new KeyValuePair("Increment", Increment); yield return new KeyValuePair("IntervalSec", IntervalSec); yield return new KeyValuePair("Series", $"Interval={IntervalSec}"); yield return new KeyValuePair("CounterType", "Sum"); yield return new KeyValuePair("Metadata", Metadata); yield return new KeyValuePair("DisplayUnits", DisplayUnits); } } #endregion // Implementation of the IEnumerable interface } }