/** * New instance with default naming for metrics entries. * * @param logger * @param clazz */ public AbstractApiServlet(Logger logger, Class<?> clazz) { this(logger, MetricsFactory.getMetrics("web", clazz)); }
/** * New instance with default naming for metrics entries. * * @param logger * @param clazz */ public AbstractApiServlet(Logger logger, Class<?> clazz) { this(logger, MetricsFactory.getMetrics("web", clazz)); }
/** Constructor */ public BaleenJobManager() { metrics = MetricsFactory.getMetrics(BaleenJobManager.class); logger = LoggerFactory.getLogger(BaleenJobManager.class); }
/** Constructor */ public BaleenJobManager() { metrics = MetricsFactory.getMetrics(BaleenJobManager.class); logger = LoggerFactory.getLogger(BaleenJobManager.class); }
/** Constructor */ public BaleenPipelineManager() { metrics = MetricsFactory.getMetrics(BaleenPipelineManager.class); logger = LoggerFactory.getLogger(BaleenPipelineManager.class); }
/** Constructor */ public BaleenPipelineManager() { metrics = MetricsFactory.getMetrics(BaleenPipelineManager.class); logger = LoggerFactory.getLogger(BaleenPipelineManager.class); }
/** * Constructor to create a UimaMonitor. The class and pipeline name should be specified so that we * can differentiate between them in the logging and metrics * * @param clazz The class that is creating the UimaMonitor instance * @param pipelineName The name of the pipeline */ public UimaMonitor(String pipelineName, Class<?> clazz) { this.pipelineName = pipelineName; logger = LoggerFactory.getLogger(UimaUtils.makePipelineSpecificName(pipelineName, clazz)); metrics = MetricsFactory.getMetrics(pipelineName, clazz); }
/** * Constructor to create a UimaMonitor. The class and pipeline name should be specified so that we * can differentiate between them in the logging and metrics * * @param clazz The class that is creating the UimaMonitor instance * @param pipelineName The name of the pipeline */ public UimaMonitor(String pipelineName, Class<?> clazz) { this.pipelineName = pipelineName; logger = LoggerFactory.getLogger(UimaUtils.makePipelineSpecificName(pipelineName, clazz)); metrics = MetricsFactory.getMetrics(pipelineName, clazz); }
@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 testTiming() { UimaMonitor monitor = new UimaMonitor(PIPELINE, this.getClass()); monitor.startFunction(FUNCTION); try { Thread.sleep(100); } catch (InterruptedException e) { // Do nothing } monitor.finishFunction(FUNCTION); Metrics m = MetricsFactory.getMetrics(PIPELINE, this.getClass()); assertTrue(m.getTimer(FUNCTION).getSnapshot().getValues()[0] > 0); }
@Test public void testEntityRemoved() { UimaMonitor monitor = new UimaMonitor(PIPELINE, this.getClass()); monitor.entityRemoved(ENTITY_TYPE_1); monitor.entityRemoved(ENTITY_TYPE_1); monitor.entityRemoved(ENTITY_TYPE_2); monitor.entityRemoved(ENTITY_TYPE_2); monitor.entityRemoved(ENTITY_TYPE_1); monitor.persistCounts(); Metrics m = MetricsFactory.getMetrics(PIPELINE, this.getClass()); assertEquals(3, m.getCounter(ENTITY_TYPE_1 + "-removed").getCount()); assertEquals(2, m.getCounter(ENTITY_TYPE_2 + "-removed").getCount()); }
@Test public void testEntityAdded() { UimaMonitor monitor = new UimaMonitor(PIPELINE, this.getClass()); monitor.entityAdded(ENTITY_TYPE_1); monitor.entityAdded(ENTITY_TYPE_1); monitor.entityAdded(ENTITY_TYPE_2); monitor.entityAdded(ENTITY_TYPE_2); monitor.entityAdded(ENTITY_TYPE_1); monitor.persistCounts(); Metrics m = MetricsFactory.getMetrics(PIPELINE, this.getClass()); assertEquals(3, m.getCounter(ENTITY_TYPE_1 + "-added").getCount()); assertEquals(2, m.getCounter(ENTITY_TYPE_2 + "-added").getCount()); }
@Test public void testConfiguration() throws Exception { YamlConfiguration configuration = new YamlConfiguration(MetricsFactoryTest.class, "reporters.yaml"); metrics.configure(configuration); metrics.start(); try { metrics.getCounter(MetricsFactoryTest.class, "testConfiguration").inc(); metrics.getCounter(MetricsFactoryTest.class, "testConfiguration").inc(); MetricsFactory.getMetrics("test", MetricsFactoryTest.class) .getCounter("testConfigurationMetric") .inc(); metrics.report(); Thread.sleep(1000); } finally { metrics.stop(); } // Delete the directory of CSV tests TestingUtils.deleteDirectory("test_csvmetrics"); } }