/** * Constructor that creates new ProblemOccurrence based on InvocationSequenceData. * * @param requestRoot * root InvocationSequenceData * @param globalContext * identified globalContext * @param rootCause * identified rootCauses */ public ProblemOccurrence(final InvocationSequenceData requestRoot, final InvocationSequenceData globalContext, final RootCause rootCause) { if (requestRoot == null) { throw new IllegalArgumentException("requestRoot cannot be null"); } if (globalContext == null) { throw new IllegalArgumentException("globalContext cannot be null"); } if (rootCause == null) { throw new IllegalArgumentException("rootCause cannot be null"); } this.businessTransactionNameIdent = requestRoot.getBusinessTransactionId(); this.applicationNameIdent = requestRoot.getApplicationId(); this.requestRoot = new InvocationIdentifier(requestRoot); this.globalContext = new InvocationIdentifier(globalContext); this.problemContext = new InvocationIdentifier(globalContext); this.rootCause = rootCause; this.causeType = CauseType.SINGLE; this.sourceType = SourceType.TIMERDATA; }
this.applicationNameIdent = requestRoot.getApplicationId(); this.requestRoot = new InvocationIdentifier(requestRoot); this.globalContext = new InvocationIdentifier(globalContext);
/** * Checks that the sequenceData have all the mandatory attributes. * * @param AggregatedDiagnosisInvocationData * Sequence data to check if has all the mandatory data. */ private void isAValidAggregatedDiagnosisData(AggregatedDiagnosisData AggregatedDiagnosisInvocationData) { for (InvocationSequenceData aggregatedSequence : AggregatedDiagnosisInvocationData.getRawInvocationsSequenceElements()) { assertThat("The aggregated sequence cannot be null", aggregatedSequence, notNullValue()); assertThat("Duration of the aggregated sequence cannot be null", aggregatedSequence.getDuration(), notNullValue()); assertThat("Start time of the aggregated cannot be null", aggregatedSequence.getStart(), notNullValue()); assertThat("End time of the aggregated cannot be null", aggregatedSequence.getEnd(), notNullValue()); assertThat("Child count of the aggregated sequence cannot be null", aggregatedSequence.getChildCount(), notNullValue()); assertThat("ApplicationId of the aggregated sequence cannot be null", aggregatedSequence.getApplicationId(), notNullValue()); assertThat("Business transaction id of the aggregated sequence cannot be null", aggregatedSequence.getBusinessTransactionId(), notNullValue()); } }
@Test public void noBusinessContext() throws Exception { when(cachedDataService.getPlatformIdentForId(PLATFORM_ID)).thenReturn(platformIdent); when(cachedDataService.getBusinessTransactionForId(APP_ID, BT_ID)).thenReturn(null); double duration = RandomUtils.nextDouble(); long time = RandomUtils.nextLong(); when(data.getPlatformIdent()).thenReturn(PLATFORM_ID); when(data.getApplicationId()).thenReturn(APP_ID); when(data.getBusinessTransactionId()).thenReturn(BT_ID); when(data.getTimeStamp()).thenReturn(new Timestamp(time)); when(data.getDuration()).thenReturn(duration); Collection<Builder> pointBuilderCol = builder.createBuilders(data); assertThat(pointBuilderCol.size(), is(1)); Builder pointBuilder = pointBuilderCol.iterator().next(); assertThat(getMeasurement(pointBuilder), is(Series.BusinessTransaction.NAME)); assertThat(getTime(pointBuilder), is(time)); assertThat(getPrecision(pointBuilder), is(TimeUnit.MILLISECONDS)); assertThat(getTags(pointBuilder), hasEntry(Series.TAG_AGENT_ID, String.valueOf(PLATFORM_ID))); assertThat(getTags(pointBuilder), hasEntry(Series.TAG_AGENT_NAME, String.valueOf(AGENT_NAME))); assertThat(getTags(pointBuilder), hasEntry(Series.BusinessTransaction.TAG_APPLICATION_NAME, String.valueOf(ApplicationDefinition.UNKNOWN_APP))); assertThat(getTags(pointBuilder), hasEntry(Series.BusinessTransaction.TAG_BUSINESS_TRANSACTION_NAME, String.valueOf(BusinessTransactionDefinition.UNKNOWN_BUSINESS_TX))); assertThat(getFields(pointBuilder), hasEntry(Series.BusinessTransaction.FIELD_DURATION, (Object) duration)); }
@Test public void noPlatform() throws Exception { when(cachedDataService.getPlatformIdentForId(PLATFORM_ID)).thenReturn(null); when(cachedDataService.getBusinessTransactionForId(APP_ID, BT_ID)).thenReturn(businessTransactionData); when(businessTransactionData.getApplication()).thenReturn(applicationData); double duration = RandomUtils.nextDouble(); long time = RandomUtils.nextLong(); when(data.getPlatformIdent()).thenReturn(PLATFORM_ID); when(data.getApplicationId()).thenReturn(APP_ID); when(data.getBusinessTransactionId()).thenReturn(BT_ID); when(data.getTimeStamp()).thenReturn(new Timestamp(time)); when(data.getDuration()).thenReturn(duration); Collection<Builder> pointBuilderCol = builder.createBuilders(data); assertThat(pointBuilderCol.size(), is(1)); Builder pointBuilder = pointBuilderCol.iterator().next(); assertThat(getMeasurement(pointBuilder), is(Series.BusinessTransaction.NAME)); assertThat(getTime(pointBuilder), is(time)); assertThat(getPrecision(pointBuilder), is(TimeUnit.MILLISECONDS)); assertThat(getTags(pointBuilder), hasEntry(Series.TAG_AGENT_ID, String.valueOf(PLATFORM_ID))); assertThat(getTags(pointBuilder), not(hasKey(Series.TAG_AGENT_NAME))); assertThat(getTags(pointBuilder), hasEntry(Series.BusinessTransaction.TAG_APPLICATION_NAME, String.valueOf(APP_NAME))); assertThat(getTags(pointBuilder), hasEntry(Series.BusinessTransaction.TAG_BUSINESS_TRANSACTION_NAME, String.valueOf(BT_NAME))); assertThat(getFields(pointBuilder), hasEntry(Series.BusinessTransaction.FIELD_DURATION, (Object) duration)); }
@Test public void happyPath() throws Exception { when(cachedDataService.getPlatformIdentForId(PLATFORM_ID)).thenReturn(platformIdent); when(cachedDataService.getBusinessTransactionForId(APP_ID, BT_ID)).thenReturn(businessTransactionData); when(businessTransactionData.getApplication()).thenReturn(applicationData); double duration = RandomUtils.nextDouble(); long time = RandomUtils.nextLong(); when(data.getPlatformIdent()).thenReturn(PLATFORM_ID); when(data.getApplicationId()).thenReturn(APP_ID); when(data.getBusinessTransactionId()).thenReturn(BT_ID); when(data.getTimeStamp()).thenReturn(new Timestamp(time)); when(data.getDuration()).thenReturn(duration); when(data.getId()).thenReturn(Long.MAX_VALUE); Collection<Builder> pointBuilderCol = builder.createBuilders(data); assertThat(pointBuilderCol.size(), is(1)); Builder pointBuilder = pointBuilderCol.iterator().next(); assertThat(getMeasurement(pointBuilder), is(Series.BusinessTransaction.NAME)); assertThat(getTime(pointBuilder), is(time)); assertThat(getPrecision(pointBuilder), is(TimeUnit.MILLISECONDS)); assertThat(getTags(pointBuilder), hasEntry(Series.TAG_AGENT_ID, String.valueOf(PLATFORM_ID))); assertThat(getTags(pointBuilder), hasEntry(Series.TAG_AGENT_NAME, String.valueOf(AGENT_NAME))); assertThat(getTags(pointBuilder), hasEntry(Series.BusinessTransaction.TAG_APPLICATION_NAME, String.valueOf(APP_NAME))); assertThat(getTags(pointBuilder), hasEntry(Series.BusinessTransaction.TAG_BUSINESS_TRANSACTION_NAME, String.valueOf(BT_NAME))); assertThat(getFields(pointBuilder), hasEntry(Series.BusinessTransaction.FIELD_DURATION, (Object) duration)); assertThat(getFields(pointBuilder), hasEntry(Series.BusinessTransaction.FIELD_TRACE_ID, (Object) Long.MAX_VALUE)); }
Set<Integer> applicationIds = new HashSet<>(1); for (InvocationSequenceData invoc : sequences) { applicationIds.add(invoc.getApplicationId()); Set<Integer> applicationIds = new HashSet<>(1); for (InvocationSequenceData invoc : sequences2) { applicationIds.add(invoc.getApplicationId()); transationsIds.add(invoc.getBusinessTransactionId());
/** * {@inheritDoc} */ @Override protected void addTags(InvocationSequenceData data, Builder builder) { super.addTags(data, builder); String businessTxName = BusinessTransactionDefinition.UNKNOWN_BUSINESS_TX; String applicationName = ApplicationDefinition.UNKNOWN_APP; BusinessTransactionData businessTx = cachedDataService.getBusinessTransactionForId(data.getApplicationId(), data.getBusinessTransactionId()); if (null != businessTx) { businessTxName = businessTx.getName(); applicationName = businessTx.getApplication().getName(); } builder.tag(Series.BusinessTransaction.TAG_APPLICATION_NAME, applicationName); builder.tag(Series.BusinessTransaction.TAG_BUSINESS_TRANSACTION_NAME, businessTxName); }
@Test public void matchEmptyApplication() { StringMatchingExpression stringMatchingExpression = new StringMatchingExpression(PatternMatchingType.CONTAINS, "root"); stringMatchingExpression.setStringValueSource(stringValueSource); stringMatchingExpression.setSearchNodeInTrace(false); StringMatchingExpression stringMatchingExpression_2 = new StringMatchingExpression(PatternMatchingType.CONTAINS, "nothing"); stringMatchingExpression_2.setStringValueSource(stringValueSource); stringMatchingExpression_2.setSearchNodeInTrace(false); applicationDefinition.setMatchingRuleExpression(stringMatchingExpression_2); applicationDefinition_empty.setMatchingRuleExpression(stringMatchingExpression); processor.process(root, entityManager); assertThat(root.getApplicationId(), equalTo(application_empty.getId())); assertThat(root.getBusinessTransactionId(), equalTo(businessTx_unknown.getId())); }
@Test public void businessContextChanged() throws InterruptedException { StringMatchingExpression stringMatchingExpression = new StringMatchingExpression(PatternMatchingType.CONTAINS, "root"); stringMatchingExpression.setStringValueSource(stringValueSource); stringMatchingExpression.setSearchNodeInTrace(false); StringMatchingExpression stringMatchingExpression_2 = new StringMatchingExpression(PatternMatchingType.CONTAINS, "node"); stringMatchingExpression_2.setStringValueSource(stringValueSource); stringMatchingExpression_2.setSearchNodeInTrace(false); applicationDefinition.setMatchingRuleExpression(stringMatchingExpression); businessTxDefinition_1.setMatchingRuleExpression(stringMatchingExpression_2); processor.onApplicationEvent(event); assertThat(root.getApplicationId(), equalTo(application.getId())); assertThat(root.getBusinessTransactionId(), equalTo(businessTx_1.getId())); }
/** * {@inheritDoc} */ @Override public DetailsTable generate(DefaultData defaultData, RepositoryDefinition repositoryDefinition, Composite parent, FormToolkit toolkit) { InvocationSequenceData invocationSequenceData = (InvocationSequenceData) defaultData; DetailsTable table = new DetailsTable(parent, toolkit, "Invocation Sequence Info", 1); ApplicationData application = repositoryDefinition.getCachedDataService().getApplicationForId(invocationSequenceData.getApplicationId()); if (null != application) { table.addContentRow("Application:", null, new DetailsCellContent[] { new DetailsCellContent(application.getName()) }); } BusinessTransactionData businessTxData = repositoryDefinition.getCachedDataService().getBusinessTransactionForId(invocationSequenceData.getApplicationId(), invocationSequenceData.getBusinessTransactionId()); if (null != businessTxData) { table.addContentRow("Business Transactions:", null, new DetailsCellContent[] { new DetailsCellContent(businessTxData.getName()) }); } table.addContentRow("Children Count:", null, new DetailsCellContent[] { new DetailsCellContent(String.valueOf(invocationSequenceData.getChildCount())) }); table.addContentRow("Nested SQLs:", null, new DetailsCellContent[] { new YesNoDetailsCellContent(InvocationSequenceDataHelper.hasNestedSqlStatements(invocationSequenceData)) }); table.addContentRow("Nested Exceptions:", null, new DetailsCellContent[] { new YesNoDetailsCellContent(InvocationSequenceDataHelper.hasNestedExceptions(invocationSequenceData)) }); return table; }
@Test public void match() { StringMatchingExpression stringMatchingExpression = new StringMatchingExpression(PatternMatchingType.CONTAINS, "root"); stringMatchingExpression.setStringValueSource(stringValueSource); stringMatchingExpression.setSearchNodeInTrace(false); StringMatchingExpression stringMatchingExpression_2 = new StringMatchingExpression(PatternMatchingType.CONTAINS, "nothing"); stringMatchingExpression_2.setStringValueSource(stringValueSource); stringMatchingExpression_2.setSearchNodeInTrace(false); applicationDefinition.setMatchingRuleExpression(stringMatchingExpression); applicationDefinition_empty.setMatchingRuleExpression(stringMatchingExpression_2); businessTxDefinition_1.setMatchingRuleExpression(stringMatchingExpression_2); businessTxDefinition_2.setMatchingRuleExpression(stringMatchingExpression); processor.process(root, entityManager); assertThat(root.getApplicationId(), equalTo(application.getId())); assertThat(root.getBusinessTransactionId(), equalTo(businessTx_2.getId())); }
@Test public void matchDefaultBT() { StringMatchingExpression stringMatchingExpression = new StringMatchingExpression(PatternMatchingType.CONTAINS, "root"); stringMatchingExpression.setStringValueSource(stringValueSource); stringMatchingExpression.setSearchNodeInTrace(false); StringMatchingExpression stringMatchingExpression_2 = new StringMatchingExpression(PatternMatchingType.CONTAINS, "nothing"); stringMatchingExpression_2.setStringValueSource(stringValueSource); stringMatchingExpression_2.setSearchNodeInTrace(false); applicationDefinition.setMatchingRuleExpression(stringMatchingExpression); applicationDefinition_empty.setMatchingRuleExpression(stringMatchingExpression_2); businessTxDefinition_1.setMatchingRuleExpression(stringMatchingExpression_2); businessTxDefinition_2.setMatchingRuleExpression(stringMatchingExpression_2); processor.process(root, entityManager); assertThat(root.getApplicationId(), equalTo(application.getId())); assertThat(root.getBusinessTransactionId(), equalTo(businessTx_unknown.getId())); }
@Test public void matchDefaultAppAndBT() { StringMatchingExpression stringMatchingExpression = new StringMatchingExpression(PatternMatchingType.CONTAINS, "nothing"); stringMatchingExpression.setStringValueSource(stringValueSource); stringMatchingExpression.setSearchNodeInTrace(false); StringMatchingExpression stringMatchingExpression_2 = new StringMatchingExpression(PatternMatchingType.CONTAINS, "nothing"); stringMatchingExpression_2.setStringValueSource(stringValueSource); stringMatchingExpression_2.setSearchNodeInTrace(false); applicationDefinition.setMatchingRuleExpression(stringMatchingExpression); applicationDefinition_empty.setMatchingRuleExpression(stringMatchingExpression_2); businessTxDefinition_1.setMatchingRuleExpression(stringMatchingExpression_2); businessTxDefinition_2.setMatchingRuleExpression(stringMatchingExpression_2); processor.process(root, entityManager); assertThat(root.getApplicationId(), equalTo(application_unknown.getId())); assertThat(root.getBusinessTransactionId(), equalTo(businessTx_unknown.getId())); }
@Test public void matchWithSearchInTrace() { StringMatchingExpression stringMatchingExpression = new StringMatchingExpression(PatternMatchingType.CONTAINS, "multiple"); stringMatchingExpression.setStringValueSource(stringValueSource); stringMatchingExpression.setSearchNodeInTrace(true); stringMatchingExpression.setMaxSearchDepth(2); StringMatchingExpression stringMatchingExpression_2 = new StringMatchingExpression(PatternMatchingType.CONTAINS, "nothing"); stringMatchingExpression_2.setStringValueSource(stringValueSource); stringMatchingExpression_2.setSearchNodeInTrace(false); applicationDefinition.setMatchingRuleExpression(stringMatchingExpression); applicationDefinition_empty.setMatchingRuleExpression(stringMatchingExpression_2); businessTxDefinition_1.setMatchingRuleExpression(stringMatchingExpression_2); businessTxDefinition_2.setMatchingRuleExpression(stringMatchingExpression); processor.process(root, entityManager); assertThat(root.getApplicationId(), equalTo(application.getId())); assertThat(root.getBusinessTransactionId(), equalTo(businessTx_2.getId())); }
ApplicationData appData1 = cachedDataService.getApplicationForId(o1.getApplicationId()); ApplicationData appData2 = cachedDataService.getApplicationForId(o2.getApplicationId()); String appName1 = null != appData1 ? appData1.getName().toLowerCase() : StringUtils.EMPTY; String appName2 = null != appData2 ? appData2.getName().toLowerCase() : StringUtils.EMPTY; return ObjectUtils.compare(appName1, appName2); case BUSINESS_TRANSACTION: BusinessTransactionData btData1 = cachedDataService.getBusinessTransactionForId(o1.getApplicationId(), o1.getBusinessTransactionId()); BusinessTransactionData btData2 = cachedDataService.getBusinessTransactionForId(o2.getApplicationId(), o2.getBusinessTransactionId()); String btName1 = null != btData1 ? btData1.getName().toLowerCase() : StringUtils.EMPTY; String btName2 = null != btData2 ? btData2.getName().toLowerCase() : StringUtils.EMPTY;
ApplicationData appData = cachedDataService.getApplicationForId(data.getApplicationId()); if (null != appData) { return new StyledString(appData.getName()); BusinessTransactionData btData = cachedDataService.getBusinessTransactionForId(data.getApplicationId(), data.getBusinessTransactionId()); if (null != btData) { return new StyledString(btData.getName());
/** * 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; }