Github user karanmehta93 commented on a diff in the pull request:
https://github.com/apache/phoenix/pull/315#discussion_r205900530
--- 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).
> Maybe "Phoenix,sub=CLIENT" down below?
Seems reasonable as well.
---