Search in sources :

Example 1 with Point

use of io.opencensus.metrics.export.Point in project instrumentation-java by census-instrumentation.

the class DropWizardMetrics method collectSnapshotAndCount.

/**
 * Returns a {@code Metric} collected from {@link Snapshot}.
 *
 * @param metricName the metric name.
 * @param metricDescription the metric description.
 * @param labelKeys metric label keys
 * @param labelValues metric label values
 * @param codahaleSnapshot the snapshot object to collect
 * @param count the value or count
 * @return a {@code Metric}.
 */
private Metric collectSnapshotAndCount(String metricName, String metricDescription, List<LabelKey> labelKeys, List<LabelValue> labelValues, String unit, io.dropwizard.metrics5.Snapshot codahaleSnapshot, long count) {
    List<ValueAtPercentile> valueAtPercentiles = Arrays.asList(ValueAtPercentile.create(50.0, codahaleSnapshot.getMedian()), ValueAtPercentile.create(75.0, codahaleSnapshot.get75thPercentile()), ValueAtPercentile.create(98.0, codahaleSnapshot.get98thPercentile()), ValueAtPercentile.create(99.0, codahaleSnapshot.get99thPercentile()), ValueAtPercentile.create(99.9, codahaleSnapshot.get999thPercentile()));
    Snapshot snapshot = Snapshot.create((long) codahaleSnapshot.size(), 0.0, valueAtPercentiles);
    Point point = Point.create(Value.summaryValue(Summary.create(count, 0.0, snapshot)), clock.now());
    // TODO(mayurkale): OPTIMIZATION: Cache the MetricDescriptor objects.
    MetricDescriptor metricDescriptor = MetricDescriptor.create(metricName, metricDescription, unit, Type.SUMMARY, labelKeys);
    TimeSeries timeSeries = TimeSeries.createWithOnePoint(labelValues, point, cumulativeStartTimestamp);
    return Metric.createWithOneTimeSeries(metricDescriptor, timeSeries);
}
Also used : ValueAtPercentile(io.opencensus.metrics.export.Summary.Snapshot.ValueAtPercentile) Snapshot(io.opencensus.metrics.export.Summary.Snapshot) MetricDescriptor(io.opencensus.metrics.export.MetricDescriptor) TimeSeries(io.opencensus.metrics.export.TimeSeries) Point(io.opencensus.metrics.export.Point)

Example 2 with Point

use of io.opencensus.metrics.export.Point in project instrumentation-java by census-instrumentation.

the class SignalFxSessionAdaptor method adapt.

/**
 * Converts the given Metric into datapoints that can be sent to SignalFx.
 *
 * @param metric The {@link Metric} containing the timeseries of each combination of label values.
 * @return A list of datapoints for the corresponding metric timeseries of this metric.
 */
static List<DataPoint> adapt(Metric metric) {
    MetricDescriptor metricDescriptor = metric.getMetricDescriptor();
    MetricType metricType = getType(metricDescriptor.getType());
    if (metricType == null) {
        return Collections.emptyList();
    }
    DataPoint.Builder shared = DataPoint.newBuilder();
    shared.setMetric(metricDescriptor.getName());
    shared.setMetricType(metricType);
    ArrayList<DataPoint> datapoints = Lists.newArrayList();
    for (TimeSeries timeSeries : metric.getTimeSeriesList()) {
        DataPoint.Builder builder = shared.clone();
        builder.addAllDimensions(createDimensions(metricDescriptor.getLabelKeys(), timeSeries.getLabelValues()));
        List<Point> points = timeSeries.getPoints();
        datapoints.ensureCapacity(datapoints.size() + points.size());
        for (Point point : points) {
            datapoints.add(builder.setValue(createDatum(point.getValue())).build());
        }
    }
    return datapoints;
}
Also used : MetricDescriptor(io.opencensus.metrics.export.MetricDescriptor) TimeSeries(io.opencensus.metrics.export.TimeSeries) DataPoint(com.signalfx.metrics.protobuf.SignalFxProtocolBuffers.DataPoint) MetricType(com.signalfx.metrics.protobuf.SignalFxProtocolBuffers.MetricType) Point(io.opencensus.metrics.export.Point) DataPoint(com.signalfx.metrics.protobuf.SignalFxProtocolBuffers.DataPoint)

Example 3 with Point

use of io.opencensus.metrics.export.Point in project instrumentation-java by census-instrumentation.

the class DropWizardMetrics method collectSnapshotAndCount.

/**
 * Returns a {@code Metric} collected from {@link Snapshot}.
 *
 * @param metricName the metric name.
 * @param metricDescription the metric description.
 * @param unit the metric descriptor unit.
 * @param codahaleSnapshot the snapshot object to collect
 * @param count the value or count
 * @return a {@code Metric}.
 */
private Metric collectSnapshotAndCount(String metricName, String metricDescription, String unit, com.codahale.metrics.Snapshot codahaleSnapshot, long count) {
    List<ValueAtPercentile> valueAtPercentiles = Arrays.asList(ValueAtPercentile.create(50.0, codahaleSnapshot.getMedian()), ValueAtPercentile.create(75.0, codahaleSnapshot.get75thPercentile()), ValueAtPercentile.create(98.0, codahaleSnapshot.get98thPercentile()), ValueAtPercentile.create(99.0, codahaleSnapshot.get99thPercentile()), ValueAtPercentile.create(99.9, codahaleSnapshot.get999thPercentile()));
    Snapshot snapshot = Snapshot.create((long) codahaleSnapshot.size(), 0.0, valueAtPercentiles);
    Point point = Point.create(Value.summaryValue(Summary.create(count, 0.0, snapshot)), clock.now());
    // TODO(mayurkale): OPTIMIZATION: Cache the MetricDescriptor objects.
    MetricDescriptor metricDescriptor = MetricDescriptor.create(metricName, metricDescription, unit, Type.SUMMARY, Collections.<LabelKey>emptyList());
    TimeSeries timeSeries = TimeSeries.createWithOnePoint(Collections.<LabelValue>emptyList(), point, cumulativeStartTimestamp);
    return Metric.createWithOneTimeSeries(metricDescriptor, timeSeries);
}
Also used : ValueAtPercentile(io.opencensus.metrics.export.Summary.Snapshot.ValueAtPercentile) Snapshot(io.opencensus.metrics.export.Summary.Snapshot) MetricDescriptor(io.opencensus.metrics.export.MetricDescriptor) TimeSeries(io.opencensus.metrics.export.TimeSeries) Point(io.opencensus.metrics.export.Point)

Aggregations

MetricDescriptor (io.opencensus.metrics.export.MetricDescriptor)3 Point (io.opencensus.metrics.export.Point)3 TimeSeries (io.opencensus.metrics.export.TimeSeries)3 Snapshot (io.opencensus.metrics.export.Summary.Snapshot)2 ValueAtPercentile (io.opencensus.metrics.export.Summary.Snapshot.ValueAtPercentile)2 DataPoint (com.signalfx.metrics.protobuf.SignalFxProtocolBuffers.DataPoint)1 MetricType (com.signalfx.metrics.protobuf.SignalFxProtocolBuffers.MetricType)1