You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@kyuubi.apache.org by fe...@apache.org on 2022/11/03 03:29:28 UTC

[incubator-kyuubi] branch branch-1.6 updated: [KYUUBI #3748] Adding metrics kyuubi.metadata.request.opened and fix flaky test - MetadataManagerSuite

This is an automated email from the ASF dual-hosted git repository.

feiwang pushed a commit to branch branch-1.6
in repository https://gitbox.apache.org/repos/asf/incubator-kyuubi.git


The following commit(s) were added to refs/heads/branch-1.6 by this push:
     new 6f0f6e570 [KYUUBI #3748] Adding metrics kyuubi.metadata.request.opened and fix flaky test - MetadataManagerSuite
6f0f6e570 is described below

commit 6f0f6e570603080adbca939573d93a6e99876490
Author: Fei Wang <fw...@ebay.com>
AuthorDate: Thu Nov 3 11:29:11 2022 +0800

    [KYUUBI #3748] Adding metrics kyuubi.metadata.request.opened and fix flaky test - MetadataManagerSuite
    
    ### _Why are the changes needed?_
    
    Seems there is some delay for the finally block.
    <img width="749" alt="image" src="https://user-images.githubusercontent.com/6757692/199627847-7555a2d6-044f-4e91-88f7-6353084c788a.png">
    Add a new metrics for opened metadata requests to track after each test.
    
    ### _How was this patch tested?_
    - [ ] Add some test cases that check the changes thoroughly including negative and positive cases if possible
    
    - [ ] Add screenshots for manual tests if appropriate
    
    - [x] [Run test](https://kyuubi.apache.org/docs/latest/develop_tools/testing.html#running-tests) locally before make a pull request
    
    Closes #3748 from turboFei/flaky_test_metadata_requests_v2.
    
    Closes #3748
    
    c130b6e9 [Fei Wang] 1.6.1
    bc327752 [Fei Wang] Add kyuubi.metadata.request.opened to fix flaky test
    6153f9a6 [Fei Wang] Revert "fix flaky test"
    f067c5aa [Fei Wang] fix flaky test
    
    Authored-by: Fei Wang <fw...@ebay.com>
    Signed-off-by: Fei Wang <fw...@ebay.com>
    (cherry picked from commit 6de2f6871325f477f2839d641e90aabb5c9ba338)
    Signed-off-by: Fei Wang <fw...@ebay.com>
---
 docs/monitor/metrics.md                                            | 1 +
 .../main/scala/org/apache/kyuubi/metrics/MetricsConstants.scala    | 1 +
 .../scala/org/apache/kyuubi/server/metadata/MetadataManager.scala  | 2 ++
 .../org/apache/kyuubi/server/metadata/MetadataManagerSuite.scala   | 7 +++++++
 4 files changed, 11 insertions(+)

diff --git a/docs/monitor/metrics.md b/docs/monitor/metrics.md
index 11232994d..0a27cf43a 100644
--- a/docs/monitor/metrics.md
+++ b/docs/monitor/metrics.md
@@ -80,6 +80,7 @@ Metrics Prefix | Metrics Suffix | Type | Since | Description
 `kyuubi.backend_service.get_primary_keys`        | | meter | 1.6.0 |<div style='width: 150pt;word-wrap: break-word;white-space: normal'> kyuubi backend service `get_primary_keys` method execution time and rate </div>
 `kyuubi.backend_service.get_cross_reference`     | | meter | 1.6.0 |<div style='width: 150pt;word-wrap: break-word;white-space: normal'> kyuubi backend service `get_cross_reference` method execution time and rate </div>
 `kyuubi.operation.state` | `${operationType}`<br/>`.${state}` | meter | 1.6.0 |<div style='width: 150pt;word-wrap: break-word;white-space: normal'>  The `${operationType}` with a particular `${state}` rate, e.g. `BatchJobSubmission.pending`, `BatchJobSubmission.finished`. Note that, the terminal states are cumulative, but the intermediate ones are not. </div>
+`kyuubi.metadata.request.opened`                 | | counter | 1.6.1 |<div style='width: 150pt;word-wrap: break-word;white-space: normal'> current opened count for the metadata requests </div>
 `kyuubi.metadata.request.total`                  | | meter | 1.6.0 |<div style='width: 150pt;word-wrap: break-word;white-space: normal'> metadata requests time and rate </div>
 `kyuubi.metadata.request.failed`                 | | meter | 1.6.0 |<div style='width: 150pt;word-wrap: break-word;white-space: normal'> metadata requests failure time and rate </div>
 `kyuubi.metadata.request.retrying`               | | meter | 1.6.0 |<div style='width: 150pt;word-wrap: break-word;white-space: normal'> retrying metadata requests time and rate, it is not cumulative </div>
diff --git a/kyuubi-metrics/src/main/scala/org/apache/kyuubi/metrics/MetricsConstants.scala b/kyuubi-metrics/src/main/scala/org/apache/kyuubi/metrics/MetricsConstants.scala
index 022992901..3f967abe6 100644
--- a/kyuubi-metrics/src/main/scala/org/apache/kyuubi/metrics/MetricsConstants.scala
+++ b/kyuubi-metrics/src/main/scala/org/apache/kyuubi/metrics/MetricsConstants.scala
@@ -85,6 +85,7 @@ object MetricsConstants {
   final val BS_FETCH_RESULTS = BACKEND_SERVICE + "fetch_results"
 
   final private val METADATA_REQUEST = KYUUBI + "metadata.request."
+  final val METADATA_REQUEST_OPENED = METADATA_REQUEST + "opened"
   final val METADATA_REQUEST_TOTAL = METADATA_REQUEST + "total"
   final val METADATA_REQUEST_FAIL = METADATA_REQUEST + "failed"
   final val METADATA_REQUEST_RETRYING = METADATA_REQUEST + "retrying"
diff --git a/kyuubi-server/src/main/scala/org/apache/kyuubi/server/metadata/MetadataManager.scala b/kyuubi-server/src/main/scala/org/apache/kyuubi/server/metadata/MetadataManager.scala
index 6b11d2a3a..c7946950c 100644
--- a/kyuubi-server/src/main/scala/org/apache/kyuubi/server/metadata/MetadataManager.scala
+++ b/kyuubi-server/src/main/scala/org/apache/kyuubi/server/metadata/MetadataManager.scala
@@ -80,6 +80,7 @@ class MetadataManager extends AbstractService("MetadataManager") {
   }
 
   private def withMetadataRequestMetrics[T](block: => T): T = {
+    MetricsSystem.tracing(_.incCount(MetricsConstants.METADATA_REQUEST_OPENED))
     try {
       block
     } catch {
@@ -87,6 +88,7 @@ class MetadataManager extends AbstractService("MetadataManager") {
         MetricsSystem.tracing(_.markMeter(MetricsConstants.METADATA_REQUEST_FAIL))
         throw e
     } finally {
+      MetricsSystem.tracing(_.decCount(MetricsConstants.METADATA_REQUEST_OPENED))
       MetricsSystem.tracing(_.markMeter(MetricsConstants.METADATA_REQUEST_TOTAL))
     }
   }
diff --git a/kyuubi-server/src/test/scala/org/apache/kyuubi/server/metadata/MetadataManagerSuite.scala b/kyuubi-server/src/test/scala/org/apache/kyuubi/server/metadata/MetadataManagerSuite.scala
index a7c7372b6..d8a8af202 100644
--- a/kyuubi-server/src/test/scala/org/apache/kyuubi/server/metadata/MetadataManagerSuite.scala
+++ b/kyuubi-server/src/test/scala/org/apache/kyuubi/server/metadata/MetadataManagerSuite.scala
@@ -51,6 +51,13 @@ class MetadataManagerSuite extends KyuubiFunSuite {
     super.afterAll()
   }
 
+  override protected def afterEach(): Unit = {
+    eventually(timeout(5.seconds), interval(200.milliseconds)) {
+      assert(MetricsSystem.counterValue(
+        MetricsConstants.METADATA_REQUEST_OPENED).getOrElse(0L) === 0)
+    }
+  }
+
   test("retry the metadata store requests") {
     val metadata = Metadata(
       identifier = UUID.randomUUID().toString,