@Test public void testMetadataMetricEnabledSpan() throws Exception { // given container.getConfigService().setPluginProperty(PLUGIN_ID, "captureDatabaseMetaDataSpans", true); // when container.executeAppUnderTest(AccessMetaData.class); // then Trace trace = container.getTraceService().getLastTrace(); assertThat(trace.getSpans()).hasSize(2); assertThat(trace.getSpans().get(1).getMessage().getText()) .startsWith("jdbc metadata:" + " DatabaseMetaData.getTables() [connection: "); assertThat(trace.getMetrics().size()).isEqualTo(2); assertThat(trace.getMetrics().get(0).getName()).isEqualTo("mock trace marker"); assertThat(trace.getMetrics().get(1).getName()).isEqualTo("jdbc metadata"); }
@Test public void testRollback() throws Exception { // given // when container.executeAppUnderTest(ExecuteJdbcRollback.class); // then Trace trace = container.getTraceService().getLastTrace(); assertThat(trace.getSpans()).hasSize(3); Span jdbcInsertSpan = trace.getSpans().get(1); assertThat(jdbcInsertSpan.getMessage().getText()) .startsWith( "jdbc execution: insert into employee (name) values ('john doe') [connection: "); Span jdbcCommitSpan = trace.getSpans().get(2); assertThat(jdbcCommitSpan.getMessage().getText()).startsWith("jdbc rollback [connection: "); assertThat(trace.getMetrics()).hasSize(4); // ordering is by total desc, so not fixed (though root span will be first since it // encompasses all other timings) assertThat(trace.getMetrics().get(0).getName()).isEqualTo("mock trace marker"); assertThat(trace.getMetricNames()) .containsOnly("mock trace marker", "jdbc execute", "jdbc rollback", "jdbc statement close"); }
@Test public void testResultSetValueMetric() throws Exception { // given container.getConfigService().setPluginProperty(PLUGIN_ID, "captureResultSetGet", true); // when container.executeAppUnderTest(ExecuteStatementAndIterateOverResults.class); // then Trace trace = container.getTraceService().getLastTrace(); boolean found = false; for (Metric metric : trace.getMetrics()) { if (metric.getName().equals("jdbc resultset value")) { found = true; break; } } assertThat(found).isTrue(); }