private EventCounters getCounterSet(String eventGroup) { EventMetricCounters invocationCounter = createEventMetricCounters(eventGroup, "count", "Total number of times the event was directly triggered", ONE); EventCounters counters = new EventCounters(invocationCounter, cleanName(eventGroup)); for (ThreadMetric metric : metricSuite.metrics()) { EventMetricCounters timingCounter = createEventMetricCounters(eventGroup, metric .getCounterSuffix(), metric.getDescription(), metric.getUnit()); counters.addMetric(metric, timingCounter); } return counters; }
protected final ThreadMetric newThreadMetric(String name, Unit<?> unit, String counterSuffix, String description, final ThreadLocal<AtomicLong> threadLocal) { return new ThreadValueMetric(name, unit, counterSuffix, description, new ThreadValue.ThreadLocalMap<Number>(threadLocal)); }
/** * Factory method that creates a new ThreadContext initialized to also update Log4j's MDC. */ public static ThreadContext newMDCEnabledContext() { return new ThreadContext(new Log4jMdcBridge()); }
public void testBackTraceWithParentShowsCorrectPath() { StepMeasurements mummy = new StepMeasurements(null, PARENT, null); StepMeasurements timing = new StepMeasurements(mummy, CHILD, null); assertEquals("floop/bloop", timing.getBackTrace()); }
public void testForwardTraceWithOneChildShowsCorrectPath() { StepMeasurements timing = new StepMeasurements(null, PARENT, null); new StepMeasurements(timing, CHILD, null); assertEquals("floop/bloop", timing.getForwardTrace()); }
public Counter createCounterPair(Unit<?> unit, String globalCounterName, String threadMetricName, String threadMetricSuffix, String description) { MonitoredCounter metric = new MonitoredCounter(globalCounterName, description, registry, unit); ThreadCounter threadCounter = new ThreadCounter.ThreadMapCounter(); ThreadMetric threadMetric = new ThreadValueMetric(threadMetricName, unit, threadMetricSuffix, description, threadCounter); metricSuite.addMetric(threadMetric); return new CounterPair(metric, threadCounter); }
public void testShouldProduceExpectedMetricString() { MetricMeasurement measurement = getUnitMeasurement(HERTZ, 1); String result = new LoggerSink().buildSingleMetricResult(measurement); assertEquals("dummy: own 1.0 Hz, total 1.0 Hz", result); }
public void testParentSettingInConstructor() { StepMeasurements mummy = new StepMeasurements(null, PARENT, null); StepMeasurements timing = new StepMeasurements(mummy, CHILD, null); assertEquals(mummy, timing.getParent()); }
public void testClearRemovesValue() { final String testKey = "painter"; context.put(testKey, 7); context.clear(); assertNull("get() after clear should return null", context.get(testKey)); }
public void testNullParent() { StepMeasurements timing = new StepMeasurements(null, PARENT, null); assertNull(timing.getParent()); }
/** * Factory method that creates a new ThreadContext initialised to also update SLF4J's MDC */ public static ThreadContext newSLF4JEnabledContext() { return new ThreadContext(new Slf4jMDCBridge()); }
public void stopTimer() { pauseOwnTime(); endValue = metricSource.getValueForThread(thread); }
@Test public void zeroFractionShouldNeverSampleEvents() { CountingMeasurementSink counter = new CountingMeasurementSink(); StepMeasurementSink sink = new SamplingMeasurementSink(counter, 0.0f); assertEventSinkCounts(sink, 0, counter, 0, 0, 0, 0, 0); }
public static ThreadMetricSuite withDefaultMetrics() { return new ThreadMetricSuite(StandardThreadMetrics.defaults()); } }
public void testGetOfUnusedKeyReturnsNull() { final String testKey = "handy"; assertNull("get() of unused key should return null", context.get(testKey)); }
public void testBackTraceShowsAction() { StepMeasurements timing = new StepMeasurements(null, PARENT, "scratchButt"); assertEquals("floop:scratchButt", timing.getBackTrace()); }
public void testForwardTraceWithMultipleChildrenShowsCorrectPath() { StepMeasurements timing = new StepMeasurements(null, PARENT, null); new StepMeasurements(timing, CHILD, null); new StepMeasurements(timing, OTHER_CHILD, null); assertEquals("floop/{bloop|gloop}", timing .getForwardTrace()); }
@Test public void oneFractionShouldSampleAllEventCounts() { CountingMeasurementSink counter = new CountingMeasurementSink(); StepMeasurementSink sink = new SamplingMeasurementSink(counter, 1.0f); assertEventSinkCounts(sink, 0, counter, 1, 2, 3, 4, 5); }
public void testBackTraceWithNoParentShowsOnlySelf() { StepMeasurements timing = new StepMeasurements(null, PARENT, null); assertEquals(PARENT, timing.getBackTrace()); }
public void testForwardTraceShowsAction() { StepMeasurements timing = new StepMeasurements(null, PARENT, "scratchButt"); assertEquals("floop:scratchButt", timing.getForwardTrace()); }