RequestMonitor { public SpanContextInformation monitor(MonitoredRequest monitoredRequest) throws Exception { if (corePlugin.isStagemonitorActive()) { final long start = System.nanoTime(); final Span span = monitoredRequest.createSpan(); final Scope scope = tracingPlugin.getTracer().scopeManager().activate(span); try { final SpanContextInformation info = getSpanContextInformation(start, span); monitoredRequest.execute(); return info; } catch (Exception e) { recordException(e); throw e; } finally { monitorStop(scope, span); } } return null; } RequestMonitor(ConfigurationRegistry configuration, Metric2Registry registry); private  RequestMonitor(ConfigurationRegistry configuration, Metric2Registry registry, TracingPlugin tracingPlugin); SpanContextInformation monitorStart(MonitoredRequest monitoredRequest); void monitorStop(); SpanContextInformation monitor(MonitoredRequest monitoredRequest); void recordException(Exception e);  }
@Test public void testDeactivated() throws Exception { doReturn(false).when(corePlugin).isStagemonitorActive(); final SpanContextInformation spanContext = requestMonitor.monitor(createMonitoredRequest()); assertNull(spanContext); }
@Test public void testInternalMetricsActive() throws Exception { doReturn(true).when(corePlugin).isInternalMonitoringActive(); requestMonitor.monitor(createMonitoredRequest()); verify(registry).timer(name("internal_overhead_request_monitor").build()); }