Skip to content
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

Export ClusterStats to JMX #502

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open

Export ClusterStats to JMX #502

wants to merge 3 commits into from

Conversation

choiwaiyiu
Copy link

@choiwaiyiu choiwaiyiu commented Oct 2, 2024

Exports ClusterStats to JMX.

Release notes

( x) This is not user-visible or is docs only, and no release notes are required.

*  Export ClusterStats to JMX

@choiwaiyiu choiwaiyiu changed the title Export clusterstats to jmx Export ClusterStats to JMX Oct 2, 2024
@ebyhr ebyhr requested a review from oneonestar October 2, 2024 05:43
@cla-bot cla-bot bot added the cla-signed label Oct 2, 2024
@trinodb trinodb deleted a comment from cla-bot bot Oct 2, 2024
@oneonestar
Copy link
Member

We can test it using /metrics added by #429

diff --git a/gateway-ha/src/test/java/io/trino/gateway/ha/TestGatewayHaMultipleBackend.java b/gateway-ha/src/test/java/io/trino/gateway/ha/TestGatewayHaMultipleBackend.java
index af680a6..f124e9d 100644
--- a/gateway-ha/src/test/java/io/trino/gateway/ha/TestGatewayHaMultipleBackend.java
+++ b/gateway-ha/src/test/java/io/trino/gateway/ha/TestGatewayHaMultipleBackend.java
@@ -338,6 +338,22 @@ final class TestGatewayHaMultipleBackend
         assertThat(callbackResponse.code()).isEqualTo(500);
     }
 
+    @Test
+    void testClusterStatsJMX()
+            throws Exception
+    {
+        Thread.sleep(5000);     // Wait for first health check to run
+        Request request = new Request.Builder()
+                .url("http://localhost:" + routerPort + "/metrics")
+                .get()
+                .build();
+        Response response = httpClient.newCall(request).execute();
+        String body = response.body().string();
+        System.out.println(body);
+        assertThat(body).contains("trino1_Healthy");
+        assertThat(body).contains("trino2_Healthy");
+    }
+
     @AfterAll
     void cleanup()
     {
diff --git a/gateway-ha/src/test/resources/test-config-template.yml b/gateway-ha/src/test/resources/test-config-template.yml
index beafe30..80ab3f3 100644
--- a/gateway-ha/src/test/resources/test-config-template.yml
+++ b/gateway-ha/src/test/resources/test-config-template.yml
@@ -11,6 +11,11 @@ dataStore:
 
 modules:
   - io.trino.gateway.ha.module.HaGatewayProviderModule
+  - io.trino.gateway.ha.module.ClusterStateListenerModule
+  - io.trino.gateway.ha.module.ClusterStatsMonitorModule
+
+managedApps:
+  - io.trino.gateway.ha.clustermonitor.ActiveClusterMonitor
 
 extraWhitelistPaths:
   - '/v1/custom.*'
@@ -23,3 +28,6 @@ gatewayCookieConfiguration:
 oauth2GatewayCookieConfiguration:
   deletePaths:
     - "/custom/logout"
+
+monitor:
+  taskDelaySeconds: 1

@willmostly
Copy link
Contributor

@choiwaiyiu I just skimmed and this looks good overall. Can you add a test as suggested by @oneonestar?

Please update the description to suggest a simple release note as well.

@choiwaiyiu
Copy link
Author

@willmostly @oneonestar
Sorry for the late response. I have added a test as suggested.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Development

Successfully merging this pull request may close these issues.

3 participants