Skip to content
Merged
Prev Previous commit
Next Next commit
comments
  • Loading branch information
Yun-Ting committed Feb 5, 2024
commit 0fa65a483fd83ad9d5b722cfa5199c2537aea73c
8 changes: 7 additions & 1 deletion src/OpenTelemetry/Metrics/MetricStreamConfiguration.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
// Copyright The OpenTelemetry Authors
// SPDX-License-Identifier: Apache-2.0

#if EXPOSE_EXPERIMENTAL_FEATURES && NET8_0_OR_GREATER
using System.Diagnostics.CodeAnalysis;
#endif
using OpenTelemetry.Internal;

namespace OpenTelemetry.Metrics;
Expand Down Expand Up @@ -106,6 +109,9 @@ public string[]? TagKeys
/// SetMaxMetricPointsPerMetricStream"/> to confiture the SDK defaults.
/// </remarks>
#if EXPOSE_EXPERIMENTAL_FEATURES
#if NET8_0_OR_GREATER
[Experimental(DiagnosticDefinitions.CardinalityLimitExperimentalApi, UrlFormat = DiagnosticDefinitions.ExperimentalApiUrlFormat)]
#endif
public
#else
internal
Expand All @@ -117,7 +123,7 @@ public string[]? TagKeys
{
if (value != null)
{
Guard.ThrowIfOutOfRange(value.Value, min: 3, max: int.MaxValue);
Guard.ThrowIfOutOfRange(value.Value, min: 1, max: int.MaxValue);
}

this.cardinalityLimit = value;
Expand Down
1 change: 1 addition & 0 deletions src/Shared/DiagnosticDefinitions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,5 @@ internal static class DiagnosticDefinitions
public const string LoggerProviderExperimentalApi = "OTEL1000";
public const string LogsBridgeExperimentalApi = "OTEL1001";
public const string ExemplarExperimentalApi = "OTEL1002";
public const string CardinalityLimitExperimentalApi = "OTEL1003";
}
4 changes: 2 additions & 2 deletions test/OpenTelemetry.Tests/Metrics/MetricViewTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -921,7 +921,7 @@ public void ViewConflict_OneInstrument_DifferentDescription()
}

[Fact]
public void MaxMetricPointsPerMetricStreamofMatchingViewTakesPrecedenceOverTheMetricReaderWhenBothWereSet()
public void CardinalityLimitofMatchingViewTakesPrecedenceOverMetricProviderWhenBothWereSet()
{
using var meter = new Meter(Utils.GetCurrentMethodName());
var exportedItems = new List<Metric>();
Expand Down Expand Up @@ -969,7 +969,7 @@ public void ViewConflict_TwoDistinctInstruments_ThreeStreams()
})
.AddView((instrument) =>
{
// This view is ignored as the passed in MaxMetricPointsPerMetricStream is out of range.
// This view is ignored as the passed in CardinalityLimit is out of range.
return new MetricStreamConfiguration() { Name = "MetricStreamD", CardinalityLimit = -1 };
})
.AddInMemoryExporter(exportedItems));
Expand Down