@Test public void buildWithNestedExceptions() { Span span01 = createServerSpan(null); InvocationSequenceData invoc01 = createSequence(span01); InvocationSequenceData _invoc02 = createSequence(null); invoc01.getNestedSequences().add(_invoc02); invoc01.setNestedExceptions(true); doReturn(Arrays.asList(span01)).when(spanService).getSpans(1337L); doReturn(Arrays.asList(invoc01)).when(invocationService).getInvocationSequenceDetail(1337L); builder.setSpanService(spanService).setInvocationService(invocationService).setTraceId(1337L); InvocationTreeElement tree = builder.build(); Map<Object, InvocationTreeElement> lookupMap = InvocationTreeUtil.buildLookupMap(tree); assertThat(lookupMap.size(), is(3)); assertThat(tree.hasNestedExceptions(), is(true)); assertThat(tree.hasNestedSqls(), is(false)); }
/** * Process all the exceptions in the invData and passes exceptions to the chained processors. * <br> * <br> * Note also that only exception data with CREATED event are processed, since the PASSED and * HANDLED should be connected as children to the CREATED one. * * @param entityManager * {@link EntityManager} needed for DB persistence. * @param invData * Invocation data to be processed. * @param topInvocationParent * Top invocation object. */ private void processExceptionSensorData(EntityManager entityManager, InvocationSequenceData invData, InvocationSequenceData topInvocationParent) { if (CollectionUtils.isNotEmpty(invData.getExceptionSensorDataObjects())) { for (ExceptionSensorData exceptionData : invData.getExceptionSensorDataObjects()) { if (exceptionData.getExceptionEvent() == ExceptionEvent.CREATED) { // only if created exception is in invocation set to the parent topInvocationParent.setNestedExceptions(Boolean.TRUE); // we need to directly call Exception message processor, cause it can not be // chained exceptionMessageCmrProcessor.process(exceptionData, entityManager); exceptionData.addInvocationParentId(topInvocationParent.getId()); passToChainedProcessors(exceptionData, entityManager); } } } }
/** * Clones invocation sequence. This method returns new object exactly same as the original * object, but with out nested sequences set. * * @return Cloned invocation sequence. */ public InvocationSequenceData getClonedInvocationSequence() { InvocationSequenceData clone = new InvocationSequenceData(this.getTimeStamp(), this.getPlatformIdent(), this.getSensorTypeIdent(), this.getMethodIdent()); clone.setId(this.getId()); clone.setSpanIdent(this.getSpanIdent()); clone.setChildCount(this.getChildCount()); clone.setDuration(this.getDuration()); clone.setEnd(this.getEnd()); clone.setNestedSequences(Collections.<InvocationSequenceData> emptyList()); clone.setParameterContentData(this.getParameterContentData()); clone.setParentSequence(this.getParentSequence()); clone.setPosition(this.getPosition()); clone.setSqlStatementData(this.getSqlStatementData()); clone.setTimerData(this.getTimerData()); clone.setExceptionSensorDataObjects(this.getExceptionSensorDataObjects()); clone.setStart(this.getStart()); clone.setNestedSqlStatements(this.isNestedSqlStatements()); clone.setNestedExceptions(this.isNestedExceptions()); clone.setLoggingData(this.getLoggingData()); clone.setApplicationId(this.getApplicationId()); clone.setBusinessTransactionId(this.getBusinessTransactionId()); return clone; }