com.signalfuse.metrics.connection.HttpDataPointProtobufReceiverConnection Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of signalfuse-java Show documentation
Show all versions of signalfuse-java Show documentation
Bare minimum core library needed to sending metrics to SignalFuse from Java clients
package com.signalfuse.metrics.connection;
import java.io.IOException;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import org.apache.commons.io.IOUtils;
import org.apache.http.HttpEntity;
import org.apache.http.HttpStatus;
import org.apache.http.client.methods.CloseableHttpResponse;
import org.apache.http.conn.HttpClientConnectionManager;
import org.apache.http.entity.ByteArrayEntity;
import org.apache.http.entity.InputStreamEntity;
import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.core.type.TypeReference;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.google.common.collect.ImmutableMap;
import com.signalfuse.common.proto.ProtocolBufferStreamingInputStream;
import com.signalfuse.endpoint.SignalFuseReceiverEndpoint;
import com.signalfuse.metrics.SignalfuseMetricsException;
import com.signalfuse.metrics.protobuf.SignalFuseProtocolBuffers;
public class HttpDataPointProtobufReceiverConnection
extends AbstractHttpDataPointProtobufReceiverConnection {
public HttpDataPointProtobufReceiverConnection(
SignalFuseReceiverEndpoint endpoint, int timeoutMs,
HttpClientConnectionManager httpClientConnectionManager) {
super(endpoint, timeoutMs, httpClientConnectionManager);
}
@Override
protected HttpEntity getEntityForVersion(List dataPoints) {
return new InputStreamEntity(
new ProtocolBufferStreamingInputStream(
dataPoints.iterator()), PROTO_TYPE);
}
@Override
protected String getEndpointForAddDatapoints() {
return "/v1/datapoint";
}
@Override
public Map registerMetrics(String auth,
Map metricTypes)
throws SignalfuseMetricsException {
Map res = new HashMap();
for (Map.Entry i : metricTypes.entrySet()) {
res.put(i.getKey(), false);
}
if (metricTypes.isEmpty()) {
return res;
}
List
© 2015 - 2025 Weber Informatics LLC | Privacy Policy