Github user Ramizjon commented on a diff in the pull request:
https://github.com/apache/nifi/pull/655#discussion_r71120757
--- Diff:
nifi-nar-bundles/nifi-datadog-bundle/nifi-datadog-reporting-task/src/main/java/org/apache/nifi/reporting/datadog/DDMetricRegistryBuilder.java
---
@@ -0,0 +1,71 @@
+package org.apache.nifi.reporting.datadog;
+
+import com.codahale.metrics.MetricRegistry;
+import org.apache.commons.lang3.RandomStringUtils;
+import org.coursera.metrics.datadog.DatadogReporter;
+import org.coursera.metrics.datadog.transport.UdpTransport;
+
+import java.io.IOException;
+import java.net.InetAddress;
+import java.util.Arrays;
+import java.util.List;
+import java.util.concurrent.TimeUnit;
+
+/**
+ * Class configures MetricRegistry (passed outside or created from
scratch) with Datadog support
+ */
+public class DDMetricRegistryBuilder {
+
+ private long interval = 10;
+
+ private MetricRegistry metricRegistry = null;
+
+ private String name = null;
+
+ private List<String> tags = Arrays.asList();
+
+ public DDMetricRegistryBuilder setInterval(long interval) {
+ this.interval = interval;
+ return this;
+ }
+
+ public DDMetricRegistryBuilder setMetricRegistry(MetricRegistry
metricRegistry) {
+ this.metricRegistry = metricRegistry;
+ return this;
+ }
+
+ public DDMetricRegistryBuilder setName(String name) {
+ this.name = name;
+ return this;
+ }
+
+ public DDMetricRegistryBuilder setTags(List<String> tags) {
+ this.tags = tags;
+ return this;
+ }
+
+ public MetricRegistry build() throws IOException {
+ if(metricRegistry == null)
+ metricRegistry = new MetricRegistry();
+
+ if(name==null) {
+ name = RandomStringUtils.randomAlphanumeric(8);
+ }
+ DatadogReporter datadogReporter =
createDatadogReporter(this.metricRegistry);
+ datadogReporter.start(this.interval, TimeUnit.SECONDS);
+
+ return this.metricRegistry;
+ }
+
+ //create DataDog reporter
+ private DatadogReporter createDatadogReporter(MetricRegistry
metricRegistry) throws IOException {
+ UdpTransport udpTransport = new UdpTransport.Builder().build();
+ DatadogReporter reporter =
+ DatadogReporter.forRegistry(metricRegistry)
+ .withHost(InetAddress.getLocalHost().getHostName())
--- End diff --
It's a predefined tag that is called "host". Again, we report metrics to
DataDog agent, that is installed locally, and it reports these metrics to
DataDog
---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at [email protected] or file a JIRA ticket
with INFRA.
---