public JmxPerformanceCounter(String categoryName, String counterName, Map<String, Collection<JmxAttributeData>> objectToAttributes) { Preconditions.checkArgument(!Strings.isNullOrEmpty(categoryName), "categoryName should be a valid non-empty value"); Preconditions.checkArgument(!Strings.isNullOrEmpty(counterName), "categoryName should be a valid non-empty value"); Preconditions.checkNotNull(objectToAttributes, "objectToAttributes should be not null"); Preconditions.checkArgument(!objectToAttributes.isEmpty(), "objectToAttributes should be not be empty"); id = categoryName + "." + counterName; telemetry = new PerformanceCounterTelemetry(); telemetry.setCategoryName(categoryName); telemetry.setCounterName(counterName); telemetry.setInstanceName(SystemInformation.INSTANCE.getProcessId()); this.objectToAttributes = objectToAttributes; }
@Test public void testInstanceName() throws IOException { PerformanceCounterTelemetry telemetry = new PerformanceCounterTelemetry(MOCK_CATEGORY, MOCK_COUNTER, MOCK_INSTANCE, MOCK_VALUE); String newValue = MOCK_INSTANCE + "new"; telemetry.setInstanceName(newValue); assertEquals(newValue, telemetry.getInstanceName()); verifyJson(telemetry, MOCK_CATEGORY, MOCK_COUNTER, newValue, MOCK_VALUE); }