Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add new API backend for Datadog EU #2

Merged
merged 2 commits into from
Dec 4, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,9 @@ public class HttpTransport implements Transport {

private static final Logger LOG = LoggerFactory.getLogger(HttpTransport.class);

private final static String BASE_URL = "https://api.datadoghq.com/api/v1";
private final static String BASE_URL_US = "https://api.datadoghq.com/api/v1";
private final static String BASE_URL_EU = "https://api.datadoghq.eu/api/v1";

private final String seriesUrl;
private final int connectTimeout; // in milliseconds
private final int socketTimeout; // in milliseconds
Expand All @@ -44,8 +46,10 @@ private HttpTransport(String apiKey,
int socketTimeout,
HttpHost proxy,
Executor executor,
boolean useCompression) {
this.seriesUrl = String.format("%s/series?api_key=%s", BASE_URL, apiKey);
boolean useCompression,
boolean euSite) {
final String baseUrl = euSite ? BASE_URL_EU: BASE_URL_US;
this.seriesUrl = String.format("%s/series?api_key=%s", baseUrl, apiKey);
this.connectTimeout = connectTimeout;
this.socketTimeout = socketTimeout;
this.proxy = proxy;
Expand All @@ -64,6 +68,7 @@ public static class Builder {
HttpHost proxy;
Executor executor;
boolean useCompression = false;
boolean euSite = false;

public Builder withApiKey(String key) {
this.apiKey = key;
Expand Down Expand Up @@ -95,8 +100,16 @@ public Builder withCompression(boolean compression) {
return this;
}

/**
* Send Metrics to Datadog EU site instead of US.
*/
public Builder withEuSite() {
this.euSite = true;
return this;
}

public HttpTransport build() {
return new HttpTransport(apiKey, connectTimeout, socketTimeout, proxy, executor, useCompression);
return new HttpTransport(apiKey, connectTimeout, socketTimeout, proxy, executor, useCompression, euSite);
}
}

Expand Down