@@ -98,8 +98,15 @@ private void compareMetricLists(List<Metric> toBeCheckedMetricList, List<Metric>
9898 // sort and check dimensions
9999 List <Dimension > dimensionList1 = o1 .getDimensions ();
100100 List <Dimension > dimensionList2 = o2 .getDimensions ();
101+
102+ // remove the skipped dimension
103+ dimensionList1 .removeIf ( dimension -> dimension .getValue ().equals ("SKIP" ));
104+ dimensionList2 .removeIf ( dimension -> dimension .getValue ().equals ("SKIP" ));
105+
106+ // sort
101107 dimensionList1 .sort (Comparator .comparing (Dimension ::getName ));
102108 dimensionList2 .sort (Comparator .comparing (Dimension ::getName ));
109+
103110 return dimensionList1 .toString ().compareTo (dimensionList2 .toString ());
104111 });
105112 for (Metric metric : baseMetricList ) {
@@ -158,40 +165,54 @@ private List<Metric> rollupMetric(List<Metric> metricList) {
158165 for (Metric metric : metricList ) {
159166 // get otellib dimension out
160167 // assuming the first dimension is otellib, if not the validation fails
161- Dimension otellibDimension = metric .getDimensions ().remove (0 );
162- assert otellibDimension .getName ().equals (DEFAULT_DIMENSION_NAME );
168+ Dimension otellibDimension = metric .getDimensions ().get (0 );
169+ boolean otelLibDimensionExisted = otellibDimension .getName ().equals (DEFAULT_DIMENSION_NAME );
170+ if (otelLibDimensionExisted ) {
171+ metric .getDimensions ().remove (0 );
172+ }
163173
164174 // all dimension rollup
165175 Metric allDimensionsMetric = new Metric ();
166176 allDimensionsMetric .setMetricName (metric .getMetricName ());
167177 allDimensionsMetric .setNamespace (metric .getNamespace ());
168178 allDimensionsMetric .setDimensions (metric .getDimensions ());
169- allDimensionsMetric
170- .getDimensions ()
171- .add (new Dimension ()
172- .withName (otellibDimension .getName ()).withValue (otellibDimension .getValue ()));
179+
180+ if (otelLibDimensionExisted ) {
181+ allDimensionsMetric
182+ .getDimensions ()
183+ .add (
184+ new Dimension ()
185+ .withName (otellibDimension .getName ())
186+ .withValue (otellibDimension .getValue ()));
187+ }
173188 rollupMetricList .add (allDimensionsMetric );
174189
175190 // zero dimension rollup
176191 Metric zeroDimensionMetric = new Metric ();
177192 zeroDimensionMetric .setNamespace (metric .getNamespace ());
178193 zeroDimensionMetric .setMetricName (metric .getMetricName ());
179- zeroDimensionMetric .setDimensions (
180- Arrays .asList (
181- new Dimension ()
182- .withName (otellibDimension .getName ()).withValue (otellibDimension .getValue ())));
194+
195+ if (otelLibDimensionExisted ) {
196+ zeroDimensionMetric .setDimensions (
197+ Arrays .asList (
198+ new Dimension ()
199+ .withName (otellibDimension .getName ())
200+ .withValue (otellibDimension .getValue ())));
201+ }
183202 rollupMetricList .add (zeroDimensionMetric );
184203
185204 // single dimension rollup
186205 for (Dimension dimension : metric .getDimensions ()) {
187206 Metric singleDimensionMetric = new Metric ();
188207 singleDimensionMetric .setNamespace (metric .getNamespace ());
189208 singleDimensionMetric .setMetricName (metric .getMetricName ());
190- singleDimensionMetric .setDimensions (
191- Arrays .asList (
192- new Dimension ()
193- .withName (otellibDimension .getName ())
194- .withValue (otellibDimension .getValue ())));
209+ if (otelLibDimensionExisted ) {
210+ singleDimensionMetric .setDimensions (
211+ Arrays .asList (
212+ new Dimension ()
213+ .withName (otellibDimension .getName ())
214+ .withValue (otellibDimension .getValue ())));
215+ }
195216 singleDimensionMetric .getDimensions ().add (dimension );
196217 rollupMetricList .add (singleDimensionMetric );
197218 }
0 commit comments