sanjeet006py commented on code in PR #2169:
URL: https://github.com/apache/phoenix/pull/2169#discussion_r2136867337


##########
phoenix-core-client/src/main/java/org/apache/phoenix/monitoring/PercentileHistogramDistribution.java:
##########
@@ -0,0 +1,60 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.phoenix.monitoring;
+
+import java.util.Collections;
+import java.util.Map;
+
+import org.apache.hbase.thirdparty.com.google.common.collect.ImmutableMap;
+
+/**
+ * Exposes percentiles captured using {@link PercentileHistogram} to the 
consumers w/o exposing
+ * underlying {@link org.HdrHistogram.Histogram} instances.
+ * <br/><br/>
+ * Call {@link #getPercentileDistributionMap()} to get percentile distribution 
from the histogram
+ * . Call {@link #getTags()} to get the tags attached to the histogram.
+ */
+public class PercentileHistogramDistribution extends HistogramDistributionImpl 
{
+    private final ImmutableMap<String, Long> percentileDistributionMap;
+    private ImmutableMap<String, String> tags = null;
+
+    public PercentileHistogramDistribution(String histoName, long min, long 
max, long count,
+                                           Map<String, Long> 
percentileDistributionMap) {
+        super(histoName, min, max, count, Collections.emptyMap());
+        this.percentileDistributionMap = 
ImmutableMap.copyOf(percentileDistributionMap);
+    }
+
+    public PercentileHistogramDistribution(String histoName, long min, long 
max, long count,
+                                           Map<String, Long> 
percentileDistributionMap,
+                                           Map<String, String> tags) {
+        this(histoName, min, max, count, percentileDistributionMap);
+        this.tags = ImmutableMap.copyOf(tags);
+    }
+
+    public Map<String, Long> getPercentileDistributionMap() {
+        return percentileDistributionMap;
+    }
+
+    public Map<String, Long> getRangeDistributionMap() {
+        throw new UnsupportedOperationException("Range Histogram Distribution 
is not supported!!");

Review Comment:
   These percentile histograms actually reset the histogram everytime we 
publish the metrics. Like internally we publish metrics from histogram every 5 
mins so, every 5 mins the histogram will be reset to record fresh values for 
next 5 mins. 
   With range histogram one problem we saw was that a static range have to be 
provided by us. And, because it will be a static range so, might not be useful 
for histograms of varied sizes (max value). Percentiles are not prone to this 
issue so, we went with Percentile histogram instead of Range Histogram in this 
case.



-- 
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: issues-unsubscr...@phoenix.apache.org

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

Reply via email to