/** * {@inheritDoc} */ @Override public int compare(MethodSensorData o1, MethodSensorData o2, ICachedDataService cachedDataService) { if (null == cachedDataService) { return 0; } MethodIdent methodIdent1 = cachedDataService.getMethodIdentForId(o1.getMethodIdent()); MethodIdent methodIdent2 = cachedDataService.getMethodIdentForId(o2.getMethodIdent()); if ((null != methodIdent1) && (null != methodIdent2)) { return compare(methodIdent1, methodIdent2); } else { return 0; } }
/** * {@inheritDoc} */ @Override public String[] getStringValues(InvocationSequenceData invocSequence, ICachedDataService cachedDataService) { MethodIdent mIdent = cachedDataService.getMethodIdentForId(invocSequence.getMethodIdent()); if (null != mIdent) { return new String[] { mIdent.getFullyQualifiedMethodSignature() }; } else { return new String[0]; } }
/** * {@inheritDoc} */ @Override protected Comparable<?> getSeriesKey(TimerData template) { MethodIdent methodIdent = cachedDataService.getMethodIdentForId(template.getMethodIdent()); return TextFormatter.getMethodString(methodIdent); }
/** * {@inheritDoc} */ @Override public String getReadableString(Object object) { if (object instanceof ExceptionSensorData) { ExceptionSensorData data = (ExceptionSensorData) object; StringBuilder sb = new StringBuilder(); MethodIdent methodIdent = cachedDataService.getMethodIdentForId(data.getMethodIdent()); for (Column column : Column.values()) { sb.append(getStyledTextForColumn(data, methodIdent, column).toString()); sb.append('\t'); } return sb.toString(); } throw new RuntimeException("Could not create the human readable string!"); }
/** * {@inheritDoc} */ @Override public String getReadableString(Object object) { if (object instanceof InvocationSequenceData) { InvocationSequenceData data = (InvocationSequenceData) object; StringBuilder sb = new StringBuilder(); MethodIdent methodIdent = cachedDataService.getMethodIdentForId(data.getMethodIdent()); for (Column column : Column.values()) { sb.append(getStyledTextForColumn(data, methodIdent, column).toString()); sb.append('\t'); } return sb.toString(); } throw new RuntimeException("Could not create the human readable string!"); }
/** * {@inheritDoc} */ @Override public String getReadableString(Object object) { if (object instanceof ExceptionSensorData) { ExceptionSensorData data = (ExceptionSensorData) object; StringBuilder sb = new StringBuilder(); MethodIdent methodIdent = cachedDataService.getMethodIdentForId(data.getMethodIdent()); for (Column column : Column.values()) { sb.append(getStyledTextForColumn(data, methodIdent, column).toString()); sb.append('\t'); } return sb.toString(); } throw new RuntimeException("Could not create the human readable string!"); }
/** * {@inheritDoc} */ @Override public String getReadableString(Object object) { if (object instanceof TimerData) { TimerData data = (TimerData) object; StringBuilder sb = new StringBuilder(); MethodIdent methodIdent = cachedDataService.getMethodIdentForId(data.getMethodIdent()); for (Column column : Column.values()) { sb.append(getStyledTextForColumn(data, methodIdent, column).toString()); sb.append('\t'); } return sb.toString(); } throw new RuntimeException("Could not create the human readable string!"); }
/** * {@inheritDoc} */ @Override public String getReadableString(Object object) { if (object instanceof ExceptionSensorData) { ExceptionSensorData data = (ExceptionSensorData) object; StringBuilder sb = new StringBuilder(); MethodIdent methodIdent = cachedDataService.getMethodIdentForId(data.getMethodIdent()); for (Column column : Column.values()) { sb.append(getStyledTextForColumn(data, methodIdent, column).toString()); sb.append('\t'); } return sb.toString(); } throw new RuntimeException("Could not create the human readable string!"); }
/** * {@inheritDoc} */ @Override public String getReadableString(Object object) { if (object instanceof TimerData) { TimerData data = (TimerData) object; StringBuilder sb = new StringBuilder(); MethodIdent methodIdent = cachedDataService.getMethodIdentForId(data.getMethodIdent()); for (Column column : Column.values()) { sb.append(getStyledTextForColumn(data, methodIdent, column).toString()); sb.append('\t'); } return sb.toString(); } throw new RuntimeException("Could not create the human readable string!"); }
/** * {@inheritDoc} */ @Override public List<String> getColumnValues(Object object) { if (object instanceof ExceptionSensorData) { ExceptionSensorData data = (ExceptionSensorData) object; MethodIdent methodIdent = cachedDataService.getMethodIdentForId(data.getMethodIdent()); List<String> values = new ArrayList<>(); for (Column column : Column.values()) { values.add(getStyledTextForColumn(data, methodIdent, column).toString()); } return values; } throw new RuntimeException("Could not create the column values!"); }
/** * {@inheritDoc} */ @Override public List<String> getColumnValues(Object object) { if (object instanceof ExceptionSensorData) { ExceptionSensorData data = (ExceptionSensorData) object; MethodIdent methodIdent = cachedDataService.getMethodIdentForId(data.getMethodIdent()); List<String> values = new ArrayList<>(); for (Column column : Column.values()) { values.add(getStyledTextForColumn(data, methodIdent, column).toString()); } return values; } throw new RuntimeException("Could not create the column values!"); }
/** * {@inheritDoc} */ @Override public List<String> getColumnValues(Object object) { if (object instanceof InvocationSequenceData) { InvocationSequenceData data = (InvocationSequenceData) object; MethodIdent methodIdent = cachedDataService.getMethodIdentForId(data.getMethodIdent()); List<String> values = new ArrayList<>(); for (Column column : Column.values()) { values.add(getStyledTextForColumn(data, methodIdent, column).toString()); } return values; } throw new RuntimeException("Could not create the column values!"); }
/** * {@inheritDoc} */ @Override public List<String> getColumnValues(Object object) { if (object instanceof ExceptionSensorData) { ExceptionSensorData data = (ExceptionSensorData) object; MethodIdent methodIdent = cachedDataService.getMethodIdentForId(data.getMethodIdent()); List<String> values = new ArrayList<>(); for (Column column : Column.values()) { values.add(getStyledTextForColumn(data, methodIdent, column).toString()); } return values; } throw new RuntimeException("Could not create the column values!"); }
/** * {@inheritDoc} */ @Override public List<String> getColumnValues(Object object) { if (object instanceof TimerData) { TimerData data = (TimerData) object; MethodIdent methodIdent = cachedDataService.getMethodIdentForId(data.getMethodIdent()); List<String> values = new ArrayList<>(); for (Column column : Column.values()) { values.add(getStyledTextForColumn(data, methodIdent, column).toString()); } return values; } throw new RuntimeException("Could not create the column values!"); }
/** * {@inheritDoc} */ @Override public List<String> getColumnValues(Object object) { if (object instanceof TimerData) { TimerData data = (TimerData) object; MethodIdent methodIdent = cachedDataService.getMethodIdentForId(data.getMethodIdent()); List<String> values = new ArrayList<>(); for (Column column : Column.values()) { values.add(getStyledTextForColumn(data, methodIdent, column).toString()); } return values; } throw new RuntimeException("Could not create the column values!"); }
/** * {@inheritDoc} */ @Override public String[] getStringValues(InvocationSequenceData invocSequence, ICachedDataService cachedDataService) { MethodIdent mIdent = cachedDataService.getMethodIdentForId(invocSequence.getMethodIdent()); if ((null != mIdent) && Objects.equals(methodSignature, mIdent.getFullyQualifiedMethodSignature()) && InvocationSequenceDataHelper.hasCapturedParameters(invocSequence)) { for (ParameterContentData parameterContentData : InvocationSequenceDataHelper.getCapturedParameters(invocSequence, false)) { if (parameterIndex == parameterContentData.getSignaturePosition()) { return new String[] { parameterContentData.getContent() }; } } } return new String[0]; }
@Test public void noMethodIdent() throws Exception { when(cachedDataService.getPlatformIdentForId(PLATFORM_ID)).thenReturn(platformIdent); when(cachedDataService.getMethodIdentForId(METHOD_ID)).thenReturn(null); long time = RandomUtils.nextLong(); when(data.getPlatformIdent()).thenReturn(PLATFORM_ID); when(data.getMethodIdent()).thenReturn(METHOD_ID); when(data.getTimeStamp()).thenReturn(new Timestamp(time)); when(data.getDuration()).thenReturn(RandomUtils.nextDouble()); Collection<Builder> pointBuilderCol = builder.createBuilders(data); assertThat(pointBuilderCol.size(), is(1)); Builder pointBuilder = pointBuilderCol.iterator().next(); assertThat(getMeasurement(pointBuilder), is(Series.Methods.NAME)); assertThat(getTime(pointBuilder), is(time)); assertThat(getPrecision(pointBuilder), is(TimeUnit.MILLISECONDS)); assertThat(getTags(pointBuilder), not(hasKey(Series.Methods.TAG_CLASS_FQN))); assertThat(getTags(pointBuilder), not(hasKey(Series.Methods.TAG_METHOD_NAME))); assertThat(getTags(pointBuilder), not(hasKey(Series.Methods.TAG_METHOD_SIGNATURE))); }
/** * {@inheritDoc} */ @Override protected void addTags(TimerData data, Builder builder) { super.addTags(data, builder); MethodIdent methodIdent = cachedDataService.getMethodIdentForId(data.getMethodIdent()); if (null != methodIdent) { builder.tag(Series.Methods.TAG_METHOD_NAME, methodIdent.getMethodName()); builder.tag(Series.Methods.TAG_CLASS_FQN, methodIdent.getFQN()); builder.tag(Series.Methods.TAG_METHOD_SIGNATURE, methodIdent.getFullyQualifiedMethodSignature()); } }
@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)); }
@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)); }