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

The following examples show how to use com.signalfx.metrics.protobuf.SignalFxProtocolBuffers#MetricType . 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 vote down vote up
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: SignalFxPluginSink.java    From ffwd with Apache License 2.0 5 votes vote down vote up
/**
 * Get the appropriate SignalFx metric type
 *
 * https://docs.signalfx.com/en/latest/getting-started/concepts/metric-types.html
 * @param metric Metric to check its type
 * @return SignalFx MetricType
 */
private SignalFxProtocolBuffers.MetricType getMetricType(final Metric metric) {
    final SignalFxProtocolBuffers.MetricType metricType;
    if (metric.getTags().getOrDefault("metric_type", "").equals("counter")) {
        metricType = SignalFxProtocolBuffers.MetricType.CUMULATIVE_COUNTER;
    } else {
        metricType = SignalFxProtocolBuffers.MetricType.GAUGE;
    }
    return metricType;
}
 
Example 3
Source File: AggregateMetricSenderSessionWrapper.java    From signalfx-java with Apache License 2.0 5 votes vote down vote up
private void addMetric(Metric metric, String codahaleName, SignalFxReporter.MetricDetails metricDetails,
                      SignalFxProtocolBuffers.MetricType defaultMetricType,
                      Object originalValue) {
    addMetric(metric, codahaleName, Optional.of(metricDetails),
            defaultMetricType, originalValue);

}
 
Example 4
Source File: DimensionInclusion.java    From signalfx-java with Apache License 2.0 5 votes vote down vote up
public boolean shouldInclude(SignalFxProtocolBuffers.MetricType metricType) {
    switch (metricType) {
    case GAUGE:
        return checkBit(GAUGE);
    case COUNTER:
        return checkBit(COUNTER);
    case CUMULATIVE_COUNTER:
        return checkBit(CUMULATIVE_COUNTER);
    case ENUM:
    default:
        return false;
    }
}
 
Example 5
Source File: AggregateMetricSenderSessionWrapper.java    From signalfx-java with Apache License 2.0 5 votes vote down vote up
/**
 * Add metric
 * @param metric
 * @param codahaleName
 * @param metricDetails
 * @param defaultMetricType
 * @param originalValue
 */

private void addMetric(Metric metric, MetricName codahaleName, SignalFxReporter.MetricDetails metricDetails,
                      SignalFxProtocolBuffers.MetricType defaultMetricType,
                      Object originalValue) {
    addMetric(metric, codahaleName, Optional.of(metricDetails),
            defaultMetricType, originalValue);

}
 
Example 6
Source File: AggregateMetricSenderSessionWrapper.java    From signalfx-java with Apache License 2.0 5 votes vote down vote up
/**
 * Add metric
 * @param metric
 * @param codahaleName
 * @param defaultMetricType
 * @param originalValue
 */

void addMetric(Metric metric, MetricName codahaleName,
                         SignalFxProtocolBuffers.MetricType defaultMetricType,
                         Object originalValue) {
    addMetric(metric, codahaleName, Optional.<SignalFxReporter.MetricDetails>absent(),
            defaultMetricType, originalValue);
}
 
Example 7
Source File: MetricMetadataImpl.java    From signalfx-java with Apache License 2.0 5 votes vote down vote up
@Override
public Optional<SignalFxProtocolBuffers.MetricType> getMetricType(Metric metric) {
    Metadata existingMetaData = metaDataCollection.get(metric);
    if (existingMetaData == null || existingMetaData.metricType == null) {
        return Optional.absent();
    } else {
        return Optional.of(existingMetaData.metricType);
    }
}
 
Example 8
Source File: StoredDataPointReceiver.java    From signalfx-java with Apache License 2.0 5 votes vote down vote up
@Override
public Map<String, Boolean> registerMetrics(String auth,
                            Map<String, SignalFxProtocolBuffers.MetricType> metricTypes)
        throws SignalFxMetricsException {
    registeredMetrics.putAll(metricTypes);
    Map<String, Boolean> ret = new HashMap<String, Boolean>();
    for (Map.Entry<String, SignalFxProtocolBuffers.MetricType> i: metricTypes.entrySet()) {
        ret.put(i.getKey(), true);
    }
    return ret;
}
 
Example 9
Source File: HttpDataPointProtobufReceiverConnectionV2.java    From signalfx-java with Apache License 2.0 5 votes vote down vote up
@Override
public Map<String, Boolean> registerMetrics(String auth,
                                            Map<String, SignalFxProtocolBuffers.MetricType> metricTypes)
        throws SignalFxMetricsException {
    Map<String, Boolean> res = new HashMap<String, Boolean>();
    for (Map.Entry<String, SignalFxProtocolBuffers.MetricType> i : metricTypes.entrySet()) {
        res.put(i.getKey(), true);
    }
    return res;
}
 
Example 10
Source File: AggregateMetricSender.java    From signalfx-java with Apache License 2.0 5 votes vote down vote up
@Override
public Session setDatapoint(String source, String metric,
                                      SignalFxProtocolBuffers.MetricType metricType,
                                      double value) {
    check(metric, metricType);
    pointsToFlush.add(SignalFxProtocolBuffers.DataPoint.newBuilder()
                              .setSource(source)
                              .setMetricType(metricType)
                              .setMetric(metric).setValue(
                    SignalFxProtocolBuffers.Datum.newBuilder().setDoubleValue(value).build())
                              .build());
    return this;
}
 
Example 11
Source File: AggregateMetricSender.java    From signalfx-java with Apache License 2.0 5 votes vote down vote up
@Override
public Session setDatapoint(String source, String metric,
                                      SignalFxProtocolBuffers.MetricType metricType,
                                      long value) {
    check(metric, metricType);
    pointsToFlush.add(SignalFxProtocolBuffers.DataPoint.newBuilder()
                              .setSource(source)
                              .setMetricType(metricType)
                              .setMetric(metric).setValue(
                    SignalFxProtocolBuffers.Datum.newBuilder().setIntValue(value).build())
                              .build());
    return this;
}
 
Example 12
Source File: DataPointReceiver.java    From signalfx-java with Apache License 2.0 4 votes vote down vote up
Map<String, Boolean> registerMetrics(String auth, Map<String, SignalFxProtocolBuffers.MetricType> metricTypes)
throws SignalFxMetricsException;
 
Example 13
Source File: MetricMetadataImpl.java    From signalfx-java with Apache License 2.0 4 votes vote down vote up
@Override
public T withMetricType(
        SignalFxProtocolBuffers.MetricType metricType) {
    thisMetricsMetadata.metricType = metricType;
    return (T) this;
}
 
Example 14
Source File: AggregateMetricSenderSessionWrapper.java    From signalfx-java with Apache License 2.0 4 votes vote down vote up
void addMetric(Metric metric, String codahaleName,
                         SignalFxProtocolBuffers.MetricType defaultMetricType,
                         Object originalValue) {
    addMetric(metric, codahaleName, Optional.<SignalFxReporter.MetricDetails>absent(),
            defaultMetricType, originalValue);
}
 
Example 15
Source File: MetricMetadata.java    From signalfx-java with Apache License 2.0 2 votes vote down vote up
/**
 * Changes the default metric type of this metric to the SignalFx metric type passed in
 * @param metricType    The new metric type of this metric
 * @return this
 */
T withMetricType(SignalFxProtocolBuffers.MetricType metricType);
 
Example 16
Source File: MetricMetadata.java    From signalfx-java with Apache License 2.0 2 votes vote down vote up
/**
 * Changes the default metric type of this metric to the SignalFx metric type passed in
 * @param metricType    The new metric type of this metric
 * @return this
 */
T withMetricType(SignalFxProtocolBuffers.MetricType metricType);
 
Example 17
Source File: MetricMetadata.java    From signalfx-java with Apache License 2.0 votes vote down vote up
public Optional<SignalFxProtocolBuffers.MetricType> getMetricType(Metric metric); 
Example 18
Source File: AggregateMetricSender.java    From signalfx-java with Apache License 2.0 votes vote down vote up
Session setDatapoint(String source, String metric, SignalFxProtocolBuffers.MetricType metricType, double value); 
Example 19
Source File: AggregateMetricSender.java    From signalfx-java with Apache License 2.0 votes vote down vote up
Session setDatapoint(String source, String metric, SignalFxProtocolBuffers.MetricType metricType, long value); 
Example 20
Source File: MetricMetadata.java    From signalfx-java with Apache License 2.0 votes vote down vote up
public Optional<SignalFxProtocolBuffers.MetricType> getMetricType(Metric metric);