xushiyan commented on a change in pull request #1572:
URL: https://github.com/apache/incubator-hudi/pull/1572#discussion_r422526952



##########
File path: 
hudi-client/src/main/java/org/apache/hudi/metrics/datadog/DatadogMetricsReporter.java
##########
@@ -0,0 +1,90 @@
+/*
+ * 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.hudi.metrics.datadog;
+
+import org.apache.hudi.common.util.Option;
+import org.apache.hudi.common.util.StringUtils;
+import org.apache.hudi.common.util.ValidationUtils;
+import org.apache.hudi.config.HoodieWriteConfig;
+import org.apache.hudi.metrics.MetricsReporter;
+import org.apache.hudi.metrics.datadog.DatadogHttpClient.ApiSite;
+
+import com.codahale.metrics.MetricFilter;
+import com.codahale.metrics.MetricRegistry;
+
+import java.io.Closeable;
+import java.util.List;
+import java.util.concurrent.TimeUnit;
+
+/**
+ * Hudi Datadog metrics reporter.
+ * <p>
+ * Responsible for reading Hoodie metrics configurations and hooking up with 
{@link org.apache.hudi.metrics.Metrics}.
+ * <p>
+ * Internally delegate reporting tasks to {@link DatadogReporter}.
+ */
+public class DatadogMetricsReporter extends MetricsReporter {
+
+  private final DatadogReporter reporter;
+
+  public DatadogMetricsReporter(HoodieWriteConfig config, MetricRegistry 
registry) {
+    ApiSite apiSite = config.getDatadogApiSite();
+    String apiKey = config.getDatadogApiKey();
+    ValidationUtils.checkState(!StringUtils.isNullOrEmpty(apiKey),
+        "Datadog cannot be initialized: API key is null or empty.");
+    boolean skipValidation = config.getDatadogApiKeySkipValidation();
+    String prefix = config.getDatadogMetricPrefix();
+    ValidationUtils.checkState(!StringUtils.isNullOrEmpty(prefix),
+        "Datadog cannot be initialized: Metric prefix is null or empty.");
+    Option<String> host = Option.ofNullable(config.getDatadogMetricHost());
+    List<String> tagList = config.getDatadogMetricTags();
+    Option<List<String>> tags = tagList.isEmpty() ? Option.empty() : 
Option.of(tagList);
+
+    reporter = new DatadogReporter(
+        registry,
+        new DatadogHttpClient(apiSite, apiKey, skipValidation),
+        prefix,
+        host,
+        tags,
+        MetricFilter.ALL,
+        TimeUnit.SECONDS,
+        TimeUnit.SECONDS
+    );
+  }
+
+  @Override
+  public void start() {
+    reporter.start(30, TimeUnit.SECONDS);

Review comment:
       I tried to gauge on a good number of configs for user to control over.. 
but i guess it won't harm if we go with all configurable with sane defaults. So 
yes i can make it configurable.




----------------------------------------------------------------
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.

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


Reply via email to