@@ -22,13 +22,11 @@ internal sealed class AggregatorStore
2222 internal readonly bool OutputDelta ;
2323 internal readonly bool OutputDeltaWithUnusedMetricPointReclaimEnabled ;
2424 internal readonly int NumberOfMetricPoints ;
25- internal readonly bool EmitOverflowAttribute ;
2625 internal readonly ConcurrentDictionary < Tags , LookupData > ? TagsToMetricPointIndexDictionaryDelta ;
2726 internal readonly Func < ExemplarReservoir ? > ? ExemplarReservoirFactory ;
2827 internal long DroppedMeasurements = 0 ;
2928
3029 private const ExemplarFilterType DefaultExemplarFilter = ExemplarFilterType . AlwaysOff ;
31- private static readonly string MetricPointCapHitFixMessage = "Consider opting in for the experimental SDK feature to emit all the throttled metrics under the overflow attribute by setting env variable OTEL_DOTNET_EXPERIMENTAL_METRICS_EMIT_OVERFLOW_ATTRIBUTE = true. You could also 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." ;
3230 private static readonly Comparison < KeyValuePair < string , object ? > > DimensionComparisonDelegate = ( x , y ) => x . Key . CompareTo ( y . Key ) ;
3331
3432 private readonly Lock lockZeroTags = new ( ) ;
@@ -42,7 +40,6 @@ internal sealed class AggregatorStore
4240 new ( ) ;
4341
4442 private readonly string name ;
45- private readonly string metricPointCapHitMessage ;
4643 private readonly MetricPoint [ ] metricPoints ;
4744 private readonly int [ ] currentMetricPointBatch ;
4845 private readonly AggregationType aggType ;
@@ -56,7 +53,6 @@ internal sealed class AggregatorStore
5653
5754 private int metricPointIndex = 0 ;
5855 private int batchSize = 0 ;
59- private int metricCapHitMessageLogged ;
6056 private bool zeroTagMetricPointInitialized ;
6157 private bool overflowTagMetricPointInitialized ;
6258
@@ -65,7 +61,6 @@ internal AggregatorStore(
6561 AggregationType aggType ,
6662 AggregationTemporality temporality ,
6763 int cardinalityLimit ,
68- bool emitOverflowAttribute ,
6964 bool shouldReclaimUnusedMetricPoints ,
7065 ExemplarFilterType ? exemplarFilter = null ,
7166 Func < ExemplarReservoir ? > ? exemplarReservoirFactory = null )
@@ -77,7 +72,6 @@ internal AggregatorStore(
7772 // Previously, these were included within the original cardinalityLimit, but now they are explicitly added to enhance clarity.
7873 this . NumberOfMetricPoints = cardinalityLimit + 2 ;
7974
80- this . metricPointCapHitMessage = $ "Maximum MetricPoints limit reached for this Metric stream. Configured limit: { cardinalityLimit } ";
8175 this . metricPoints = new MetricPoint [ this . NumberOfMetricPoints ] ;
8276 this . currentMetricPointBatch = new int [ this . NumberOfMetricPoints ] ;
8377 this . aggType = aggType ;
@@ -105,8 +99,6 @@ internal AggregatorStore(
10599 this . tagsKeysInterestingCount = hs . Count ;
106100 }
107101
108- this . EmitOverflowAttribute = emitOverflowAttribute ;
109-
110102 this . exemplarFilter = exemplarFilter ?? DefaultExemplarFilter ;
111103 Debug . Assert (
112104 this . exemplarFilter == ExemplarFilterType . AlwaysOff
@@ -245,17 +237,14 @@ internal void SnapshotDeltaWithMetricPointReclaim()
245237 this . batchSize ++ ;
246238 }
247239
248- if ( this . EmitOverflowAttribute )
240+ // TakeSnapshot for the MetricPoint for overflow
241+ ref var metricPointForOverflow = ref this . metricPoints [ 1 ] ;
242+ if ( metricPointForOverflow . MetricPointStatus != MetricPointStatus . NoCollectPending )
249243 {
250- // TakeSnapshot for the MetricPoint for overflow
251- ref var metricPointForOverflow = ref this . metricPoints [ 1 ] ;
252- if ( metricPointForOverflow . MetricPointStatus != MetricPointStatus . NoCollectPending )
253- {
254- this . TakeMetricPointSnapshot ( ref metricPointForOverflow , outputDelta : true ) ;
244+ this . TakeMetricPointSnapshot ( ref metricPointForOverflow , outputDelta : true ) ;
255245
256- this . currentMetricPointBatch [ this . batchSize ] = 1 ;
257- this . batchSize ++ ;
258- }
246+ this . currentMetricPointBatch [ this . batchSize ] = 1 ;
247+ this . batchSize ++ ;
259248 }
260249
261250 // Index 0 and 1 are reserved for no tags and overflow
@@ -994,16 +983,8 @@ private void UpdateLongMetricPoint(int metricPointIndex, long value, ReadOnlySpa
994983 if ( metricPointIndex < 0 )
995984 {
996985 Interlocked . Increment ( ref this . DroppedMeasurements ) ;
997-
998- if ( this . EmitOverflowAttribute )
999- {
1000- this . InitializeOverflowTagPointIfNotInitialized ( ) ;
1001- this . metricPoints [ 1 ] . Update ( value ) ;
1002- }
1003- else if ( Interlocked . CompareExchange ( ref this . metricCapHitMessageLogged , 1 , 0 ) == 0 )
1004- {
1005- OpenTelemetrySdkEventSource . Log . MeasurementDropped ( this . name , this . metricPointCapHitMessage , MetricPointCapHitFixMessage ) ;
1006- }
986+ this . InitializeOverflowTagPointIfNotInitialized ( ) ;
987+ this . metricPoints [ 1 ] . Update ( value ) ;
1007988
1008989 return ;
1009990 }
@@ -1049,16 +1030,8 @@ private void UpdateDoubleMetricPoint(int metricPointIndex, double value, ReadOnl
10491030 if ( metricPointIndex < 0 )
10501031 {
10511032 Interlocked . Increment ( ref this . DroppedMeasurements ) ;
1052-
1053- if ( this . EmitOverflowAttribute )
1054- {
1055- this . InitializeOverflowTagPointIfNotInitialized ( ) ;
1056- this . metricPoints [ 1 ] . Update ( value ) ;
1057- }
1058- else if ( Interlocked . CompareExchange ( ref this . metricCapHitMessageLogged , 1 , 0 ) == 0 )
1059- {
1060- OpenTelemetrySdkEventSource . Log . MeasurementDropped ( this . name , this . metricPointCapHitMessage , MetricPointCapHitFixMessage ) ;
1061- }
1033+ this . InitializeOverflowTagPointIfNotInitialized ( ) ;
1034+ this . metricPoints [ 1 ] . Update ( value ) ;
10621035
10631036 return ;
10641037 }
0 commit comments