You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@celeborn.apache.org by GitBox <gi...@apache.org> on 2023/01/18 09:14:29 UTC
[GitHub] [incubator-celeborn] AngersZhuuuu commented on a diff in pull request #1173: [CELEBORN-229][FEATURE] Support collect metrics with customized labels
AngersZhuuuu commented on code in PR #1173:
URL: https://github.com/apache/incubator-celeborn/pull/1173#discussion_r1073274224
##########
common/src/main/scala/org/apache/celeborn/common/metrics/source/AbstractSource.scala:
##########
@@ -300,7 +314,14 @@ abstract class AbstractSource(conf: CelebornConf, role: String)
BigDecimal(value / 1000000).setScale(2, BigDecimal.RoundingMode.HALF_UP).toDouble
}
- val label = s"""{role="$role"}"""
+ def getLabels(metricLabels: Map[String, String]): String = {
+ val sb = new StringBuilder()
+ sb.append("{")
+ metricLabels.foldLeft(sb.append(s"""role="$role""""))((_, entry) =>
+ sb.append(s""" ${entry._1}="${entry._2}""""))
+ sb.append("}")
+ sb.toString()
Review Comment:
```
metricLabels.map { case (key, value) => s""${key}="${value}"""" }.mkString(" ")
```
##########
common/src/main/scala/org/apache/celeborn/common/metrics/source/AbstractSource.scala:
##########
@@ -30,13 +30,20 @@ import org.apache.celeborn.common.internal.Logging
import org.apache.celeborn.common.metrics.{ResettableSlidingWindowReservoir, RssHistogram, RssTimer}
import org.apache.celeborn.common.util.{ThreadUtils, Utils}
-case class NamedCounter(name: String, counter: Counter)
+private[source] trait MetricLabels {
+ val labels: Map[String, String]
Review Comment:
```
def labelString = xxx
```
##########
common/src/main/scala/org/apache/celeborn/common/metrics/source/AbstractSource.scala:
##########
@@ -60,29 +67,32 @@ abstract class AbstractSource(conf: CelebornConf, role: String)
protected val namedGauges: java.util.List[NamedGauge[_]] =
new java.util.ArrayList[NamedGauge[_]]()
- def addGauge[T](name: String, f: Unit => T): Unit = {
+ def addGauge[T](
+ name: String,
+ f: Unit => T,
+ labels: Map[String, String] = Map.empty[String, String]): Unit = {
val supplier: MetricRegistry.MetricSupplier[Gauge[_]] = new GaugeSupplier[T](f)
val gauge = metricRegistry.gauge(name, supplier)
- namedGauges.add(NamedGauge(name, gauge))
+ namedGauges.add(NamedGauge(name, gauge, labels))
}
Review Comment:
Maybe we can support both
```
def addGauge[T](name: String, f: Unit => T): Unit = { .... }
```
and
```
def addGauge[T](
name: String,
f: Unit => T,
labels: Map[String, String]): Unit = {
......
}
```
##########
common/src/main/scala/org/apache/celeborn/common/metrics/source/AbstractSource.scala:
##########
@@ -60,29 +67,32 @@ abstract class AbstractSource(conf: CelebornConf, role: String)
protected val namedGauges: java.util.List[NamedGauge[_]] =
new java.util.ArrayList[NamedGauge[_]]()
- def addGauge[T](name: String, f: Unit => T): Unit = {
+ def addGauge[T](
+ name: String,
+ f: Unit => T,
+ labels: Map[String, String] = Map.empty[String, String]): Unit = {
val supplier: MetricRegistry.MetricSupplier[Gauge[_]] = new GaugeSupplier[T](f)
val gauge = metricRegistry.gauge(name, supplier)
- namedGauges.add(NamedGauge(name, gauge))
+ namedGauges.add(NamedGauge(name, gauge, labels))
}
Review Comment:
namedGauges.add(NamedGauge(name, gauge, labels + "role" -> role))
--
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-unsubscribe@celeborn.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org