heesung-sn opened a new pull request, #15692:
URL: https://github.com/apache/pulsar/pull/15692

   <!--
   ### Contribution Checklist
     
     - PR title format should be *[type][component] summary*. For details, see 
*[Guideline - Pulsar PR Naming 
Convention](https://docs.google.com/document/d/1d8Pw6ZbWk-_pCKdOmdvx9rnhPiyuxwq60_TrD68d7BA/edit#heading=h.trs9rsex3xom)*.
 
   
     - Fill out the template below to describe the changes contributed by the 
pull request. That will give reviewers the context they need to do the review.
     
     - Each pull request should address only one issue, not mix up code from 
multiple issues.
     
     - Each commit in the pull request has a meaningful commit message
   
     - Once all items of the checklist are addressed, remove the above text and 
this checklist, leaving only the filled out template below.
   
   **(The sections below can be removed for hotfixes of typos)**
   -->
   
   
   
   ### Motivation
   
   We have the following error from websocket service when running different 
GCs other than G1GC. This is because websocket uses its own 
`org.apache.pulsar.websocket.stats.JvmMetrics`  class, which always looks up 
G1GC stats, regardless of the runtime GC. I think we can replace this 
duplicated `org.apache.pulsar.websocket.stats.JvmMetrics` with the common one 
`org.apache.pulsar.common.stats.JvmMetrics`, which supports different GC 
metrics.
   ```
   2022-05-20T10:54:29,322-0700 [pulsar-websocket-57-2] ERROR 
org.apache.pulsar.websocket.stats.JvmMetrics - Failed to collect GC stats: 
java.lang:type=GarbageCollector,name=G1 Young Generation
   ```
   ### Modifications
   
   - Removed  `org.apache.pulsar.websocket.stats.JvmMetrics` 
   - Replaced `org.apache.pulsar.websocket.stats.JvmMetrics`  dependency with  
`org.apache.pulsar.common.stats.JvmMetrics`  in `ProxyStats`.
   
   #### Behavior changes
   Before
   
   ```
   ### when running websocket on G1GC
   curl http://localhost:8080/admin/v2/proxy-stats/metrics/
   [{"metrics":{
   "jvm_gc_old_count":0,
   "jvm_gc_old_pause":0,
   "jvm_gc_young_count":0,
   "jvm_gc_young_pause":0,
   "jvm_heap_used":52622168,
   "jvm_max_direct_memory":4294967296,
   "jvm_max_memory":2147483648,
   "jvm_thread_cnt":24,
   "jvm_total_memory":2147483648},
   "dimensions":{"system":"jvm"}}]
   
   
   ### when running websocket on ZGC
   websocket.stats.JvmMetrics constantly fails to collect G1GC metrics and 
throws the error.
   
   2022-05-20T15:26:00,499-0700 [pulsar-websocket-2-1] ERROR 
org.apache.pulsar.websocket.stats.JvmMetrics - Failed to collect GC stats: 
java.lang:type=GarbageCollector,name=G1 Young Generation
   ...
   
   curl http://localhost:8080/admin/v2/proxy-stats/metrics/
   [{"metrics":{
   "jvm_gc_old_count":0,
   "jvm_gc_old_pause":0,
   "jvm_gc_young_count":0,
   "jvm_gc_young_pause":0,
   "jvm_heap_used":117440512,
   "jvm_max_direct_memory":4294967296,
   "jvm_max_memory":2147483648,
   "jvm_thread_cnt":24,
   "jvm_total_memory":2147483648},
   "dimensions":{"system":"jvm"}}]
   
   ```
   
   After
   
   ```
   ### when running websocket on G1GC
   
   curl http://localhost:8080/admin/v2/proxy-stats/metrics/
   [{"metrics":{
   "jvm_direct_memory_used":0,
   "jvm_gc_old_count":0,
   "jvm_gc_old_pause":0,
   "jvm_gc_young_count":0,
   "jvm_gc_young_pause":0,
   "jvm_heap_used":58425032,
   "jvm_max_direct_memory":4294967296,
   "jvm_max_memory":2147483648,
   "jvm_thread_cnt":28,
   "jvm_total_memory":2147483648,
   "prx_default_pool_allocated":0,
   "prx_default_pool_used":0},
   "dimensions":{"metric":"jvm_metrics"}}]
   
   ### when running websocket on ZGC
   curl http://localhost:8080/admin/v2/proxy-stats/metrics/
   [{"metrics":{
   "jvm_ZGC Cycles_gc_count":0,
   "jvm_ZGC Cycles_gc_pause":0,
   "jvm_ZGC Pauses_gc_count":0,
   "jvm_ZGC Pauses_gc_pause":0,
   "jvm_direct_memory_used":0,
   "jvm_full_gc_count":1,
   "jvm_full_gc_pause":0,
   "jvm_heap_used":117440512,
   "jvm_max_direct_memory":4294967296,
   "jvm_max_memory":2147483648,
   "jvm_thread_cnt":24,
   "jvm_total_memory":2147483648,
   "prx_default_pool_allocated":0,
   "prx_default_pool_used":0},
   "dimensions":{"metric":"jvm_metrics"}}]
   
   ```
   
   ### Verifying this change
   
   - [x] Make sure that the change passes the CI checks.
   
   
   This change is a trivial rework / code cleanup without any test coverage.
   
   
   ### Does this pull request potentially affect one of the following parts:
   
   *If `yes` was chosen, please highlight the changes*
   
     - Dependencies (does it add or upgrade a dependency): (yes / **no**)
     - The public API: (yes / **no**)
     - The schema: (yes / **no** / don't know)
     - The default values of configurations: (yes / **no**)
     - The wire protocol: (yes / **no**)
     - The rest endpoints: (yes / **no**)
     - The admin cli options: (yes / **no**)
     - Anything that affects deployment: (yes / **no** / don't know)
   
   ### Documentation
   
   Check the box below or label this PR directly.
   
   Need to update docs? 
   
   - [ ] `doc-required` 
   (Your PR needs to update docs and you will update later)
     
   - [x ] `no-need-doc` 
   (Please explain why)
     
   - [ ] `doc` 
   (Your PR contains doc changes)
   
   - [ ] `doc-added`
   (Docs have been already added)


-- 
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]

Reply via email to