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

    https://github.com/apache/phoenix/pull/315#discussion_r206259129
  
    --- Diff: 
phoenix-core/src/main/java/org/apache/phoenix/monitoring/GlobalClientMetrics.java
 ---
    @@ -108,40 +114,88 @@
         GLOBAL_HBASE_COUNT_ROWS_SCANNED(COUNT_ROWS_SCANNED),
         GLOBAL_HBASE_COUNT_ROWS_FILTERED(COUNT_ROWS_FILTERED);
     
    -    
    +    private static final Logger LOG = 
LoggerFactory.getLogger(GlobalClientMetrics.class);
         private static final boolean isGlobalMetricsEnabled = 
QueryServicesOptions.withDefaults().isGlobalMetricsEnabled();
    +    private MetricType metricType;
         private GlobalMetric metric;
     
    -    public void update(long value) {
    +    static {
    +        initPhoenixGlobalClientMetrics();
             if (isGlobalMetricsEnabled) {
    -            metric.change(value);
    +            MetricRegistry metricRegistry = createMetricRegistry();
    +            registerPhoenixMetricsToRegistry(metricRegistry);
    +            
GlobalMetricRegistriesAdapter.getInstance().registerMetricRegistry(metricRegistry);
    +        }
    +    }
    +
    +    private static void initPhoenixGlobalClientMetrics() {
    +        for (GlobalClientMetrics globalMetric : 
GlobalClientMetrics.values()) {
    +            globalMetric.metric = isGlobalMetricsEnabled ?
    +                    new GlobalMetricImpl(globalMetric.metricType) : new 
NoOpGlobalMetricImpl();
    +        }
    +    }
    +
    +    private static void registerPhoenixMetricsToRegistry(MetricRegistry 
metricRegistry) {
    +        for (GlobalClientMetrics globalMetric : 
GlobalClientMetrics.values()) {
    +            metricRegistry.register(globalMetric.metricType.columnName(),
    +                    new PhoenixGlobalMetricGauge(globalMetric.metric));
    +        }
    +    }
    +
    +    private static MetricRegistry createMetricRegistry() {
    +        LOG.info("Creating Metric Registry for Phoenix Global Metrics");
    +        MetricRegistryInfo registryInfo = new 
MetricRegistryInfo("PHOENIX", "Phoenix Global Metrics",
    --- End diff --
    
    > Global here refers that it is an aggregation across all clients (or all 
Phoenix Connections).
    
    In my mind, if you show me "Phoenix Client Metrics", I would naturally 
assume that they are for all clients that have metrics enabled (as opposed to 
breakouts by individual clients). As such, the word "Global" to me is just 
filler, but maybe that's just my interpretation of it.


---

Reply via email to