You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@pulsar.apache.org by "crossoverJie (via GitHub)" <gi...@apache.org> on 2023/08/31 09:04:12 UTC

[GitHub] [pulsar] crossoverJie opened a new pull request, #21102: [improve][broker] Add addCustomizeMetrics method for BrokerInterceptor

crossoverJie opened a new pull request, #21102:
URL: https://github.com/apache/pulsar/pull/21102

   
   
   Fixes #20772
   
   
   <!-- Details of when a PIP is required and how the PIP process work, please see: https://github.com/apache/pulsar/blob/master/pip/README.md -->
   
   ### Motivation
   
   Add addCustomizeMetrics method for BrokerInterceptor.
   
   ### Modifications
   
   <!-- Describe the modifications you've done. -->
   - Add addCustomizeMetrics method for BrokerInterceptor.
   - Callback the `addCustomizeMetrics(stream, pulsar)` method in `org.apache.pulsar.broker.stats.prometheus.PrometheusMetricsGenerator#generate0`. 
   
   ### Verifying this change
   
   - [x] Make sure that the change passes the CI checks.
   
   
   ### Does this pull request potentially affect one of the following parts:
   
   <!-- DO NOT REMOVE THIS SECTION. CHECK THE PROPER BOX ONLY. -->
   
   *If the box was checked, please highlight the changes*
   
   - [ ] Dependencies (add or upgrade a dependency)
   - [ ] The public API
   - [ ] The schema
   - [ ] The default values of configurations
   - [ ] The threading model
   - [ ] The binary protocol
   - [ ] The REST endpoints
   - [ ] The admin CLI options
   - [ ] The metrics
   - [ ] Anything that affects deployment
   
   ### Documentation
   
   <!-- DO NOT REMOVE THIS SECTION. CHECK THE PROPER BOX ONLY. -->
   
   - [ ] `doc` <!-- Your PR contains doc changes. -->
   - [ ] `doc-required` <!-- Your PR changes impact docs and you will update later -->
   - [x] `doc-not-needed` <!-- Your PR changes do not impact docs -->
   - [ ] `doc-complete` <!-- Docs have been already added -->
   
   ### Matching PR in forked repository
   
   PR in forked repository: https://github.com/crossoverJie/pulsar/pull/13
   
   <!--
   After opening this PR, the build in apache/pulsar will fail and instructions will
   be provided for opening a PR in the PR author's forked repository.
   
   apache/pulsar pull requests should be first tested in your own fork since the 
   apache/pulsar CI based on GitHub Actions has constrained resources and quota.
   GitHub Actions provides separate quota for pull requests that are executed in 
   a forked repository.
   
   The tests will be run in the forked repository until all PR review comments have
   been handled, the tests pass and the PR is approved by a reviewer.
   -->
   


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


Re: [PR] [improve][broker] Add addCustomizeMetrics method for BrokerInterceptor [pulsar]

Posted by "crossoverJie (via GitHub)" <gi...@apache.org>.
crossoverJie commented on PR #21102:
URL: https://github.com/apache/pulsar/pull/21102#issuecomment-1775358814

   
   This is also a method, but if a standard interface is provided by `BrokerInterceptor`, it can also standardize the code, and some of the Broker's metadata can also be obtained through `PulsarService`.


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


Re: [PR] [improve][broker] Add addCustomizeMetrics method for BrokerInterceptor [pulsar]

Posted by "dao-jun (via GitHub)" <gi...@apache.org>.
dao-jun commented on PR #21102:
URL: https://github.com/apache/pulsar/pull/21102#issuecomment-1773734513

   I don't get the key point of why do you want to add the method into `BrokerInterceptor`.
   Because in my understanding, we can also code as:
   ```
   public final class FooBrokerInterceptor implements BrokerInterceptor {
   
            public static final Counter counter = Counter.Builder()....register();
   
           @Override
           public void beforeSendMessage(Subscription subscription,
                                      Entry entry,
                                      long[] ackSet,
                                      MessageMetadata msgMetadata,
                                      Consumer consumer) {
               counter.add(...);
       }
   
   }
   
   ```


-- 
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] crossoverJie commented on a diff in pull request #21102: [improve][broker] Add addCustomizeMetrics method for BrokerInterceptor

Posted by "crossoverJie (via GitHub)" <gi...@apache.org>.
crossoverJie commented on code in PR #21102:
URL: https://github.com/apache/pulsar/pull/21102#discussion_r1315545265


##########
pulsar-broker/src/main/java/org/apache/pulsar/broker/intercept/BrokerInterceptor.java:
##########
@@ -223,6 +224,13 @@ default void onFilter(ServletRequest request, ServletResponse response, FilterCh
         // Just continue the chain by default.
         chain.doFilter(request, response);
     }
+    /**
+     * Add customize metrics to PrometheusMetricStreams.
+     * @param metricStreams
+     * @param pulsar
+     */
+    default void addCustomizeMetrics(PrometheusMetricStreams metricStreams, PulsarService pulsar){

Review Comment:
   Done



-- 
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] crossoverJie commented on a diff in pull request #21102: [improve][broker] Add addCustomizeMetrics method for BrokerInterceptor

Posted by "crossoverJie (via GitHub)" <gi...@apache.org>.
crossoverJie commented on code in PR #21102:
URL: https://github.com/apache/pulsar/pull/21102#discussion_r1315547689


##########
pulsar-broker/src/test/java/org/apache/pulsar/broker/intercept/BrokerInterceptorWithClassLoaderTest.java:
##########
@@ -185,6 +191,7 @@ public void close() {
                 .beforeSendMessage(mock(Subscription.class), mock(Entry.class), null, null);
         brokerInterceptorWithClassLoader
                 .beforeSendMessage(mock(Subscription.class), mock(Entry.class), null, null, null);
+        brokerInterceptorWithClassLoader.addCustomizeMetrics(mock(PrometheusMetricStreams.class),mock(PulsarService.class));

Review Comment:
   Done



-- 
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] Technoboy- commented on a diff in pull request #21102: [improve][broker] Add addCustomizeMetrics method for BrokerInterceptor

Posted by "Technoboy- (via GitHub)" <gi...@apache.org>.
Technoboy- commented on code in PR #21102:
URL: https://github.com/apache/pulsar/pull/21102#discussion_r1314734563


##########
pulsar-broker/src/main/java/org/apache/pulsar/broker/intercept/BrokerInterceptor.java:
##########
@@ -223,6 +224,13 @@ default void onFilter(ServletRequest request, ServletResponse response, FilterCh
         // Just continue the chain by default.
         chain.doFilter(request, response);
     }
+    /**
+     * Add customize metrics to PrometheusMetricStreams.
+     * @param metricStreams
+     * @param pulsar
+     */
+    default void addCustomizeMetrics(PrometheusMetricStreams metricStreams, PulsarService pulsar){

Review Comment:
   addCustomizeMetrics -> addCustomizedMetrics



-- 
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] Technoboy- commented on a diff in pull request #21102: [improve][broker] Add addCustomizeMetrics method for BrokerInterceptor

Posted by "Technoboy- (via GitHub)" <gi...@apache.org>.
Technoboy- commented on code in PR #21102:
URL: https://github.com/apache/pulsar/pull/21102#discussion_r1314730633


##########
pulsar-broker/src/main/java/org/apache/pulsar/broker/stats/prometheus/PrometheusMetricStreams.java:
##########
@@ -37,7 +37,7 @@ public class PrometheusMetricStreams {
      * @param value value of the sample
      * @param labelsAndValuesArray varargs of label and label value
      */
-    void writeSample(String metricName, Number value, String... labelsAndValuesArray) {
+    public void writeSample(String metricName, Number value, String... labelsAndValuesArray) {

Review Comment:
   Why change here ?



-- 
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] crossoverJie commented on a diff in pull request #21102: [improve][broker] Add addCustomizeMetrics method for BrokerInterceptor

Posted by "crossoverJie (via GitHub)" <gi...@apache.org>.
crossoverJie commented on code in PR #21102:
URL: https://github.com/apache/pulsar/pull/21102#discussion_r1315551352


##########
pulsar-broker/src/main/java/org/apache/pulsar/broker/stats/prometheus/PrometheusMetricStreams.java:
##########
@@ -37,7 +37,7 @@ public class PrometheusMetricStreams {
      * @param value value of the sample
      * @param labelsAndValuesArray varargs of label and label value
      */
-    void writeSample(String metricName, Number value, String... labelsAndValuesArray) {
+    public void writeSample(String metricName, Number value, String... labelsAndValuesArray) {

Review Comment:
   `writeSample()` method will be called by `addCustomizedMetrics()`, the default access permissions cannot be called.



-- 
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] Technoboy- commented on a diff in pull request #21102: [improve][broker] Add addCustomizeMetrics method for BrokerInterceptor

Posted by "Technoboy- (via GitHub)" <gi...@apache.org>.
Technoboy- commented on code in PR #21102:
URL: https://github.com/apache/pulsar/pull/21102#discussion_r1314731620


##########
pulsar-broker/src/test/java/org/apache/pulsar/broker/intercept/BrokerInterceptorWithClassLoaderTest.java:
##########
@@ -185,6 +191,7 @@ public void close() {
                 .beforeSendMessage(mock(Subscription.class), mock(Entry.class), null, null);
         brokerInterceptorWithClassLoader
                 .beforeSendMessage(mock(Subscription.class), mock(Entry.class), null, null, null);
+        brokerInterceptorWithClassLoader.addCustomizeMetrics(mock(PrometheusMetricStreams.class),mock(PulsarService.class));

Review Comment:
   Also add a related test.



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


Re: [PR] [improve][broker] Add addCustomizeMetrics method for BrokerInterceptor [pulsar]

Posted by "github-actions[bot] (via GitHub)" <gi...@apache.org>.
github-actions[bot] commented on PR #21102:
URL: https://github.com/apache/pulsar/pull/21102#issuecomment-1752247050

   The pr had no activity for 30 days, mark with Stale label.


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