/** * Initializes the instance with a name and value * @param name The name of the metric. Length 1-150 characters. * @param value The value of the metric. * @throws IllegalArgumentException if name is null or empty */ public MetricTelemetry(String name, double value) { this(); setName(name); metric.setValue(value); }
protected void send(TelemetryClient telemetryClient, double value, String key) { // Using the metric to avoid unneeded allocations telemetry.setName(key); telemetry.setValue(value); telemetryClient.track(telemetry); } }
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); }
@Override protected void send(TelemetryClient telemetryClient, String displayName, double value) { InternalLogger.INSTANCE.trace("Metric JMX: %s, %s", displayName, value); MetricTelemetry telemetry = new MetricTelemetry(); telemetry.markAsCustomPerfCounter(); telemetry.setName(displayName); telemetry.setValue(value); telemetry.getProperties().put("CustomPerfCounter", "true"); telemetryClient.track(telemetry); } }
@Test public void testSetName() { MetricTelemetry telemetry = new MetricTelemetry("MockName", 120.1); telemetry.setName("MockName1"); assertEquals("MockName1", telemetry.getName()); assertEquals(120.1, telemetry.getValue(), Math.ulp(120.1)); }