LOGGER.info("Enabling UDP Datadog reporting with host " + config.metricsDatadogHost + ", port " + config.metricsDatadogPort); transport = new UdpTransport.Builder() .withStatsdHost(config.metricsDatadogHost) .withPort(config.metricsDatadogPort) .build();
private Transport buildUdp(Map<String, Object> transport) { UdpTransport.Builder builder = new UdpTransport.Builder(); ofNullable(transport.get("host")) .map(Object::toString) .ifPresent(builder::withStatsdHost); ofNullable(transport.get("prefix")) .map(Object::toString) .ifPresent(builder::withPrefix); ofNullable(transport.get("port")) .map(Object::toString) .map(Integer::parseInt) .ifPresent(builder::withPort); return builder.build(); }
public UdpTransport build() { return new UdpTransport.Builder() .withPrefix(prefix) .withStatsdHost(statsdHost) .withPort(port) .withRetryingLookup(retryingLookup) .build(); } }
UdpTransport.Builder builder = new UdpTransport.Builder(); if (hasProperty(STATSD_HOST)) { builder.withStatsdHost(getProperty(STATSD_HOST)); builder.withPort(getProperty(STATSD_PORT, Integer.class)); builder.withPrefix(getProperty(STATSD_PREFIX)); transport = builder.build(); } else { throw new IllegalArgumentException("Invalid Datadog Transport: " + transportName);
private boolean createTransport(String apiKey) { //if api key was not changed if (this.apiKey.equals(apiKey)) { return false; } else if (apiKey.equals("agent")) { this.apiKey = "agent"; transport = new UdpTransport.Builder().build(); return true; } else { this.apiKey = apiKey; transport = new HttpTransport.Builder().withApiKey(apiKey).build(); return true; } }