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 testSetStandardDeviation() { MetricTelemetry telemetry = new MetricTelemetry("MockName", 120.1); telemetry.setStandardDeviation(new Double(1)); assertEquals(new Double(1), telemetry.getStandardDeviation()); }
mt.setMin(10.0); mt.setCount(100); mt.setStandardDeviation(2.43); appInsights.trackMetric(mt); System.out.println("[4] Metric -- metric:\"Test time\", value=17.0, Max=20.0, Min=10.0, Count=100 and STDV=2.43");
/** * 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 = new MetricTelemetry("TestAggregation", sum); mt.getContext().setInstrumentationKey(iKey); mt.setStandardDeviation(stdDev); mt.setMin(min); mt.setMax(max);