You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@pinot.apache.org by GitBox <gi...@apache.org> on 2022/12/12 23:42:44 UTC

[GitHub] [pinot] jackjlli commented on a diff in pull request #9961: allow gauge stored in metric registry to be updated

jackjlli commented on code in PR #9961:
URL: https://github.com/apache/pinot/pull/9961#discussion_r1046498295


##########
pinot-plugins/pinot-metrics/pinot-yammer/src/main/java/org/apache/pinot/plugin/metrics/yammer/YammerSettableGauge.java:
##########
@@ -0,0 +1,41 @@
+/**
+ * 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.pinot.plugin.metrics.yammer;
+
+import com.yammer.metrics.core.Gauge;
+import java.util.function.Supplier;
+
+/**
+ * YammerSettableGauge extends {@link Gauge}, allowing setting a value supplier to provide the gauge value
+ *
+ * @param <T> the type of the metric's value
+ */
+public abstract class YammerSettableGauge<T> extends Gauge<T> {

Review Comment:
   Same here. We may not need an abstract class but more of an interface to specify the following two methods.



##########
pinot-spi/src/main/java/org/apache/pinot/spi/metrics/PinotGauge.java:
##########
@@ -36,10 +38,26 @@
 
   Object getGauge();
 
+  /**
+   * Sets the gauge value.
+   * @param value the gauge value to set.
+   */
+  default void setValue(T value) {
+    throw new RuntimeException("setValue is not implemented");
+  }
+
+  /**
+   * Sets the gauge value supplier.
+   * @param valueSupplier the gauge value supplier to set.
+   */
+  default void setValueSupplier(Supplier<T> valueSupplier) {

Review Comment:
   I wonder if it's possible to introduce a new interface that specifies the both setValue() and setValueSupplier() methods, and let this PinotGauge interface also extends the new interface you just created?



-- 
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: commits-unsubscribe@pinot.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@pinot.apache.org
For additional commands, e-mail: commits-help@pinot.apache.org