com.signalfx.metrics.connection.AbstractHttpEventProtobufReceiverConnection Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of signalfx-codahale Show documentation
Show all versions of signalfx-codahale Show documentation
Dropwizard Codahale metrics plugin for signalfx
The newest version!
package com.signalfx.metrics.connection;
import java.io.IOException;
import java.util.List;
import com.signalfx.shaded.apache.http.HttpEntity;
import com.signalfx.shaded.apache.http.client.methods.CloseableHttpResponse;
import com.signalfx.shaded.apache.http.conn.HttpClientConnectionManager;
import com.signalfx.shaded.apache.http.entity.ContentType;
import com.signalfx.connection.AbstractHttpReceiverConnection;
import com.signalfx.endpoint.SignalFxReceiverEndpoint;
import com.signalfx.metrics.SignalFxMetricsException;
import com.signalfx.metrics.protobuf.SignalFxProtocolBuffers;
public abstract class AbstractHttpEventProtobufReceiverConnection extends AbstractHttpReceiverConnection implements EventReceiver {
protected static final ContentType PROTO_TYPE = ContentType.create("application/x-protobuf");
public AbstractHttpEventProtobufReceiverConnection(
SignalFxReceiverEndpoint endpoint,
int timeoutMs, HttpClientConnectionManager httpClientConnectionManager) {
super(endpoint, timeoutMs, httpClientConnectionManager);
}
public AbstractHttpEventProtobufReceiverConnection(
SignalFxReceiverEndpoint endpoint,
int timeoutMs, int maxRetries, HttpClientConnectionManager httpClientConnectionManager) {
super(endpoint, timeoutMs, maxRetries, httpClientConnectionManager);
}
@Override
public void addEvents(String auth, List events)
throws SignalFxMetricsException {
if (events.isEmpty()) {
return;
}
try {
CloseableHttpResponse resp = null;
try {
resp = postToEndpoint(auth,
getEntityForVersion(events),
getEndpointForAddEvents(),
false);
checkHttpResponse(resp);
} finally {
if (resp != null) {
resp.close();
}
}
} catch (IOException e) {
throw new SignalFxMetricsException("Exception posting to addEvents", e);
}
}
protected abstract String getEndpointForAddEvents();
protected abstract HttpEntity getEntityForVersion(
List events);
}
© 2015 - 2024 Weber Informatics LLC | Privacy Policy