/** * 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; }
/** * {@inheritDoc} */ @Override public int hashCode() { final int prime = 31; int result = 1; result = (prime * result) + this.applicationNameIdent; result = (prime * result) + this.businessTransactionNameIdent; result = (prime * result) + ((this.causeType == null) ? 0 : this.causeType.hashCode()); result = (prime * result) + ((this.globalContext == null) ? 0 : this.globalContext.hashCode()); result = (prime * result) + ((this.problemContext == null) ? 0 : this.problemContext.hashCode()); result = (prime * result) + ((this.requestRoot == null) ? 0 : this.requestRoot.hashCode()); result = (prime * result) + ((this.rootCause == null) ? 0 : this.rootCause.hashCode()); result = (prime * result) + ((this.sourceType == null) ? 0 : this.sourceType.hashCode()); return result; }
@Test public void noApplicationData() throws Exception { when(cachedDataService.getApplicationForId(problemOccurrence.getApplicationNameIdent())).thenReturn(null); when(cachedDataService.getPlatformIdentForId(APP_ID)).thenReturn(null); when(cachedDataService.getBusinessTransactionForId(APP_ID, BUSINESS_TX_ID)).thenReturn(businessTransactionData); when(cachedDataService.getMethodIdentForId(invocationIdentifier.getMethodIdent())).thenReturn(methodIdent); Builder pointBuilder = builder.getBuilder(problemOccurrence); assertThat(getMeasurement(pointBuilder), is(Series.ProblemOccurrenceInformation.NAME)); assertThat(getPrecision(pointBuilder), is(TimeUnit.MILLISECONDS)); assertThat(getTags(pointBuilder), hasEntry(Series.ProblemOccurrenceInformation.TAG_APPLICATION_NAME, String.valueOf(ApplicationDefinition.UNKNOWN_APP))); assertThat(getTags(pointBuilder), hasEntry(Series.ProblemOccurrenceInformation.TAG_BUSINESS_TRANSACTION_NAME, String.valueOf(BUSINESS_TX))); assertThat(getTags(pointBuilder), hasEntry(Series.ProblemOccurrenceInformation.TAG_PROBLEM_CONTEXT_METHOD_NAME, FQN + "." + METHOD)); assertThat(getTags(pointBuilder), hasEntry(Series.ProblemOccurrenceInformation.TAG_ROOTCAUSE_METHOD_NAME, FQN + "." + METHOD)); assertThat(getTags(pointBuilder), hasEntry(Series.ProblemOccurrenceInformation.TAG_CAUSESTRUCTURE_CAUSE_TYPE, String.valueOf(causeType))); assertThat(getTags(pointBuilder), hasEntry(Series.ProblemOccurrenceInformation.TAG_CAUSESTRUCTURE_SOURCE_TYPE, String.valueOf(sourceType))); assertThat(getFields(pointBuilder), hasEntry(Series.ProblemOccurrenceInformation.FIELD_INVOCATION_ROOT_DURATION, DURATION)); assertThat(getFields(pointBuilder), hasEntry(Series.ProblemOccurrenceInformation.FIELD_GLOBAL_CONTEXT_METHOD_EXCLUSIVE_TIME, EXCLUSIVE_DURATION)); assertThat(getFields(pointBuilder), hasEntry(Series.ProblemOccurrenceInformation.FIELD_ROOTCAUSE_METHOD_EXCLUSIVE_TIME, EXCLUSIVE_DURATION)); }
@BeforeMethod public void init() { when(problemOccurrence.getApplicationNameIdent()).thenReturn(APP_ID); when(problemOccurrence.getBusinessTransactionNameIdent()).thenReturn(BUSINESS_TX_ID); when(problemOccurrence.getProblemContext()).thenReturn(invocationIdentifier); when(problemOccurrence.getRequestRoot()).thenReturn(invocationIdentifier); when(problemOccurrence.getGlobalContext()).thenReturn(invocationIdentifier); when(problemOccurrence.getCauseType()).thenReturn(causeType); when(problemOccurrence.getSourceType()).thenReturn(sourceType); when(problemOccurrence.getRootCause()).thenReturn(rootCause); when(invocationIdentifier.getDiagnosisTimerData()).thenReturn(diagnosisTimerData); when(rootCause.getAggregatedDiagnosisTimerData()).thenReturn(aggregatedDiagnosisTimerData); when(diagnosisTimerData.getDuration()).thenReturn(DURATION); when(diagnosisTimerData.getExclusiveDuration()).thenReturn(EXCLUSIVE_DURATION); when(aggregatedDiagnosisTimerData.getExclusiveDuration()).thenReturn(EXCLUSIVE_DURATION); when(applicationData.getName()).thenReturn(APPLICATION_NAME); when(businessTransactionData.getName()).thenReturn(BUSINESS_TX); when(methodIdent.getMethodName()).thenReturn(METHOD); when(methodIdent.getFQN()).thenReturn(FQN); }
@Test public void noBusinessContext() throws Exception { when(cachedDataService.getApplicationForId(problemOccurrence.getApplicationNameIdent())).thenReturn(applicationData); when(cachedDataService.getPlatformIdentForId(APP_ID)).thenReturn(platformIdent); when(cachedDataService.getBusinessTransactionForId(APP_ID, BUSINESS_TX_ID)).thenReturn(null); when(cachedDataService.getMethodIdentForId(invocationIdentifier.getMethodIdent())).thenReturn(methodIdent); Builder pointBuilder = builder.getBuilder(problemOccurrence); assertThat(getMeasurement(pointBuilder), is(Series.ProblemOccurrenceInformation.NAME)); assertThat(getPrecision(pointBuilder), is(TimeUnit.MILLISECONDS)); assertThat(getTags(pointBuilder), hasEntry(Series.ProblemOccurrenceInformation.TAG_APPLICATION_NAME, String.valueOf(APPLICATION_NAME))); assertThat(getTags(pointBuilder), hasEntry(Series.ProblemOccurrenceInformation.TAG_BUSINESS_TRANSACTION_NAME, BusinessTransactionDefinition.UNKNOWN_BUSINESS_TX)); assertThat(getTags(pointBuilder), hasEntry(Series.ProblemOccurrenceInformation.TAG_PROBLEM_CONTEXT_METHOD_NAME, FQN + "." + METHOD)); assertThat(getTags(pointBuilder), hasEntry(Series.ProblemOccurrenceInformation.TAG_ROOTCAUSE_METHOD_NAME, FQN + "." + METHOD)); assertThat(getTags(pointBuilder), hasEntry(Series.ProblemOccurrenceInformation.TAG_CAUSESTRUCTURE_CAUSE_TYPE, String.valueOf(causeType))); assertThat(getTags(pointBuilder), hasEntry(Series.ProblemOccurrenceInformation.TAG_CAUSESTRUCTURE_SOURCE_TYPE, String.valueOf(sourceType))); assertThat(getFields(pointBuilder), hasEntry(Series.ProblemOccurrenceInformation.FIELD_INVOCATION_ROOT_DURATION, DURATION)); assertThat(getFields(pointBuilder), hasEntry(Series.ProblemOccurrenceInformation.FIELD_GLOBAL_CONTEXT_METHOD_EXCLUSIVE_TIME, EXCLUSIVE_DURATION)); assertThat(getFields(pointBuilder), hasEntry(Series.ProblemOccurrenceInformation.FIELD_ROOTCAUSE_METHOD_EXCLUSIVE_TIME, EXCLUSIVE_DURATION)); }
/** * Add fields to builder. * * @param data * ProblemOccurrence instance * @param builder * Builder that can be used to create influx points. */ protected void addFields(ProblemOccurrence data, Builder builder) { builder.addField(Series.ProblemOccurrenceInformation.FIELD_INVOCATION_ROOT_DURATION, data.getRequestRoot().getDiagnosisTimerData().getDuration()); builder.addField(Series.ProblemOccurrenceInformation.FIELD_GLOBAL_CONTEXT_METHOD_EXCLUSIVE_TIME, data.getGlobalContext().getDiagnosisTimerData().getExclusiveDuration()); builder.addField(Series.ProblemOccurrenceInformation.FIELD_ROOTCAUSE_METHOD_EXCLUSIVE_TIME, data.getRootCause().getAggregatedDiagnosisTimerData().getExclusiveDuration()); builder.addField(Series.ProblemOccurrenceInformation.FIELD_ROOTCAUSE_METHOD_EXCLUSIVE_COUNT, data.getRootCause().getAggregatedDiagnosisTimerData().getExclusiveCount()); }
@Test public void noMethodIdentifier() throws Exception { when(cachedDataService.getApplicationForId(problemOccurrence.getApplicationNameIdent())).thenReturn(applicationData); when(cachedDataService.getPlatformIdentForId(APP_ID)).thenReturn(platformIdent); when(cachedDataService.getBusinessTransactionForId(APP_ID, BUSINESS_TX_ID)).thenReturn(businessTransactionData); when(cachedDataService.getMethodIdentForId(invocationIdentifier.getMethodIdent())).thenReturn(null); Builder pointBuilder = builder.getBuilder(problemOccurrence); assertThat(getMeasurement(pointBuilder), is(Series.ProblemOccurrenceInformation.NAME)); assertThat(getPrecision(pointBuilder), is(TimeUnit.MILLISECONDS)); assertThat(getTags(pointBuilder), hasEntry(Series.ProblemOccurrenceInformation.TAG_APPLICATION_NAME, String.valueOf(APPLICATION_NAME))); assertThat(getTags(pointBuilder), hasEntry(Series.ProblemOccurrenceInformation.TAG_BUSINESS_TRANSACTION_NAME, String.valueOf(BUSINESS_TX))); assertThat(getTags(pointBuilder), hasEntry(Series.ProblemOccurrenceInformation.TAG_PROBLEM_CONTEXT_METHOD_NAME, UNKNOWN_METHOD_FQN)); assertThat(getTags(pointBuilder), hasEntry(Series.ProblemOccurrenceInformation.TAG_ROOTCAUSE_METHOD_NAME, UNKNOWN_METHOD_FQN)); assertThat(getTags(pointBuilder), hasEntry(Series.ProblemOccurrenceInformation.TAG_CAUSESTRUCTURE_CAUSE_TYPE, String.valueOf(causeType))); assertThat(getTags(pointBuilder), hasEntry(Series.ProblemOccurrenceInformation.TAG_CAUSESTRUCTURE_SOURCE_TYPE, String.valueOf(sourceType))); assertThat(getFields(pointBuilder), hasEntry(Series.ProblemOccurrenceInformation.FIELD_INVOCATION_ROOT_DURATION, DURATION)); assertThat(getFields(pointBuilder), hasEntry(Series.ProblemOccurrenceInformation.FIELD_GLOBAL_CONTEXT_METHOD_EXCLUSIVE_TIME, EXCLUSIVE_DURATION)); assertThat(getFields(pointBuilder), hasEntry(Series.ProblemOccurrenceInformation.FIELD_ROOTCAUSE_METHOD_EXCLUSIVE_TIME, EXCLUSIVE_DURATION)); } }
this.requestRoot = new InvocationIdentifier(requestRoot); this.globalContext = new InvocationIdentifier(globalContext); this.problemContext = new InvocationIdentifier(problemContext); this.rootCause = rootCause; this.causeType = causeType;
@Test public void happyPath() throws Exception { when(cachedDataService.getApplicationForId(problemOccurrence.getApplicationNameIdent())).thenReturn(applicationData); when(cachedDataService.getPlatformIdentForId(APP_ID)).thenReturn(platformIdent); when(cachedDataService.getBusinessTransactionForId(APP_ID, BUSINESS_TX_ID)).thenReturn(businessTransactionData); when(cachedDataService.getMethodIdentForId(invocationIdentifier.getMethodIdent())).thenReturn(methodIdent); Builder pointBuilder = builder.getBuilder(problemOccurrence); assertThat(getMeasurement(pointBuilder), is(Series.ProblemOccurrenceInformation.NAME)); assertThat(getPrecision(pointBuilder), is(TimeUnit.MILLISECONDS)); assertThat(getTags(pointBuilder), hasEntry(Series.ProblemOccurrenceInformation.TAG_APPLICATION_NAME, String.valueOf(APPLICATION_NAME))); assertThat(getTags(pointBuilder), hasEntry(Series.ProblemOccurrenceInformation.TAG_BUSINESS_TRANSACTION_NAME, String.valueOf(BUSINESS_TX))); assertThat(getTags(pointBuilder), hasEntry(Series.ProblemOccurrenceInformation.TAG_PROBLEM_CONTEXT_METHOD_NAME, FQN + "." + METHOD)); assertThat(getTags(pointBuilder), hasEntry(Series.ProblemOccurrenceInformation.TAG_ROOTCAUSE_METHOD_NAME, FQN + "." + METHOD)); assertThat(getTags(pointBuilder), hasEntry(Series.ProblemOccurrenceInformation.TAG_CAUSESTRUCTURE_CAUSE_TYPE, String.valueOf(causeType))); assertThat(getTags(pointBuilder), hasEntry(Series.ProblemOccurrenceInformation.TAG_CAUSESTRUCTURE_SOURCE_TYPE, String.valueOf(sourceType))); assertThat(getFields(pointBuilder), hasEntry(Series.ProblemOccurrenceInformation.FIELD_INVOCATION_ROOT_DURATION, DURATION)); assertThat(getFields(pointBuilder), hasEntry(Series.ProblemOccurrenceInformation.FIELD_GLOBAL_CONTEXT_METHOD_EXCLUSIVE_TIME, EXCLUSIVE_DURATION)); assertThat(getFields(pointBuilder), hasEntry(Series.ProblemOccurrenceInformation.FIELD_ROOTCAUSE_METHOD_EXCLUSIVE_TIME, EXCLUSIVE_DURATION)); }
@Test public void noPlatform() throws Exception { when(cachedDataService.getApplicationForId(problemOccurrence.getApplicationNameIdent())).thenReturn(applicationData); when(cachedDataService.getPlatformIdentForId(APP_ID)).thenReturn(null); when(cachedDataService.getBusinessTransactionForId(APP_ID, BUSINESS_TX_ID)).thenReturn(businessTransactionData); when(cachedDataService.getMethodIdentForId(invocationIdentifier.getMethodIdent())).thenReturn(methodIdent); Builder pointBuilder = builder.getBuilder(problemOccurrence); assertThat(getMeasurement(pointBuilder), is(Series.ProblemOccurrenceInformation.NAME)); assertThat(getPrecision(pointBuilder), is(TimeUnit.MILLISECONDS)); assertThat(getTags(pointBuilder), hasEntry(Series.ProblemOccurrenceInformation.TAG_APPLICATION_NAME, String.valueOf(APPLICATION_NAME))); assertThat(getTags(pointBuilder), hasEntry(Series.ProblemOccurrenceInformation.TAG_BUSINESS_TRANSACTION_NAME, String.valueOf(BUSINESS_TX))); assertThat(getTags(pointBuilder), hasEntry(Series.ProblemOccurrenceInformation.TAG_PROBLEM_CONTEXT_METHOD_NAME, FQN + "." + METHOD)); assertThat(getTags(pointBuilder), hasEntry(Series.ProblemOccurrenceInformation.TAG_ROOTCAUSE_METHOD_NAME, FQN + "." + METHOD)); assertThat(getTags(pointBuilder), hasEntry(Series.ProblemOccurrenceInformation.TAG_CAUSESTRUCTURE_CAUSE_TYPE, String.valueOf(causeType))); assertThat(getTags(pointBuilder), hasEntry(Series.ProblemOccurrenceInformation.TAG_CAUSESTRUCTURE_SOURCE_TYPE, String.valueOf(sourceType))); assertThat(getFields(pointBuilder), hasEntry(Series.ProblemOccurrenceInformation.FIELD_INVOCATION_ROOT_DURATION, DURATION)); assertThat(getFields(pointBuilder), hasEntry(Series.ProblemOccurrenceInformation.FIELD_GLOBAL_CONTEXT_METHOD_EXCLUSIVE_TIME, EXCLUSIVE_DURATION)); assertThat(getFields(pointBuilder), hasEntry(Series.ProblemOccurrenceInformation.FIELD_ROOTCAUSE_METHOD_EXCLUSIVE_TIME, EXCLUSIVE_DURATION)); }
MethodIdent problemContextMethodIdent = cachedDataService.getMethodIdentForId(data.getProblemContext().getMethodIdent()); if (problemContextMethodIdent != null) { problemContextName = problemContextMethodIdent.getFQN() + "." + problemContextMethodIdent.getMethodName();