[
https://issues.apache.org/jira/browse/STORM-1524?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15132604#comment-15132604
]
ASF GitHub Bot commented on STORM-1524:
---------------------------------------
Github user revans2 commented on a diff in the pull request:
https://github.com/apache/storm/pull/1075#discussion_r51903563
--- Diff:
storm-core/src/jvm/org/apache/storm/daemon/metrics/reporters/ConsolePreparableReporter.java
---
@@ -0,0 +1,82 @@
+/**
+ * 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.storm.daemon.metrics.reporters;
+
+import com.codahale.metrics.ConsoleReporter;
+import com.codahale.metrics.MetricFilter;
+import com.codahale.metrics.MetricRegistry;
+import org.apache.storm.utils.Utils;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import java.io.PrintStream;
+import java.util.Locale;
+import java.util.Map;
+import java.util.concurrent.TimeUnit;
+
+public class ConsolePreparableReporter implements
PreparableReporter<ConsoleReporter> {
+ private final static Logger LOG =
LoggerFactory.getLogger(ConsolePreparableReporter.class);
+ ConsoleReporter reporter = null;
+
+ @Override
+ public void prepare(MetricRegistry metricsRegistry, Map stormConf) {
+ LOG.info("Preparing...");
+ ConsoleReporter.Builder builder =
ConsoleReporter.forRegistry(metricsRegistry);
+ PrintStream stream = (PrintStream)stormConf.get(":stream");
+ if (stream != null) {
+ builder.outputTo(stream);
+ }
+ Locale locale = (Locale)stormConf.get(":locale");
+ if (locale != null) {
+ builder.formattedFor(locale);
+ }
+ String rateUnit = Utils.getString(stormConf.get(":rate-unit"),
null);
+ if (rateUnit != null) {
+ builder.convertRatesTo(TimeUnit.valueOf(rateUnit));
+ }
+ String durationUnit =
Utils.getString(stormConf.get(":duration-unit"), null);
+ if (durationUnit != null) {
+ builder.convertDurationsTo(TimeUnit.valueOf(durationUnit));
+ }
+ MetricFilter filter = (MetricFilter) stormConf.get(":filter");
+ if (filter != null) {
+ builder.filter(filter);
+ }
+ reporter = builder.build();
--- End diff --
I'm not really sure I like the configs named ":filter" etc. I would prefer
to have them prefixed with something like
"storm.daemon.metrics.console-reporter." or you could have them be a map under
that config name.
> Make Storm daemon function statistics reporter pluggable
> --------------------------------------------------------
>
> Key: STORM-1524
> URL: https://issues.apache.org/jira/browse/STORM-1524
> Project: Apache Storm
> Issue Type: New Feature
> Components: storm-core
> Affects Versions: 0.10.0, 1.0.0, 0.10.1
> Reporter: Kishor Patil
> Assignee: Kishor Patil
>
> We use codahale, metrics-clojure to gather daemon side stats, but currently
> the we have only three reporters available which use builder pattern. So it
> would be useful to have ability to plugin different reporters that can use
> configuration instead of builder pattern.
--
This message was sent by Atlassian JIRA
(v6.3.4#6332)