pingtimeout commented on code in PR #2887: URL: https://github.com/apache/polaris/pull/2887#discussion_r2485873415
########## runtime/service/src/main/java/org/apache/polaris/service/reporting/DefaultMetricsReporter.java: ########## @@ -0,0 +1,52 @@ +/* + * 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.polaris.service.reporting; + +import com.google.common.annotations.VisibleForTesting; +import io.smallrye.common.annotation.Identifier; +import jakarta.enterprise.context.RequestScoped; +import org.apache.commons.lang3.function.TriConsumer; +import org.apache.iceberg.catalog.TableIdentifier; +import org.apache.iceberg.metrics.MetricsReport; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +@RequestScoped +@Identifier("default") +public class DefaultMetricsReporter implements PolarisMetricsReporter { + private static final Logger LOGGER = LoggerFactory.getLogger(DefaultMetricsReporter.class); + + private final TriConsumer<String, TableIdentifier, MetricsReport> reportConsumer; + + public DefaultMetricsReporter() { + this( + (catalogName, table, metricsReport) -> + LOGGER.info("{}.{}: {}", catalogName, table, metricsReport)); Review Comment: @snazy note that by default the log level for this package is set to `OFF`. So what this code will do is perform a boolean check every time and return. That being said, I would also prefer to have a `no-op` implementation as well as this `logging` implementation and have the `polaris.iceberg-metrics.reporting.type` config parameter be very explicit on which one is picked, instead of relying on logging configuration to achieve the same goal. ########## runtime/service/src/main/java/org/apache/polaris/service/reporting/DefaultMetricsReporter.java: ########## @@ -0,0 +1,52 @@ +/* + * 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.polaris.service.reporting; + +import com.google.common.annotations.VisibleForTesting; +import io.smallrye.common.annotation.Identifier; +import jakarta.enterprise.context.RequestScoped; +import org.apache.commons.lang3.function.TriConsumer; +import org.apache.iceberg.catalog.TableIdentifier; +import org.apache.iceberg.metrics.MetricsReport; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +@RequestScoped +@Identifier("default") Review Comment: Would it be possible to use another name than `default` here? This currently results in the configuration file saying "The default value for polaris.iceberg-metrics.reporting.type is `default`", which does not give any meaningful information. This class could probably be named `LoggingMetricsReporter` and have a `logging` identifier. Then as @snazy suggests, there could be a `no-op` reporter that does nothing. -- 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: [email protected] For queries about this service, please contact Infrastructure at: [email protected]
