public Runnable getTrackMetric_FullMeasurement() { final double value = 789.0123; final int count = 1; MetricTelemetry mt = new MetricTelemetry(); mt.setName("AiTestMetric_FullMeasurement"); mt.setValue(value); mt.setCount(count); for (Entry<String, String> entry : getPropertyMapForMethod("Metric_Mea").entrySet()) { mt.getProperties().put(entry.getKey(), entry.getValue()); } return customCases.getTrackMetric(mt); }
public Runnable getTrackMetric_FullAggregate() { final double value = (123.4 + 567.8); final int count = 2; final double min = 123.4; final double max = 567.8; final double avg = value/count; final double stdDev = Math.sqrt(((123.4-avg)*(123.4-avg) + (567.8-avg)*(567.8-avg))/count); MetricTelemetry mt = new MetricTelemetry(); mt.setName("AiTestMetric_FullAggregate"); mt.setValue(value); mt.setCount(count); mt.setMin(min); mt.setMax(max); mt.setStandardDeviation(stdDev); for (Entry<String, String> entry : getPropertyMapForMethod("Metric_Agg").entrySet()) { mt.getProperties().put(entry.getKey(), entry.getValue()); } return customCases.getTrackMetric(mt); }
@Test public void testSetCount() { MetricTelemetry telemetry = new MetricTelemetry("MockName", 120.1); telemetry.setCount(1); assertEquals(new Integer(1), telemetry.getCount()); }
mt.setMax(20.0); mt.setMin(10.0); mt.setCount(100); mt.setStandardDeviation(2.43); appInsights.trackMetric(mt);
/** * Sends a numeric metric to Application Insights. Appears in customMetrics in Analytics, and under Custom Metrics in Metric Explorer. * * @param name The name of the metric. Max length 150. * @param value The value of the metric. Sum if it represents an aggregation. * @param sampleCount The sample count. * @param min The minimum value of the sample. * @param max The maximum value of the sample. * @param stdDev The standard deviation of the sample. * @param properties Named string values you can use to search and classify trace messages. * @throws IllegalArgumentException if name is null or empty */ public void trackMetric(String name, double value, Integer sampleCount, Double min, Double max, Double stdDev, Map<String, String> properties) { if (isDisabled()) { return; } MetricTelemetry mt = new MetricTelemetry(name, value); mt.setCount(sampleCount); mt.setMin(min); mt.setMax(max); mt.setStandardDeviation(stdDev); MapUtil.copy(properties, mt.getProperties()); this.track(mt); }
mt.setMin(min); mt.setMax(max); mt.setCount(count); testCases.add(new Object[]{ "Metric aggregation",