} catch (JsonProcessingException e) {
LOG.error("Telemetry is activated but sending failed.", e);
return;
}
final HttpPost post;
try {
post = new HttpPost(new URIBuilder(configuration.getTelemetryServiceUri()).build());
post.setHeader("User-Agent", "graylog2-server");
post.setHeader("Content-Type", "application/json");
post.setHeader("Content-Encoding", "gzip");
post.setEntity(postBody);
final RequestConfig.Builder configBuilder = RequestConfig.custom()
.setConnectTimeout(configuration.getTelemetryServiceConnectTimeOut())
.setSocketTimeout(configuration.getTelemetryServiceSocketTimeOut())
.setConnectionRequestTimeout(configuration.getTelemetryServiceConnectionRequestTimeOut());
if (configuration.getHttpProxyUri() != null) {
try {
final URIBuilder uriBuilder = new URIBuilder(configuration.getHttpProxyUri());
final URI proxyURI = uriBuilder.build();
configBuilder.setProxy(new HttpHost(proxyURI.getHost(), proxyURI.getPort(), proxyURI.getScheme()));
} catch (Exception e) {
LOG.error("Invalid telemetry service proxy URI: {}", configuration.getHttpProxyUri(), e);
return;
}
}
post.setConfig(configBuilder.build());
} catch (URISyntaxException e) {
LOG.error("Invalid telemetry service endpoint URI.", e);
return;
}