[KYUUBI #1699] Improve codahale metric

<!--
Thanks for sending a pull request!

Here are some tips for you:
  1. If this is your first time, please read our contributor guidelines: https://kyuubi.readthedocs.io/en/latest/community/contributions.html
  2. If the PR is related to an issue in https://github.com/apache/incubator-kyuubi/issues, add '[KYUUBI #XXXX]' in your PR title, e.g., '[KYUUBI #XXXX] Your PR title ...'.
  3. If the PR is unfinished, add '[WIP]' in your PR title, e.g., '[WIP][KYUUBI #XXXX] Your PR title ...'.
-->

### _Why are the changes needed?_
<!--
Please clarify why the changes are needed. For instance,
  1. If you add a feature, you can talk about the use case of it.
  2. If you fix a bug, you can clarify why it is a bug.
-->
Improve the codahale metric registered in MetricsSystem.

### _How was this patch tested?_
- [ ] Add some test cases that check the changes thoroughly including negative and positive cases if possible

- [x] Add screenshots for manual tests if appropriate

Before:
![Screenshot from 2022-01-17 18-50-32](https://user-images.githubusercontent.com/29809822/149756433-d318bc9c-c884-4194-a92b-f90b803dc15f.png)

After:
![Screenshot from 2022-01-17 18-52-47](https://user-images.githubusercontent.com/29809822/149756710-6d77f283-0bcc-4b8e-9a78-9716e0c5c697.png)

- [x] [Run test](https://kyuubi.readthedocs.io/en/latest/develop_tools/testing.html#running-tests) locally before make a pull request

Closes #1782 from zhenjiaguo/improve_codahale_metric.

Closes #1699

73ac95be [zhenjiaguo] improve codahale metric

Authored-by: zhenjiaguo <zhenjiaguo@gmail.com>
Signed-off-by: Kent Yao <yao@apache.org>
This commit is contained in:
zhenjiaguo 2022-01-19 11:20:15 +08:00 committed by Kent Yao
parent 53bbbb7161
commit 7ef612cdea
No known key found for this signature in database
GPG Key ID: F7051850A0AF904D
2 changed files with 13 additions and 4 deletions

View File

@ -21,6 +21,12 @@ object MetricsConstants {
final private val KYUUBI = "kyuubi."
final val GC_METRIC: String = KYUUBI + "gc"
final val MEMORY_USAGE: String = KYUUBI + "memory_usage"
final val BUFFER_POOL: String = KYUUBI + "buffer_pool"
final val THREAD_STATE: String = KYUUBI + "thread_state"
final val CLASS_LOADING: String = KYUUBI + "class_loading"
final val EXEC_POOL_ALIVE: String = KYUUBI + "exec.pool.threads.alive"
final val EXEC_POOL_ACTIVE: String = KYUUBI + "exec.pool.threads.active"

View File

@ -67,10 +67,13 @@ class MetricsSystem extends CompositeService("MetricsSystem") {
}
override def initialize(conf: KyuubiConf): Unit = synchronized {
registry.registerAll(new GarbageCollectorMetricSet)
registry.registerAll(new MemoryUsageGaugeSet)
registry.registerAll(new BufferPoolMetricSet(ManagementFactory.getPlatformMBeanServer))
registry.registerAll(new ThreadStatesGaugeSet)
registry.registerAll(MetricsConstants.GC_METRIC, new GarbageCollectorMetricSet)
registry.registerAll(MetricsConstants.MEMORY_USAGE, new MemoryUsageGaugeSet)
registry.registerAll(
MetricsConstants.BUFFER_POOL,
new BufferPoolMetricSet(ManagementFactory.getPlatformMBeanServer))
registry.registerAll(MetricsConstants.THREAD_STATE, new ThreadStatesGaugeSet)
registry.registerAll(MetricsConstants.CLASS_LOADING, new ClassLoadingGaugeSet)
conf.get(METRICS_REPORTERS).map(ReporterType.withName).foreach {
case JSON => addService(new JsonReporterService(registry))