Java Code Examples for com.signalfx.metrics.protobuf.SignalFxProtocolBuffers#DataPoint

The following examples show how to use com.signalfx.metrics.protobuf.SignalFxProtocolBuffers#DataPoint . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: StoredDataPointReceiver.java    From signalfx-java with Apache License 2.0 6 votes vote down vote up
@Override
public void addDataPoints(String auth, List<SignalFxProtocolBuffers.DataPoint> dataPoints)
        throws SignalFxMetricsException {
    if (throwOnAdd) {
        throw new SignalFxMetricsException("Flag set to true");
    }
    addDataPoints.addAll(dataPoints);
    for (SignalFxProtocolBuffers.DataPoint dp: dataPoints) {
        String source = dp.getSource();
        if ("".equals(source)) {
            source = findSfSourceDim(dp.getDimensionsList());
        }
        Pair<String, String> key = Pair.of(source, dp.getMetric());
        if (pointsFor.containsKey(key)) {
            pointsFor.get(key).add(dp.getValue());
        } else {
            pointsFor.put(key, Lists.newArrayList(dp.getValue()));
        }
    }
}
 
Example 2
Source File: AggregateMetricSender.java    From signalfx-java with Apache License 2.0 5 votes vote down vote up
private SessionImpl() {
    toBeRegisteredMetricPairs = new HashMap<String, com.signalfx.metrics.protobuf
            .SignalFxProtocolBuffers.MetricType>();

    pointsToFlush = new ArrayList<SignalFxProtocolBuffers.DataPoint>();
    eventsToFlush = new ArrayList<SignalFxProtocolBuffers.Event>();
}
 
Example 3
Source File: AbstractHttpDataPointProtobufReceiverConnection.java    From signalfx-java with Apache License 2.0 5 votes vote down vote up
@Override
public void addDataPoints(String auth, List<SignalFxProtocolBuffers.DataPoint> dataPoints)
        throws SignalFxMetricsException {
    if (dataPoints.isEmpty()) {
        return;
    }
    try {
        CloseableHttpResponse resp = null;
        try {
            resp = postToEndpoint(auth,
                    getEntityForVersion(dataPoints),
                    getEndpointForAddDatapoints(),
                    compress);

            int code = resp.getStatusLine().getStatusCode();
            if (code != HttpStatus.SC_OK) {
                throw new SignalFxMetricsException("Invalid status code " + code);
            }
        } finally {
            if (resp != null) {
                resp.close();
            }
        }
    } catch (IOException e) {
        throw new SignalFxMetricsException("Exception posting to addDataPoints", e);
    }
}
 
Example 4
Source File: AggregateMetricSender.java    From signalfx-java with Apache License 2.0 4 votes vote down vote up
@Override
public Session setDatapoint(SignalFxProtocolBuffers.DataPoint datapoint) {
    check(datapoint.getMetric(), datapoint.getMetricType());
    pointsToFlush.add(datapoint);
    return this;
}
 
Example 5
Source File: HttpDataPointProtobufReceiverConnectionV2.java    From signalfx-java with Apache License 2.0 4 votes vote down vote up
@Override
protected HttpEntity getEntityForVersion(List<SignalFxProtocolBuffers.DataPoint> dataPoints) {
    byte[] bodyBytes = SignalFxProtocolBuffers.DataPointUploadMessage.newBuilder()
            .addAllDatapoints(dataPoints).build().toByteArray();
    return new ByteArrayEntity(bodyBytes, PROTO_TYPE);
}
 
Example 6
Source File: DataPointReceiver.java    From signalfx-java with Apache License 2.0 4 votes vote down vote up
void addDataPoints(String auth, List<SignalFxProtocolBuffers.DataPoint> dataPoints)
throws SignalFxMetricsException;
 
Example 7
Source File: HttpDataPointProtobufReceiverConnection.java    From signalfx-java with Apache License 2.0 4 votes vote down vote up
@Override
protected HttpEntity getEntityForVersion(List<SignalFxProtocolBuffers.DataPoint> dataPoints) {
    return new InputStreamEntity(
            new ProtocolBufferStreamingInputStream<SignalFxProtocolBuffers.DataPoint>(
                    dataPoints.iterator()), PROTO_TYPE);
}
 
Example 8
Source File: AbstractHttpDataPointProtobufReceiverConnection.java    From signalfx-java with Apache License 2.0 4 votes vote down vote up
protected abstract HttpEntity getEntityForVersion(
List<SignalFxProtocolBuffers.DataPoint> dataPoints);
 
Example 9
Source File: AggregateMetricSender.java    From signalfx-java with Apache License 2.0 votes vote down vote up
Session setDatapoint(SignalFxProtocolBuffers.DataPoint datapoint);