diff --git a/src/OpenTelemetry/Metrics/AggregatorStore.cs b/src/OpenTelemetry/Metrics/AggregatorStore.cs index c61f1a59273..d3e0842bb1a 100644 --- a/src/OpenTelemetry/Metrics/AggregatorStore.cs +++ b/src/OpenTelemetry/Metrics/AggregatorStore.cs @@ -25,6 +25,7 @@ namespace OpenTelemetry.Metrics { internal sealed class AggregatorStore { + private static readonly string MetricPointCapHitFixMessage = "Modify instrumentation to reduce the number of unique key/value pair combinations. Or use Views to drop unwanted tags. Or use MeterProviderBuilder.SetMaxMetricPointsPerMetricStream to set higher limit."; private readonly object lockZeroTags = new object(); private readonly HashSet tagKeysInteresting; private readonly int tagsKeysInterestingCount; @@ -309,7 +310,7 @@ private void UpdateLong(long value, ReadOnlySpan> t { if (Interlocked.CompareExchange(ref this.metricCapHitMessageLogged, 1, 0) == 0) { - OpenTelemetrySdkEventSource.Log.MeasurementDropped(this.name, this.metricPointCapHitMessage, "Modify instrumentation to reduce the number of unique key/value pair combinations. Or use MeterProviderBuilder.SetMaxMetricPointsPerMetricStream to set higher limit."); + OpenTelemetrySdkEventSource.Log.MeasurementDropped(this.name, this.metricPointCapHitMessage, MetricPointCapHitFixMessage); } return; @@ -332,7 +333,7 @@ private void UpdateLongCustomTags(long value, ReadOnlySpan + /// MetricReader implementation which exports metrics to the configured + /// MetricExporter upon . + /// public class BaseExportingMetricReader : MetricReader { protected readonly BaseExporter exporter; private readonly ExportModes supportedExportModes = ExportModes.Push | ExportModes.Pull; private bool disposed; + /// + /// Initializes a new instance of the class. + /// + /// Exporter instance to export Metrics to. public BaseExportingMetricReader(BaseExporter exporter) { Guard.ThrowIfNull(exporter); diff --git a/src/OpenTelemetry/Metrics/CompositeMetricReader.cs b/src/OpenTelemetry/Metrics/CompositeMetricReader.cs index b06339118f6..4b3b4cd69d6 100644 --- a/src/OpenTelemetry/Metrics/CompositeMetricReader.cs +++ b/src/OpenTelemetry/Metrics/CompositeMetricReader.cs @@ -141,10 +141,9 @@ protected override void Dispose(bool disposing) { cur.Value?.Dispose(); } - catch (Exception) + catch (Exception ex) { - // TODO: which event source do we use? - // OpenTelemetrySdkEventSource.Log.SpanProcessorException(nameof(this.Dispose), ex); + OpenTelemetrySdkEventSource.Log.MetricReaderException(nameof(this.Dispose), ex); } } } diff --git a/src/OpenTelemetry/Metrics/ExplicitBucketHistogramConfiguration.cs b/src/OpenTelemetry/Metrics/ExplicitBucketHistogramConfiguration.cs index 7ed4a0fadd2..1fa4f6f2e9d 100644 --- a/src/OpenTelemetry/Metrics/ExplicitBucketHistogramConfiguration.cs +++ b/src/OpenTelemetry/Metrics/ExplicitBucketHistogramConfiguration.cs @@ -24,6 +24,8 @@ public class ExplicitBucketHistogramConfiguration : MetricStreamConfiguration /// /// /// The array must be in ascending order with distinct values. + /// An empty array would result in no histogram buckets being calculated. + /// A null value would result in default bucket boundaries being used. /// public double[] Boundaries { get; set; } } diff --git a/src/OpenTelemetry/Metrics/Metric.cs b/src/OpenTelemetry/Metrics/Metric.cs index 983976d5e9e..5a567a06756 100644 --- a/src/OpenTelemetry/Metrics/Metric.cs +++ b/src/OpenTelemetry/Metrics/Metric.cs @@ -20,6 +20,9 @@ namespace OpenTelemetry.Metrics { + /// + /// Represents a Metric stream which can contain multiple MetricPoints. + /// public sealed class Metric { internal static readonly double[] DefaultHistogramBounds = new double[] { 0, 5, 10, 25, 50, 75, 100, 250, 500, 1000 }; diff --git a/src/OpenTelemetry/Metrics/MetricPoint.cs b/src/OpenTelemetry/Metrics/MetricPoint.cs index e91c1253ace..4d8ce31036e 100644 --- a/src/OpenTelemetry/Metrics/MetricPoint.cs +++ b/src/OpenTelemetry/Metrics/MetricPoint.cs @@ -22,7 +22,7 @@ namespace OpenTelemetry.Metrics { /// - /// Stores details about a metric data point. + /// Represents a metric data point. /// public struct MetricPoint { diff --git a/src/OpenTelemetry/Metrics/MetricReaderType.cs b/src/OpenTelemetry/Metrics/MetricReaderType.cs index 4c20574f552..2e8524b6ac8 100644 --- a/src/OpenTelemetry/Metrics/MetricReaderType.cs +++ b/src/OpenTelemetry/Metrics/MetricReaderType.cs @@ -28,7 +28,7 @@ public enum MetricReaderType Manual, /// - /// Use the . + /// Uses the . /// MetricReader.Collect() will be invoked on a defined interval. /// Periodic, diff --git a/src/OpenTelemetry/Metrics/MetricStreamConfiguration.cs b/src/OpenTelemetry/Metrics/MetricStreamConfiguration.cs index ccc68f56cac..df681be3c6b 100644 --- a/src/OpenTelemetry/Metrics/MetricStreamConfiguration.cs +++ b/src/OpenTelemetry/Metrics/MetricStreamConfiguration.cs @@ -28,6 +28,9 @@ internal enum Aggregation #pragma warning restore SA1602 // Enumeration items should be documented } + /// + /// Holds the configuration for a MetricStream. + /// public class MetricStreamConfiguration { public static readonly MetricStreamConfiguration Drop = new DropConfiguration(); @@ -40,7 +43,9 @@ public class MetricStreamConfiguration internal virtual Aggregation Aggregation { get; set; } - // TODO: MetricPoints caps can be configured here + // TODO: MetricPoints caps can be configured here on + // a per stream basis, when we add such a capability + // in the future. private sealed class DropConfiguration : MetricStreamConfiguration { diff --git a/src/OpenTelemetry/Metrics/PeriodicExportingMetricReader.cs b/src/OpenTelemetry/Metrics/PeriodicExportingMetricReader.cs index 8a4021f1095..dce43d6986e 100644 --- a/src/OpenTelemetry/Metrics/PeriodicExportingMetricReader.cs +++ b/src/OpenTelemetry/Metrics/PeriodicExportingMetricReader.cs @@ -21,6 +21,11 @@ namespace OpenTelemetry.Metrics { + /// + /// MetricReader implementation which collects metrics based on + /// a user-configurable time interval and passes the metrics to + /// the configured MetricExporter. + /// public class PeriodicExportingMetricReader : BaseExportingMetricReader { internal const int DefaultExportIntervalMilliseconds = 60000; @@ -33,6 +38,12 @@ public class PeriodicExportingMetricReader : BaseExportingMetricReader private readonly ManualResetEvent shutdownTrigger = new ManualResetEvent(false); private bool disposed; + /// + /// Initializes a new instance of the class. + /// + /// Exporter instance to export Metrics to. + /// The interval in milliseconds between two consecutive exports. The default value is 60000. + /// How long the export can run before it is cancelled. The default value is 30000. public PeriodicExportingMetricReader( BaseExporter exporter, int exportIntervalMilliseconds = DefaultExportIntervalMilliseconds, diff --git a/test/Benchmarks/Metrics/MetricsBenchmarks.cs b/test/Benchmarks/Metrics/MetricsBenchmarks.cs index 44266e6b6a1..13b1faf8e7f 100644 --- a/test/Benchmarks/Metrics/MetricsBenchmarks.cs +++ b/test/Benchmarks/Metrics/MetricsBenchmarks.cs @@ -20,7 +20,6 @@ using System.Diagnostics.Metrics; using BenchmarkDotNet.Attributes; using OpenTelemetry; -using OpenTelemetry.Exporter; using OpenTelemetry.Metrics; using OpenTelemetry.Tests; diff --git a/test/Benchmarks/Metrics/MetricsViewBenchmarks.cs b/test/Benchmarks/Metrics/MetricsViewBenchmarks.cs index e93f3cb9aa6..a21d69ef2ce 100644 --- a/test/Benchmarks/Metrics/MetricsViewBenchmarks.cs +++ b/test/Benchmarks/Metrics/MetricsViewBenchmarks.cs @@ -20,7 +20,6 @@ using System.Threading; using BenchmarkDotNet.Attributes; using OpenTelemetry; -using OpenTelemetry.Exporter; using OpenTelemetry.Metrics; using OpenTelemetry.Tests; diff --git a/test/OpenTelemetry.Tests/Metrics/MetricAPITest.cs b/test/OpenTelemetry.Tests/Metrics/MetricAPITest.cs index 9e29ad9b0d1..ba24ef84014 100644 --- a/test/OpenTelemetry.Tests/Metrics/MetricAPITest.cs +++ b/test/OpenTelemetry.Tests/Metrics/MetricAPITest.cs @@ -19,7 +19,6 @@ using System.Diagnostics; using System.Diagnostics.Metrics; using System.Threading; -using OpenTelemetry.Exporter; using OpenTelemetry.Tests; using Xunit; using Xunit.Abstractions;