All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.signalfuse.metrics.connection.HttpDataPointProtobufReceiverConnectionV2 Maven / Gradle / Ivy

Go to download

Bare minimum core library needed to sending metrics to SignalFuse from Java clients

There is a newer version: 0.0.19
Show newest version
package com.signalfuse.metrics.connection;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

import org.apache.http.HttpEntity;
import org.apache.http.conn.HttpClientConnectionManager;
import org.apache.http.entity.ByteArrayEntity;

import com.signalfuse.endpoint.SignalFuseReceiverEndpoint;
import com.signalfuse.metrics.SignalfuseMetricsException;
import com.signalfuse.metrics.protobuf.SignalFuseProtocolBuffers;

public class HttpDataPointProtobufReceiverConnectionV2
        extends AbstractHttpDataPointProtobufReceiverConnection {
    public HttpDataPointProtobufReceiverConnectionV2(
            SignalFuseReceiverEndpoint endpoint, int timeoutMs,
            HttpClientConnectionManager httpClientConnectionManager) {
        super(endpoint, timeoutMs, httpClientConnectionManager);
    }

    @Override
    protected String getEndpointForAddDatapoints() {
        return "/v2/datapoint";
    }

    @Override
    protected HttpEntity getEntityForVersion(List dataPoints) {
        byte[] bodyBytes = SignalFuseProtocolBuffers.DataPointUploadMessage.newBuilder()
                .addAllDatapoints(dataPoints).build().toByteArray();
        return new ByteArrayEntity(bodyBytes, PROTO_TYPE);
    }

    @Override
    public Map registerMetrics(String auth,
                                                Map metricTypes)
            throws SignalfuseMetricsException {
        Map res = new HashMap();
        for (Map.Entry i : metricTypes.entrySet()) {
            res.put(i.getKey(), true);
        }
        return res;
    }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy