use of io.opencensus.metrics.export.Metric in project instrumentation-java by census-instrumentation.
the class DerivedLongGaugeImplTest method createTimeSeries_WithObjFunction.
@Test
public void createTimeSeries_WithObjFunction() {
derivedLongGauge.createTimeSeries(LABEL_VALUES, new QueueManager(), queueManagerFunction);
Metric metric = derivedLongGauge.getMetric(testClock);
assertThat(metric).isNotNull();
assertThat(metric).isEqualTo(Metric.createWithOneTimeSeries(METRIC_DESCRIPTOR, TimeSeries.createWithOnePoint(LABEL_VALUES, Point.create(Value.longValue(2), TEST_TIME), null)));
}
use of io.opencensus.metrics.export.Metric in project instrumentation-java by census-instrumentation.
the class DoubleGaugeImplTest method getOrCreateTimeSeries_WithNegativePointValues.
@Test
public void getOrCreateTimeSeries_WithNegativePointValues() {
DoublePoint point = doubleGauge.getOrCreateTimeSeries(LABEL_VALUES);
point.add(-100);
point.add(-33);
Metric metric = doubleGauge.getMetric(testClock);
assertThat(metric).isNotNull();
assertThat(metric.getMetricDescriptor()).isEqualTo(METRIC_DESCRIPTOR);
assertThat(metric.getTimeSeriesList().size()).isEqualTo(1);
assertThat(metric.getTimeSeriesList().get(0).getPoints().size()).isEqualTo(1);
assertThat(metric.getTimeSeriesList().get(0).getPoints().get(0).getValue()).isEqualTo(Value.doubleValue(-133));
assertThat(metric.getTimeSeriesList().get(0).getPoints().get(0).getTimestamp()).isEqualTo(TEST_TIME);
assertThat(metric.getTimeSeriesList().get(0).getStartTimestamp()).isNull();
}
use of io.opencensus.metrics.export.Metric in project instrumentation-java by census-instrumentation.
the class MeasureToViewMap method getMetrics.
synchronized List<Metric> getMetrics(Clock clock, State state) {
List<Metric> metrics = new ArrayList<Metric>();
Timestamp now = clock.now();
for (Entry<String, MutableViewData> entry : mutableMap.entries()) {
Metric metric = entry.getValue().toMetric(now, state);
if (metric != null) {
metrics.add(metric);
}
}
return metrics;
}
use of io.opencensus.metrics.export.Metric in project instrumentation-java by census-instrumentation.
the class DropWizardMetricsTest method collect_Timer.
@Test
public void collect_Timer() throws InterruptedException {
Timer timer = metricRegistry.timer("requests");
Timer.Context context = timer.time();
Thread.sleep(1L);
context.stop();
ArrayList<Metric> metrics = new ArrayList<>(dropWizardMetrics.getMetrics());
assertThat(metrics.size()).isEqualTo(1);
assertThat(metrics.get(0).getMetricDescriptor()).isEqualTo(MetricDescriptor.create("codahale_requests_timer", "Collected from codahale (metric=requests, " + "type=com.codahale.metrics.Timer)", NS_UNIT, Type.SUMMARY, Collections.<LabelKey>emptyList()));
assertThat(metrics.get(0).getTimeSeriesList().size()).isEqualTo(1);
assertThat(metrics.get(0).getTimeSeriesList().get(0).getLabelValues().size()).isEqualTo(0);
assertThat(metrics.get(0).getTimeSeriesList().get(0).getPoints().size()).isEqualTo(1);
assertThat(metrics.get(0).getTimeSeriesList().get(0).getPoints().get(0).getValue()).isEqualTo(Value.summaryValue(Summary.create(1L, 0.0, Snapshot.create(1L, 0.0, Arrays.asList(ValueAtPercentile.create(50.0, timer.getSnapshot().getMedian()), ValueAtPercentile.create(75.0, timer.getSnapshot().get75thPercentile()), ValueAtPercentile.create(98.0, timer.getSnapshot().get98thPercentile()), ValueAtPercentile.create(99.0, timer.getSnapshot().get99thPercentile()), ValueAtPercentile.create(99.9, timer.getSnapshot().get999thPercentile()))))));
assertThat(metrics.get(0).getTimeSeriesList().get(0).getStartTimestamp()).isNotNull();
}
use of io.opencensus.metrics.export.Metric in project instrumentation-java by census-instrumentation.
the class DropWizardMetricsTest method collect_Meter.
@Test
public void collect_Meter() {
Meter getRequests = metricRegistry.meter("get_requests");
getRequests.mark();
getRequests.mark();
ArrayList<Metric> metrics = new ArrayList<>(dropWizardMetrics.getMetrics());
assertThat(metrics.size()).isEqualTo(1);
assertThat(metrics.get(0).getMetricDescriptor()).isEqualTo(MetricDescriptor.create("codahale_get_requests_meter", "Collected from codahale (metric=get_requests, " + "type=com.codahale.metrics.Meter)", DEFAULT_UNIT, Type.CUMULATIVE_INT64, Collections.<LabelKey>emptyList()));
assertThat(metrics.get(0).getTimeSeriesList().size()).isEqualTo(1);
assertThat(metrics.get(0).getTimeSeriesList().get(0).getLabelValues().size()).isEqualTo(0);
assertThat(metrics.get(0).getTimeSeriesList().get(0).getPoints().size()).isEqualTo(1);
assertThat(metrics.get(0).getTimeSeriesList().get(0).getPoints().get(0).getValue()).isEqualTo(Value.longValue(2));
assertThat(metrics.get(0).getTimeSeriesList().get(0).getStartTimestamp()).isNotNull();
}
Aggregations