lhotari commented on a change in pull request #13380:
URL: https://github.com/apache/pulsar/pull/13380#discussion_r771274117



##########
File path: 
pulsar-broker/src/main/java/org/apache/pulsar/broker/stats/prometheus/PrometheusMetricsServlet.java
##########
@@ -70,18 +71,27 @@ protected void doGet(HttpServletRequest request, 
HttpServletResponse response)
         AsyncContext context = request.startAsync();
         context.setTimeout(metricsServletTimeoutMs);
         executor.execute(safeRun(() -> {
+            long start = System.currentTimeMillis();
             HttpServletResponse res = (HttpServletResponse) 
context.getResponse();
             try {
                 res.setStatus(HttpStatus.OK_200);
                 res.setContentType("text/plain");
                 PrometheusMetricsGenerator.generate(pulsar, 
shouldExportTopicMetrics, shouldExportConsumerMetrics,
                         shouldExportProducerMetrics, 
splitTopicAndPartitionLabel, res.getOutputStream(),
                         metricsProviders);
-                context.complete();
-
             } catch (Exception e) {
-                log.error("Failed to generate prometheus stats", e);
+                long end = System.currentTimeMillis();
+                long time = end - start;

Review comment:
       I wonder if we should use Guava's Stopwatch for such use cases? Javadoc: 
https://guava.dev/releases/snapshot-jre/api/docs/com/google/common/base/Stopwatch.html




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