nastra commented on code in PR #5837: URL: https://github.com/apache/iceberg/pull/5837#discussion_r1050492924
########## api/src/main/java/org/apache/iceberg/metrics/MultiDimensionCounterKey.java: ########## @@ -0,0 +1,26 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.iceberg.metrics; + +// TODO gaborkaszab: comment +public interface MultiDimensionCounterKey { Review Comment: rather than calling this `MultiDimensionCounterKey` I think a better name would be `MetricTag`. Micrometer also uses tag(s) as a term for multiple dimensions. ########## api/src/main/java/org/apache/iceberg/metrics/MultiDimensionCounterKey.java: ########## @@ -0,0 +1,26 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.iceberg.metrics; + +// TODO gaborkaszab: comment +public interface MultiDimensionCounterKey { + String get(); + + int numDimensions(); Review Comment: I'm a bit confused why this method is needed ########## core/src/main/java/org/apache/iceberg/metrics/MultiDimensionCounterResultParser.java: ########## @@ -0,0 +1,95 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.iceberg.metrics; + +import com.fasterxml.jackson.core.JsonGenerator; +import com.fasterxml.jackson.databind.JsonNode; +import com.fasterxml.jackson.databind.node.ArrayNode; +import java.io.IOException; +import java.util.Iterator; +import java.util.Map; +import org.apache.iceberg.relocated.com.google.common.base.Preconditions; +import org.apache.iceberg.relocated.com.google.common.collect.Maps; +import org.apache.iceberg.util.JsonUtil; + +public class MultiDimensionCounterResultParser { + private static final String MISSING_FIELD_ERROR_MSG = + "Cannot parse counter from '%s': Missing field '%s'"; + private static final String UNIT = "unit"; + private static final String VALUE = "value"; + private static final String COUNTER_ID = "counter-id"; Review Comment: why do we use `counter-id`? Isn't this just a nested `CounterResult` where we can use `CounterResultParser` for ser/de? ########## core/src/main/java/org/apache/iceberg/metrics/MultiDimensionCounterResult.java: ########## @@ -0,0 +1,69 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.iceberg.metrics; + +import java.util.Map; +import org.apache.iceberg.metrics.MetricsContext.Unit; +import org.apache.iceberg.relocated.com.google.common.base.Preconditions; +import org.apache.iceberg.relocated.com.google.common.collect.Maps; +import org.immutables.value.Value; + +@Value.Immutable +public abstract class MultiDimensionCounterResult { + public abstract Map<String, Long> counterResults(); Review Comment: I would have expected this to be a `Map<String, CounterResult>` since a nested counter is still a valid counter. Also aren't we losing the unit of the counter that way? ########## api/src/main/java/org/apache/iceberg/metrics/MultiDimensionCounter.java: ########## @@ -0,0 +1,69 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.iceberg.metrics; + +import java.util.Set; +import org.apache.iceberg.metrics.MetricsContext.Unit; + +/** Generalized multi-dimension Counter interface. */ +public interface MultiDimensionCounter { + + /** Increment the counter under a given key by 1. */ + void increment(MultiDimensionCounterKey key); + + /** Increment the counter under a given key by the provided amount. */ + void increment(MultiDimensionCounterKey key, long amount); + + /** + * The name of the multi-dimension counter. + * + * @return The name of the multi-dimension counter. + */ + String name(); + + /** + * The keys used by this multi-dimension counter. + * + * @return The keys used by this multi-dimension counter. + */ + Set<String> keys(); Review Comment: I think a better name would be `metricTags()` -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: issues-unsubscr...@iceberg.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org --------------------------------------------------------------------- To unsubscribe, e-mail: issues-unsubscr...@iceberg.apache.org For additional commands, e-mail: issues-h...@iceberg.apache.org