frankgh commented on code in PR #109:
URL: https://github.com/apache/cassandra-sidecar/pull/109#discussion_r1560054031


##########
src/main/java/org/apache/cassandra/sidecar/metrics/MetricFilter.java:
##########
@@ -0,0 +1,89 @@
+/*
+ * 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.cassandra.sidecar.metrics;
+
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Objects;
+import java.util.regex.Pattern;
+
+import org.apache.cassandra.sidecar.config.MetricsFilteringConfiguration;
+
+/**
+ * Filter for deciding whether a metric should be captured
+ */
+public abstract class MetricFilter
+{
+    public abstract boolean matches(String name);
+
+    public static List<MetricFilter> parse(List<MetricsFilteringConfiguration> 
filterConfigurations)
+    {
+        List<MetricFilter> filters = new ArrayList<>();
+        for (MetricsFilteringConfiguration filterConfiguration : 
filterConfigurations)
+        {
+            if (filterConfiguration.type().equalsIgnoreCase("regex"))
+            {
+                filters.add(new Regex(filterConfiguration.value()));
+            }
+            else if (filterConfiguration.type().equalsIgnoreCase("equals"))
+            {
+                filters.add(new Equals(filterConfiguration.value()));
+            }
+        }
+        return filters;
+    }
+
+    /**
+     * Metric name based {@link MetricFilter} that checks if a metric name 
matches provided regex pattern
+     */
+    public static class Regex extends MetricFilter
+    {
+        private final Pattern pattern;
+
+        public Regex(String regex)
+        {
+            Objects.requireNonNull(regex);
+            this.pattern = Pattern.compile(regex);
+        }
+
+        public boolean matches(String name)

Review Comment:
   can you add override annotations ?



##########
src/main/java/org/apache/cassandra/sidecar/metrics/MetricFilter.java:
##########
@@ -0,0 +1,89 @@
+/*
+ * 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.cassandra.sidecar.metrics;
+
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Objects;
+import java.util.regex.Pattern;
+
+import org.apache.cassandra.sidecar.config.MetricsFilteringConfiguration;
+
+/**
+ * Filter for deciding whether a metric should be captured
+ */
+public abstract class MetricFilter
+{
+    public abstract boolean matches(String name);

Review Comment:
   javadocs?



-- 
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: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to