-
Notifications
You must be signed in to change notification settings - Fork 374
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[CELEBORN-1122] Metrics supports json format #2089
Conversation
Codecov ReportAttention:
Additional details and impacted files@@ Coverage Diff @@
## main #2089 +/- ##
==========================================
- Coverage 47.13% 46.22% -0.91%
==========================================
Files 173 175 +2
Lines 11034 11336 +302
Branches 1011 1016 +5
==========================================
+ Hits 5200 5239 +39
- Misses 5494 5757 +263
Partials 340 340 ☔ View full report in Codecov by Sentry. |
sources.asScala, | ||
jsonServletPath).asInstanceOf[JsonServlet]) | ||
} | ||
if (kv._1 == "prometheusServlet") { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: else if
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: else if
@RexXiong Thank you for your suggestion.
common/src/main/scala/org/apache/celeborn/common/metrics/sink/JsonServlet.scala
Outdated
Show resolved
Hide resolved
|
||
private def updateInnerMetrics(absSource: AbstractSource, metricData: MetricData): Unit = { | ||
innerMetrics.synchronized { | ||
if (innerMetrics.size() >= absSource.metricsCapacity) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if condition meet, can we directly return? as remove and add new metricData seems useless
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if condition meet, can we directly return? as remove and add new metricData seems useless
@RexXiong Thank you for your suggestion. I have resubmitted, please help me review it again.
|
||
import com.codahale.metrics.MetricRegistry | ||
import io.netty.channel.ChannelHandler.Sharable | ||
import org.apache.hadoop.shaded.com.fasterxml.jackson.annotation.JsonAutoDetect.Visibility |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I have no other comments on this pr except this import as it from shaded dependency, WDYT @waitinfuture @pan3793 @FMX @cfmcgrady
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I have no other comments on this pr except this import as it from shaded dependency, WDYT @waitinfuture @pan3793 @FMX @cfmcgrady
@RexXiong Thank you for your suggestion. I reimport the jackson package,and the version from hadoop 3.2.4.
pom.xml
Outdated
@@ -96,6 +96,8 @@ | |||
<zstd-jni.version>1.5.2-1</zstd-jni.version> | |||
<kubernetes-client.version>6.7.0</kubernetes-client.version> | |||
<rocksdbjni.version>8.5.3</rocksdbjni.version> | |||
<jackson.version>2.10.5</jackson.version> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why choose such a low version
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why choose such a low version
@pan3793
The version of org.apache.hadoop.shaded.*.jackson
comes from Hadoop 3.2.4 now. In order to reduce its impact on the original framework. I directly import the jackson 2.10.5 from Hadoop 3.2.4.
please update the LICENSE and NOTICE since it introduces the new dependencies, also, fix sbt building system |
4ce6f37
to
bb084cc
Compare
@pan3793 Thank you. I have updated newer version , and fixed sbt building system. Please help me review it again. |
project/CelebornBuild.scala
Outdated
@@ -56,6 +56,8 @@ object Dependencies { | |||
val ratisVersion = "2.5.1" | |||
val roaringBitmapVersion = "0.9.32" | |||
val rocksdbJniVersion = "8.5.3" | |||
val jacksonVersion = "2.15.3" | |||
val paranamerVersion = "2.8" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
seems we don't need to manage paranamerVersion
explicitly, let's simply delegate it to jackson
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
seems we don't need to manage
paranamerVersion
explicitly, let's simply delegate it to jackson
Thank you. I remove it.
import org.apache.celeborn.common.metrics.source.{AbstractSource, NamedCounter, NamedGauge, NamedHistogram, NamedTimer, Source} | ||
|
||
object JsonConverter { | ||
val mapper = new ObjectMapper() with ClassTagExtensions |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I guess user may preview the json using browser, maybe we can print the pretty json string.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I guess user may preview the json using browser, maybe we can print the pretty json string.
@pan3793
Thank you. For users, they may preview the json using browser, but for metrics collection, we prefer to use a compact format. I can add the celeborn.metrics.json.pretty.enabled
to control whether to enable pretty and default value true
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
configurable SGTM, though I think the overhead is quite nit
val servletHttpRequestHandler = servletHttpRequestHandlers.find(servlet => | ||
uri == servlet.getServletPath()) | ||
if (servletHttpRequestHandler.nonEmpty) { | ||
servletHttpRequestHandler.get.handleRequest(uri) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
should we update it for JSON?
res.headers().set(HttpHeaderNames.CONTENT_TYPE, "text/plain; charset=UTF-8")
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
should we update it for JSON?
res.headers().set(HttpHeaderNames.CONTENT_TYPE, "text/plain; charset=UTF-8")
Thank you. You are right. I update it.
common/src/main/scala/org/apache/celeborn/common/metrics/MetricsSystem.scala
Outdated
Show resolved
Hide resolved
b6b3685
to
381b8ba
Compare
mapper.writeValueAsString(value) | ||
} | ||
|
||
def toJsonWithPretty(value: ArrayBuffer[Any]): String = { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
def toJsonWithPretty(value: ArrayBuffer[Any]): String = { | |
def toPrettyJson(value: Any): String = { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you. I update it.
val mapper = new ObjectMapper() with ClassTagExtensions | ||
mapper.registerModule(DefaultScalaModule) | ||
|
||
def toJson(value: ArrayBuffer[Any]): String = { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
def toJson(value: ArrayBuffer[Any]): String = { | |
def toJson(value: Any): String = { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you. I update it.
com.fasterxml.jackson.module:jackson-module-scala | ||
com.fasterxml.jackson.core:jackson-databind | ||
com.fasterxml.jackson.core:jackson-annotations | ||
com.fasterxml.jackson.core:jackson-core |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LICENSE-binary reflects the final content of the binary release tarball, so the paranamer should be retained here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LICENSE-binary reflects the final content of the binary release tarball, so the parameter should be retained here.
what is the parameter
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
sorry, the paranamer
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
sorry, the paranamer
I have added it. Please review it again.
hadoop-client-api/3.3.6//hadoop-client-api-3.3.6.jar | ||
hadoop-client-runtime/3.3.6//hadoop-client-runtime-3.3.6.jar | ||
guava/14.0.1//guava-14.0.1.jar | ||
hadoop-client-api/3.2.4//hadoop-client-api-3.2.4.jar |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
please rebase master and regenerate this files
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you. I update it.
47956ed
to
1d9caba
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, cc @pan3793 @cfmcgrady
@@ -47,21 +47,34 @@ class HttpRequestHandler( | |||
val uri = req.uri() | |||
val (path, parameters) = HttpUtils.parseUri(uri) | |||
val msg = HttpUtils.handleRequest(service, path, parameters) | |||
val response = msg match { | |||
val textType = "text/plain; charset=UTF-8" | |||
val jsonType = "application/json; charset=UTF-8" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
val jsonType = "application/json; charset=UTF-8" | |
val jsonType = "application/json" |
https://www.rfc-editor.org/rfc/rfc8259.html
Note: No "charset" parameter is defined for this registration.
Adding one really has no effect on compliant recipients.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks. I update it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, except for one minor thing
1d9caba
to
c4c1a2d
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, except a nit
val servletHttpRequestHandler = servletHttpRequestHandlers.find(servlet => | ||
uri == servlet.getServletPath()) | ||
servletHttpRequestHandler match { | ||
case Some(handler) => handler match { | ||
case jsonHandler: JsonHttpRequestHandler => | ||
(jsonHandler.handleRequest(uri), jsonType) | ||
case _ => (handler.handleRequest(uri), textType) | ||
} | ||
case _ => (s"Unknown path $uri!", textType) | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit
val servletHttpRequestHandler = servletHttpRequestHandlers.find(servlet => | |
uri == servlet.getServletPath()) | |
servletHttpRequestHandler match { | |
case Some(handler) => handler match { | |
case jsonHandler: JsonHttpRequestHandler => | |
(jsonHandler.handleRequest(uri), jsonType) | |
case _ => (handler.handleRequest(uri), textType) | |
} | |
case _ => (s"Unknown path $uri!", textType) | |
} | |
servletHttpRequestHandlers.find(servlet => uri == servlet.getServletPath()) | |
.map { | |
case jsonHandler: JsonHttpRequestHandler => | |
(jsonHandler.handleRequest(uri), jsonType) | |
case handler: ServletHttpRequestHandler => | |
(handler.handleRequest(uri), textType) | |
}.getOrElse((s"Unknown path $uri!", textType)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks. I update it.
c4c1a2d
to
af01170
Compare
Thank you all @suizhe007 @pan3793 @cfmcgrady, merge to main(v0.4.0) |
What changes were proposed in this pull request?
If the user does not use prometheus to collect monitoring metrics, but rather some other ones. Using metrics in JSON format would be more user-friendly.The PR supports JSON format for metrics.
Why are the changes needed?
Ditto.
Does this PR introduce any user-facing change?
Metrics supports JSON format
How was this patch tested?
Cluster test.