public DummyEventTimer() { super("dummy", new MonitorableRegistry(), ThreadMetricSuite.blank(), false, false, Collections.<StepMeasurementSink>emptyList()); }
public static ThreadMetricSuite blank() { return new ThreadMetricSuite(Collections.<ThreadMetric>emptyList()); }
public static void main(String[] args) throws InterruptedException { ThreadMetricSuite suite = ThreadMetricSuite.blank(); suite.addMetric(StandardThreadMetrics.CLOCK_TIME); suite.addMetric(StandardThreadMetrics.BLOCKED_TIME); suite.addMetric(StandardThreadMetrics.WAITED_TIME); suite.addMetric(StandardThreadMetrics.USER_CPU_TIME); EventTimer timer = new EventTimer("blah", new MonitorableRegistry(), suite, true, true, Collections.<StepMeasurementSink>singletonList(new LoggerSink())); ThreadContext context = new ThreadContext(); EmailSender sender = new EmailSender(context); CheckoutBuyer buyer = new CheckoutBuyer(context); timer.registerTimeable(sender, "sendEmail"); timer.registerTimeable(buyer, "buySomething"); Thread t1 = new Thread(sender); Thread t2 = new Thread(buyer); t1.start(); t2.start(); InProgressExporter exporter = new InProgressExporter(timer, context); for (int i = 1; i <= 5; i++) { Thread.sleep(5000); InProgressSnapshot snapshot = exporter.getSnapshot(); System.out.println(snapshot.asFormattedString()); } t1.join(); t2.join(); }
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); }
classes.add(String.class); for (ThreadMetric metric : timer.getMetricSuite().metrics()) { names.add(metric.getMetricName()); descriptions.add(metric.getDescription()); keyedValues.put("Thread ID", entry.getKey().getId()); keyedValues.put("Event", event); for (ThreadMetric metric : timer.getMetricSuite().metrics()) { keyedValues.put(metric.getMetricName(), snapshotValues.get(metric)); LOG.trace(String.format("Thread %s in event %s, metric %s has value %s", entry
private void initEvents() { metricFactory = new EventTimer("test", new MonitorableRegistry(), ThreadMetricSuite .withDefaultMetrics(), true, true, Collections.<StepMeasurementSink>singletonList(new LoggerSink())); workflowWizardControl = new DummyTimeable(); logonControl = new DummyTimeable(); attachmentControl = new DummyTimeable(); }
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; }
@Test public void testValuesConvertedToStringsForExport() { ThreadContext context = new ThreadContext(); context.put("stringvalue", "floop"); context.put("intvalue", 99); Timeable t = new Timeable() { @Override public void setEventTimer(EventTimer timer) { } }; EventTimer timer = new EventTimer("foo", new MonitorableRegistry(), ThreadMetricSuite.blank(), false, false, Collections.<StepMeasurementSink>singletonList(new LoggerSink())); timer.registerTimeable(t, "foo"); timer.getCollector().startTiming(t, "stuff"); InProgressSnapshot snapshot = InProgressSnapshot.capture(timer, context); TabularData data = JmxInProgressMonitor.TO_TABULAR_DATA.apply(snapshot); assertEquals(SimpleType.STRING, data.getTabularType().getRowType().getType("stringvalue")); assertEquals(SimpleType.STRING, data.getTabularType().getRowType().getType("intvalue")); }
public static ThreadMetricSuite withDefaultMetrics() { return new ThreadMetricSuite(StandardThreadMetrics.defaults()); } }