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; } }
if (config.metricsDatadogType.contains("http")) { LOGGER.info("Enabling HTTP Datadog reporting"); transport = new HttpTransport.Builder() .withApiKey(config.metricsDatadogAPIKey) .build();
String transportName = getProperty(TRANSPORT); if ("http".equalsIgnoreCase(transportName)) { HttpTransport.Builder builder = new HttpTransport.Builder(); builder.withApiKey(getProperty(API_KEY)); if (hasProperty(CONNECT_TIMEOUT)) {
HttpTransport httpTransport = new HttpTransport .Builder() .withApiKey(getApiKey())
private Transport buildHttp(Map<String, Object> transport) { HttpTransport.Builder builder = new HttpTransport.Builder(); builder.withApiKey(ofNullable(transport.get("key")) .orElseThrow(() -> new IllegalArgumentException("Missing API Key!")).toString()); ofNullable(transport.get("connect.timeout.ms")) .map(Object::toString) .map(Integer::parseInt) .ifPresent(builder::withConnectTimeout); ofNullable(transport.get("socket.timeout.ms")) .map(Object::toString) .map(Integer::parseInt) .ifPresent(builder::withSocketTimeout); // only setup proxy if at least a port is specified ofNullable(transport.get("proxy.port")) .map(Object::toString) .map(Integer::parseInt) .ifPresent(port -> builder.withProxy(transport.getOrDefault("proxy.host", "localhost").toString(), port)); return builder.build(); }
public HttpTransport build() { HttpTransport.Builder builder = new HttpTransport.Builder() .withApiKey(apiKey) .withConnectTimeout((int) connectTimeout.toMilliseconds()) .withSocketTimeout((int) socketTimeout.toMilliseconds()); if (proxyPort != 0 || proxyHost != null) { if (proxyPort == 0 || proxyHost == null) { throw new IllegalStateException("must set both proxyPort and proxyHost or neither"); } builder.withProxy(proxyHost, proxyPort); } return builder.build(); } }