/** * Get a new metrics provider for a specific class. * * @param prefix * @param clazz * @return */ public static Metrics getMetrics(String prefix, Class<?> clazz) { return new Metrics(getInstance(), prefix, clazz); }
/** * Get a new metrics provider for a specific class, without a prefix. * * @param clazz * @return */ public static Metrics getMetrics(Class<?> clazz) { return new Metrics(getInstance(), clazz); }
/** * Get a new metrics provider for a specific class. * * @param prefix * @param clazz * @return */ public static Metrics getMetrics(String prefix, Class<?> clazz) { return new Metrics(getInstance(), prefix, clazz); }
/** * Get a new metrics provider for a specific class, without a prefix. * * @param clazz * @return */ public static Metrics getMetrics(Class<?> clazz) { return new Metrics(getInstance(), clazz); }
/** Start timing the processing of a document */ public void startDocumentProcess() { finishDocumentProcess(); // Check we've finished the timing of the previous document documentTimerContext = MetricsFactory.getInstance().getTimer(pipelineName, DOCUMENT_TIMER).time(); }
/** Start timing the processing of a document */ public void startDocumentProcess() { finishDocumentProcess(); // Check we've finished the timing of the previous document documentTimerContext = MetricsFactory.getInstance().getTimer(pipelineName, DOCUMENT_TIMER).time(); }
/** Shutdown the sub components. */ public synchronized void shutdown() { if (started) { LOGGER.info("Shutting down"); started = false; List<AbstractBaleenComponent> components = Arrays.asList(pipelineManager, jobManager, webApi, logging); for (AbstractBaleenComponent component : components) { if (component != null) { try { component.stop(); } catch (BaleenException e) { LOGGER.error("Failed to stop " + component.getClass().getSimpleName(), e); } } } MetricsFactory metrics = MetricsFactory.getInstance(); if (metrics != null) { metrics.stop(); } LOGGER.info("Shutdown complete"); } }
/** Shutdown the sub components. */ public synchronized void shutdown() { if (started) { LOGGER.info("Shutting down"); started = false; List<AbstractBaleenComponent> components = Arrays.asList(pipelineManager, jobManager, webApi, logging); for (AbstractBaleenComponent component : components) { if (component != null) { try { component.stop(); } catch (BaleenException e) { LOGGER.error("Failed to stop " + component.getClass().getSimpleName(), e); } } } MetricsFactory metrics = MetricsFactory.getInstance(); if (metrics != null) { metrics.stop(); } LOGGER.info("Shutdown complete"); } }
@Override public final void getNext(final JCas jCas) throws IOException, CollectionException { getMonitor().startFunction("getNext"); MetricsFactory.getInstance() .getPipelineMetrics(monitor.getPipelineName()) .startDocumentProcess(); jCas.setDocumentText(JobSettings.class.getSimpleName()); jCas.setDocumentLanguage("en"); final JobSettings settings = new JobSettings(jCas); for (final Map.Entry<String, String> e : config.entrySet()) { settings.set(e.getKey(), e.getValue()); } getMonitor().finishFunction("getNext"); }
@Override public final void getNext(final JCas jCas) throws IOException, CollectionException { getMonitor().startFunction("getNext"); MetricsFactory.getInstance() .getPipelineMetrics(monitor.getPipelineName()) .startDocumentProcess(); jCas.setDocumentText(JobSettings.class.getSimpleName()); jCas.setDocumentLanguage("en"); final JobSettings settings = new JobSettings(jCas); for (final Map.Entry<String, String> e : config.entrySet()) { settings.set(e.getKey(), e.getValue()); } getMonitor().finishFunction("getNext"); }
@Before public void before() { // We need to clear the registry MetricsFactory.getInstance().removeAll(); }
MetricsFactory metrics = MetricsFactory.getInstance(); metrics.configure(configuration); metrics.start();
MetricsFactory metrics = MetricsFactory.getInstance(); metrics.configure(configuration); metrics.start();
@Override public final void getNext(JCas jCas) throws IOException, CollectionException { monitor.startFunction("getNext"); MetricsFactory.getInstance() .getPipelineMetrics(monitor.getPipelineName()) .startDocumentProcess(); doGetNext(jCas); monitor.finishFunction("getNext"); monitor.persistCounts(); }
@Override public final void getNext(JCas jCas) throws IOException, CollectionException { monitor.startFunction("getNext"); MetricsFactory.getInstance() .getPipelineMetrics(monitor.getPipelineName()) .startDocumentProcess(); doGetNext(jCas); monitor.finishFunction("getNext"); monitor.persistCounts(); }
@Test public void testInstance() { assertNotNull(MetricsFactory.getInstance()); Metrics m1 = MetricsFactory.getMetrics(MetricsFactoryTest.class); Metrics m2 = MetricsFactory.getMetrics("Testing", MetricsFactoryTest.class); assertTrue(m1.getBase().contains(MetricsFactoryTest.class.getCanonicalName())); assertTrue(m2.getBase().contains(MetricsFactoryTest.class.getCanonicalName())); assertTrue(m2.getBase().startsWith("Testing")); }
@Test public void test() throws Exception { PipelineMetrics pm = MetricsFactory.getInstance().getPipelineMetrics(PIPELINE_NAME); assertEquals(PIPELINE_NAME, pm.getPipelineName()); pm.startDocumentProcess(); Thread.sleep(10); pm.finishDocumentProcess(); Timer t = MetricsFactory.getInstance().getTimer(PIPELINE_NAME, "documentProcessingTime"); assertEquals(1, t.getCount()); assertTrue(t.getMeanRate() > 0); assertEquals(pm, MetricsFactory.getInstance().getPipelineMetrics(PIPELINE_NAME)); } }
new InstrumentedAppender(MetricsFactory.getInstance().getRegistry()); instrumentedAppender.setContext(context); instrumentedAppender.start();
new InstrumentedAppender(MetricsFactory.getInstance().getRegistry()); instrumentedAppender.setContext(context); instrumentedAppender.start();
@Test public void testDoesntCrash() { MetricsFactory factory = MetricsFactory.getInstance(); factory.getRegistry().addListener(new LoggingMetricListener()); assertNotNull(factory.getCounter(LoggingMetricListenerTest.class, "a")); assertNotNull(factory.getHistogram(LoggingMetricListenerTest.class, "b")); assertNotNull(factory.getMeter(LoggingMetricListenerTest.class, "c")); assertNotNull(factory.getTimer(LoggingMetricListenerTest.class, "d")); factory.removeAll(); }