HenryCaiHaiying commented on code in PR #17025: URL: https://github.com/apache/iceberg/pull/17025#discussion_r3696499797
########## kafka-connect/kafka-connect/src/main/java/org/apache/iceberg/connect/channel/ChannelMetrics.java: ########## @@ -0,0 +1,163 @@ +/* + * 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.connect.channel; + +import java.util.Collections; +import java.util.LinkedHashMap; +import java.util.Map; +import java.util.function.Supplier; +import org.apache.kafka.common.MetricName; +import org.apache.kafka.common.metrics.Gauge; +import org.apache.kafka.common.metrics.JmxReporter; +import org.apache.kafka.common.metrics.KafkaMetricsContext; +import org.apache.kafka.common.metrics.MetricConfig; +import org.apache.kafka.common.metrics.Metrics; +import org.apache.kafka.common.metrics.Sensor; +import org.apache.kafka.common.metrics.stats.Avg; +import org.apache.kafka.common.metrics.stats.CumulativeCount; +import org.apache.kafka.common.metrics.stats.CumulativeSum; +import org.apache.kafka.common.metrics.stats.Max; +import org.apache.kafka.common.utils.Time; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +/** + * Base for the per-task/per-connector JMX metric registries. Owns the {@link Metrics} registry, the + * sensor-creation helpers shared by the worker and coordinator, and the two channel-level timers + * that every {@link Channel} feeds while draining the control topic. + */ +abstract class ChannelMetrics implements AutoCloseable { + + private static final Logger LOG = LoggerFactory.getLogger(ChannelMetrics.class); + + /** JMX domain; dotted to sit alongside Kafka's own {@code kafka.connect.*} beans in jconsole. */ + static final String NAMESPACE = "iceberg.kafka.connect"; + + private final Metrics metrics; + private final String group; + + private final Sensor messageReadTime; + private final Sensor messageProcessTime; + + ChannelMetrics(String group, String connector, String task) { + this.group = group; + this.metrics = + new Metrics( + new MetricConfig(), Review Comment: Good catch. But I don' think extend the sample window is useful here because 1. the customer can configure different commit interval; 2. the commit interval is not precise since there can be other code execution increase/decrease the commit interval; I don't want the sample window size coupled with the code execution logic. In fact, I don't think I need the Avg and Max Stat for the timerSensor, it measures the avg/max within the 30 second window, it's not very meaningful. I already have the '-total' and '-count' CumulativeSum stats which is not affected by the sample window size, the user can easily extrapolate the rate or sum from these 2 numbers. So I will just remove the Avg/Max stats from the timerSensor. -- 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] --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
