dockerzhang commented on a change in pull request #1866:
URL: https://github.com/apache/incubator-inlong/pull/1866#discussion_r764537440



##########
File path: 
inlong-agent/agent-core/src/main/java/org/apache/inlong/agent/core/AgentMain.java
##########
@@ -111,11 +126,23 @@ public static void main(String[] args) throws Exception {
         try {
             manager.start();
             stopManagerIfKilled(manager);
+
+            boolean enablePrometheus = AgentConfiguration.getAgentConf()
+                    .getBoolean(PROMETHEUS_ENABLE, DEFAULT_PROMETHEUS_ENABLE);
+            if (enablePrometheus) {
+                // starting metrics server
+                int metricsServerPort = AgentConfiguration.getAgentConf()
+                        .getInt(PROMETHEUS_EXPORTER_PORT, 
DEFAULT_PROMETHEUS_EXPORTER_PORT);
+                LOGGER.info("Starting prometheus metrics server on port {}", 
metricsServerPort);
+                metricsServer = new HTTPServer(metricsServerPort);
+            }
+
             manager.join();
         } catch (Exception ex) {
             LOGGER.error("exception caught", ex);
         } finally {
             manager.stop();
+            metricsServer.stop();

Review comment:
       if `enablePrometheus`  is `false`, here may cause an exception.




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