You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@pulsar.apache.org by GitBox <gi...@apache.org> on 2021/12/09 08:45:31 UTC

[GitHub] [pulsar] Richard-Yi opened a new issue #13206: Pulsar metric endpoint should be designed to be reusable by other plugins

Richard-Yi opened a new issue #13206:
URL: https://github.com/apache/pulsar/issues/13206


   Currently, pulsar use `/metric` endpoint to expose its metrics in prometheus format,but it cannot be reused by other plugins such as aop/kop..
   I checked the source code. Pulsar defines `PrometheusRawMetricsProvider` to abstract the metrics provider class.
   ```java
   /**
    * The prometheus metrics provider for generate prometheus format metrics.
    */
   public interface PrometheusRawMetricsProvider {
   
       /**
        * Generate the metrics from the metrics provider.
        * @param stream the stream that write the metrics to
        */
       void generate(SimpleTextOutputStream stream);
   }
   
   ```
   But In `PrometheusMetricsServlet`, It only collect the metric from `PrometheusMetricsGenerator`, which only contains metrics from pulsar itself.
   ```java
       @Override
       protected void doGet(HttpServletRequest request, HttpServletResponse response)
               throws ServletException, IOException {
           AsyncContext context = request.startAsync();
           context.setTimeout(metricsServletTimeoutMs);
           executor.execute(safeRun(() -> {
               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);
                   res.setStatus(HttpStatus.INTERNAL_SERVER_ERROR_500);
                   context.complete();
               }
           }));
       }
   ```
   
   


-- 
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: commits-unsubscribe@pulsar.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [pulsar] Richard-Yi commented on issue #13206: Pulsar metric endpoint should be designed to be reusable by other plugins

Posted by GitBox <gi...@apache.org>.
Richard-Yi commented on issue #13206:
URL: https://github.com/apache/pulsar/issues/13206#issuecomment-989654114


   Sry..I missed the code. I know how to do it now. Just ignore this issue🤣


-- 
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: commits-unsubscribe@pulsar.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [pulsar] Richard-Yi closed issue #13206: Pulsar metric endpoint should be designed to be reusable by other plugins

Posted by GitBox <gi...@apache.org>.
Richard-Yi closed issue #13206:
URL: https://github.com/apache/pulsar/issues/13206


   


-- 
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: commits-unsubscribe@pulsar.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org