@Test public void noDoubleId() { registeredSensorConfig.addSensorId(1, PriorityEnum.MIN); registeredSensorConfig.addSensorId(2, PriorityEnum.MAX); registeredSensorConfig.addSensorId(1, PriorityEnum.MAX); registeredSensorConfig.addSensorId(2, PriorityEnum.MIN); long[] sensorIds = registeredSensorConfig.getSensorIds(); assertThat(sensorIds.length, is(2)); }
@Test public void priority() { registeredSensorConfig.addSensorId(1, PriorityEnum.MAX); registeredSensorConfig.addSensorId(2, PriorityEnum.MIN); long[] sensorIds = registeredSensorConfig.getSensorIds(); assertThat(sensorIds.length, is(2)); assertThat(sensorIds[0], is(1L)); assertThat(sensorIds[1], is(2L)); }
@Test public void priorityReverse() { registeredSensorConfig.addSensorId(1, PriorityEnum.MIN); registeredSensorConfig.addSensorId(2, PriorityEnum.MAX); long[] sensorIds = registeredSensorConfig.getSensorIds(); assertThat(sensorIds.length, is(2)); // highest priority first assertThat(sensorIds[0], is(2L)); assertThat(sensorIds[1], is(1L)); } }
@Test public void containsId() { registeredSensorConfig.addSensorId(1, PriorityEnum.MIN); registeredSensorConfig.addSensorId(2, PriorityEnum.MAX); boolean containsSensorId1 = registeredSensorConfig.containsSensorId(1); boolean containsSensorId2 = registeredSensorConfig.containsSensorId(2); assertThat(containsSensorId1, is(true)); assertThat(containsSensorId2, is(true)); } }
/** * {@inheritDoc} */ protected void applyAssignment(AgentConfig agentConfiguration, SensorInstrumentationPoint sensorInstrumentationPoint) { // there can be only one exception sensor so I just take the id ExceptionSensorTypeConfig exceptionSensorTypeConfig = agentConfiguration.getExceptionSensorTypeConfig(); long sensorId = exceptionSensorTypeConfig.getId(); // set to rsc sensorInstrumentationPoint.addSensorId(sensorId, exceptionSensorTypeConfig.getPriority()); // add all settings sensorInstrumentationPoint.addSettings(exceptionSensorAssignment.getSettings()); }
/** * {@inheritDoc} */ protected void applyAssignment(AgentConfig agentConfiguration, SensorInstrumentationPoint sensorInstrumentationPoint) { // first deal with sensor id MethodSensorTypeConfig methodSensorTypeConfig = getSensorTypeConfigFromConfiguration(agentConfiguration, environment, methodSensorAssignment); long sensorId = methodSensorTypeConfig.getId(); // set to rsc sensorInstrumentationPoint.addSensorId(sensorId, methodSensorTypeConfig.getPriority()); // add all settings sensorInstrumentationPoint.addSettings(methodSensorAssignment.getSettings()); }
/** * {@inheritDoc} */ @Override protected void applyAssignment(AgentConfig agentConfiguration, SensorInstrumentationPoint registeredSensorConfig) { // call super first super.applyAssignment(agentConfiguration, registeredSensorConfig); // check for invocation starts if (assignment.isStartsInvocation()) { // find the id of invocation sensor and only mark if one is found IMethodSensorConfig invocationSensorConfig = environment.getMethodSensorTypeConfig(InvocationSequenceSensorConfig.class); if (null != invocationSensorConfig) { MethodSensorTypeConfig invocationSensorTypeConfig = agentConfiguration.getMethodSensorTypeConfig(invocationSensorConfig.getClassName()); registeredSensorConfig.addSensorId(invocationSensorTypeConfig.getId(), invocationSensorTypeConfig.getPriority()); registeredSensorConfig.setStartsInvocation(true); } } } }