@Test public void testSystemMetricsSensor() throws InterruptedException { final MetricRegistry registry = new MetricRegistry(); MetricRegistryHolder.getInstance().setMetrics(registry); final JavaTestKit agent = new JavaTestKit(actorSystem); final ActorRef sensor = TestActorRef.create(actorSystem, Props.create(SystemMetricsSensor.class, agent.getRef().path().toString())); agent.expectMsgClass(StatsRequest.class); sensor.tell(new StatsResponse(0, 0, 1.0, 0, 0, 0, 0, 0), agent.getRef()); for (Map.Entry<String, Histogram> e : registry.getHistograms().entrySet()) { if (SystemMetricNames.SYSTEM_CPU_LOAD.equalsIgnoreCase(e.getKey())) { Assert.assertEquals(100, e.getValue().getSnapshot().getValues()[0]); } else { Assert.assertEquals(0, e.getValue().getSnapshot().getValues()[0]); } } }
public SystemMetricsSensor() { this(DEFAULT_AGENT_PATH); }
SystemMetricsSensor extends AbstractSensor { public SystemMetricsSensor() { this(DEFAULT_AGENT_PATH); } }
SystemMetricsSensor extends AbstractSensor { public SystemMetricsSensor() { this(DEFAULT_AGENT_PATH); } SystemMetricsSensor();  SystemMetricsSensor(String agentPath); }
SystemMetricsSensor extends AbstractSensor { public SystemMetricsSensor() { this(DEFAULT_AGENT_PATH); } SystemMetricsSensor();  SystemMetricsSensor(String agentPath); @Override void onReceive(final Object message); }
SystemMetricsSensor extends AbstractSensor { public SystemMetricsSensor() { this(DEFAULT_AGENT_PATH); } SystemMetricsSensor();  SystemMetricsSensor(String agentPath); @Override void onReceive(final Object message);  }