Java Code Examples for com.signalfx.metrics.protobuf.SignalFxProtocolBuffers#Datum
The following examples show how to use
com.signalfx.metrics.protobuf.SignalFxProtocolBuffers#Datum .
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: SignalFxMeterRegistry.java From micrometer with Apache License 2.0 | 6 votes |
private SignalFxProtocolBuffers.DataPoint.Builder addDatapoint(Meter meter, SignalFxProtocolBuffers.MetricType metricType, @Nullable String statSuffix, Number value) { SignalFxProtocolBuffers.Datum.Builder datumBuilder = SignalFxProtocolBuffers.Datum.newBuilder(); SignalFxProtocolBuffers.Datum datum = (value instanceof Double ? datumBuilder.setDoubleValue((Double) value) : datumBuilder.setIntValue(value.longValue()) ).build(); String metricName = config().namingConvention().name(statSuffix == null ? meter.getId().getName() : meter.getId().getName() + "." + statSuffix, meter.getId().getType(), meter.getId().getBaseUnit()); SignalFxProtocolBuffers.DataPoint.Builder dataPointBuilder = SignalFxProtocolBuffers.DataPoint.newBuilder() .setMetric(metricName) .setMetricType(metricType) .setValue(datum); for (Tag tag : getConventionTags(meter.getId())) { dataPointBuilder.addDimensions(SignalFxProtocolBuffers.Dimension.newBuilder() .setKey(tag.getKey()) .setValue(tag.getValue()) .build()); } return dataPointBuilder; }
Example 2
Source File: StoredDataPointReceiver.java From signalfx-java with Apache License 2.0 | 5 votes |
public List<SignalFxProtocolBuffers.Datum> valuesFor(String source, String metric) { Pair<String, String> key = Pair.of(source, metric); List<SignalFxProtocolBuffers.Datum> ret = pointsFor.get(key); if (ret == null) { return Collections.emptyList(); } else { return Collections.unmodifiableList(ret); } }
Example 3
Source File: StoredDataPointReceiver.java From signalfx-java with Apache License 2.0 | 5 votes |
public SignalFxProtocolBuffers.Datum lastValueFor(String source, String metric) { List<SignalFxProtocolBuffers.Datum> vals = valuesFor(source, metric); if (vals.isEmpty()) { throw new RuntimeException("No value for source/metric"); } else { return vals.get(vals.size() - 1); } }