internal string FormattedMetricValue(MetricType type, MetricValue metricValue, double sample)
        {
            if (sample < 0 || sample > 1)
            {
                throw new ArgumentOutOfRangeException(nameof(sample));
            }

            var metricTypeSpecifier = GetMetricTypeSpecifier(type);

            var value = metricValue.ToString();

            if (string.IsNullOrWhiteSpace(metricTypeSpecifier))
            {
                throw new ArgumentException(nameof(type));
            }

            if (sample < 0 || sample > 1)
            {
                throw new ArgumentOutOfRangeException(nameof(sample));
            }

            var format = sample < 1 ? SampledMetricDatagramFormat : MetricDatagramFormat;

            return(string.Format(cultureInfo, format, value, metricTypeSpecifier, sample));
        }
Exemplo n.º 2
0
 public override string ToString()
 {
     return(MetricValue == null ? "No value found" : MetricValue.ToString());
 }
Exemplo n.º 3
0
        /// <summary>
        /// Returns a string that represents the current object.
        /// </summary>
        /// <returns>A string that represents the current object.</returns>
        public override string ToString()
        {
            string contextFormatted = $"{{{String.Join("; ", Context.Select(item => $"[{item.Key}, {item.Value}]"))}}}";

            return($"{MetricName}: {MetricValue.ToString(CultureInfo.InvariantCulture)} at {Timestamp} (Context: {contextFormatted})");
        }