Github user alasdairhodge commented on a diff in the pull request:

    https://github.com/apache/incubator-brooklyn/pull/790#discussion_r36396115
  
    --- Diff: 
software/messaging/src/main/java/brooklyn/entity/messaging/kafka/KafkaBrokerImpl.java
 ---
    @@ -99,35 +100,43 @@ protected void connectSensors() {
                     .pollAttribute(new 
JmxAttributePollConfig<Long>(FETCH_REQUEST_COUNT)
                             .objectName(SOCKET_SERVER_STATS_MBEAN)
                             .attributeName("NumFetchRequests")
    -                        .onException(Functions.constant(-1l)))
    +                        .onException(Functions.constant(-1l))
    +                        .enabled(retrieveUsageMetrics))
                     .pollAttribute(new 
JmxAttributePollConfig<Long>(TOTAL_FETCH_TIME)
                             .objectName(SOCKET_SERVER_STATS_MBEAN)
                             .attributeName("TotalFetchRequestMs")
    -                        .onException(Functions.constant(-1l)))
    +                        .onException(Functions.constant(-1l))
    +                        .enabled(retrieveUsageMetrics))
                     .pollAttribute(new 
JmxAttributePollConfig<Double>(MAX_FETCH_TIME)
                             .objectName(SOCKET_SERVER_STATS_MBEAN)
                             .attributeName("MaxFetchRequestMs")
    -                        .onException(Functions.constant(-1.0d)))
    +                        .onException(Functions.constant(-1.0d))
    +                        .enabled(retrieveUsageMetrics))
                     .pollAttribute(new 
JmxAttributePollConfig<Long>(PRODUCE_REQUEST_COUNT)
                             .objectName(SOCKET_SERVER_STATS_MBEAN)
                             .attributeName("NumProduceRequests")
    -                        .onException(Functions.constant(-1l)))
    +                        .onException(Functions.constant(-1l))
    +                        .enabled(retrieveUsageMetrics))
                     .pollAttribute(new 
JmxAttributePollConfig<Long>(TOTAL_PRODUCE_TIME)
                             .objectName(SOCKET_SERVER_STATS_MBEAN)
                             .attributeName("TotalProduceRequestMs")
    -                        .onException(Functions.constant(-1l)))
    +                        .onException(Functions.constant(-1l))
    +                        .enabled(retrieveUsageMetrics))
                     .pollAttribute(new 
JmxAttributePollConfig<Double>(MAX_PRODUCE_TIME)
                             .objectName(SOCKET_SERVER_STATS_MBEAN)
                             .attributeName("MaxProduceRequestMs")
    -                        .onException(Functions.constant(-1.0d)))
    +                        .onException(Functions.constant(-1.0d))
    +                        .enabled(retrieveUsageMetrics))
                     .pollAttribute(new 
JmxAttributePollConfig<Long>(BYTES_RECEIVED)
                             .objectName(SOCKET_SERVER_STATS_MBEAN)
                             .attributeName("TotalBytesRead")
    -                        .onException(Functions.constant(-1l)))
    +                        .onException(Functions.constant(-1l))
    +                        .enabled(retrieveUsageMetrics))
                     .pollAttribute(new JmxAttributePollConfig<Long>(BYTES_SENT)
                             .objectName(SOCKET_SERVER_STATS_MBEAN)
                             .attributeName("TotalBytesWritten")
    -                        .onException(Functions.constant(-1l)))
    +                        .onException(Functions.constant(-1l))
    +                        .enabled(retrieveUsageMetrics))
    --- End diff --
    
    Should we have a global `enabled` option on the feed itself to cater for 
these cases where all `pollAttributes` are gated on the same condition?


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at [email protected] or file a JIRA ticket
with INFRA.
---

Reply via email to