File tree Expand file tree Collapse file tree 1 file changed +16
-9
lines changed
sdk/metrics/src/main/java/io/opentelemetry/sdk/metrics/internal/state Expand file tree Collapse file tree 1 file changed +16
-9
lines changed Original file line number Diff line number Diff line change @@ -161,16 +161,23 @@ private Attributes validateAndProcessAttributes(Attributes attributes) {
161161 attributes = attributesProcessor .process (attributes , context );
162162
163163 if (aggregatorHandles .size () >= maxCardinality ) {
164- throttlingLogger .log (
165- Level .WARNING ,
166- "Instrument "
167- + metricDescriptor .getSourceInstrument ().getName ()
168- + " has exceeded the maximum allowed cardinality ("
169- + maxCardinality
170- + ")." );
171- return MetricStorage .CARDINALITY_OVERFLOW ;
164+ aggregatorHandles .forEach (
165+ (attr , handle ) -> {
166+ if (!handle .hasRecordedValues ()) {
167+ aggregatorHandles .remove (attr );
168+ }
169+ });
170+ if (aggregatorHandles .size () >= maxCardinality ) {
171+ throttlingLogger .log (
172+ Level .WARNING ,
173+ "Instrument "
174+ + metricDescriptor .getSourceInstrument ().getName ()
175+ + " has exceeded the maximum allowed cardinality ("
176+ + maxCardinality
177+ + ")." );
178+ return MetricStorage .CARDINALITY_OVERFLOW ;
179+ }
172180 }
173-
174181 return attributes ;
175182 }
176183
You can’t perform that action at this time.
0 commit comments