/** * {@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; } }
@Test public void noJmxIdent() throws Exception { when(cachedDataService.getPlatformIdentForId(PLATFORM_ID)).thenReturn(platformIdent); when(cachedDataService.getJmxDefinitionDataIdentForId(JMX_IDENT)).thenReturn(null); long time = RandomUtils.nextLong(); when(data.getPlatformIdent()).thenReturn(PLATFORM_ID); when(data.getJmxSensorDefinitionDataIdentId()).thenReturn(JMX_IDENT); when(data.getTimeStamp()).thenReturn(new Timestamp(time)); Collection<Builder> pointBuilderCol = builder.createBuilders(data); assertThat(pointBuilderCol.size(), is(1)); Builder pointBuilder = pointBuilderCol.iterator().next(); assertThat(getMeasurement(pointBuilder), is(Series.Jmx.NAME)); assertThat(getTime(pointBuilder), is(time)); assertThat(getPrecision(pointBuilder), is(TimeUnit.MILLISECONDS)); assertThat(getTags(pointBuilder), not(hasKey(Series.Jmx.TAG_JMX_ATTRIBUTE_FULL_NAME))); assertThat(getFields(pointBuilder), hasEntry(Series.Jmx.FIELD_VALUE, (Object) data.getValueAsDouble())); }
@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)); }
/** * {@inheritDoc} */ @Override public String[] getStringValues(InvocationSequenceData invocSequence, ICachedDataService cachedDataService) { PlatformIdent pIdent = cachedDataService.getPlatformIdentForId(invocSequence.getPlatformIdent()); if (null != pIdent) { List<String> ipList = pIdent.getDefinedIPs(); String[] result = new String[ipList.size()]; ipList.toArray(result); return result; } else { return new String[0]; } }
BusinessTransactionData businessTx = cachedDataService.getBusinessTransactionForId(data.getApplicationNameIdent(), data.getBusinessTransactionNameIdent()); if (null != businessTx) { businessTxName = businessTx.getName(); ApplicationData applicationData = cachedDataService.getApplicationForId(data.getApplicationNameIdent()); if (applicationData != null) { applicationName = applicationData.getName(); MethodIdent problemContextMethodIdent = cachedDataService.getMethodIdentForId(data.getProblemContext().getMethodIdent()); if (problemContextMethodIdent != null) { problemContextName = problemContextMethodIdent.getFQN() + "." + problemContextMethodIdent.getMethodName(); MethodIdent rootCauseMethodIdent = cachedDataService.getMethodIdentForId(data.getRootCause().getMethodIdent()); if (rootCauseMethodIdent != null) { rootCauseName = rootCauseMethodIdent.getFQN() + "." + rootCauseMethodIdent.getMethodName();
return TextFormatter.getPropagationStyled(span.getPropagationType()); case ORIGIN: return TextFormatter.getSpanOriginStyled(span, cachedDataService.getPlatformIdentForId(span.getPlatformIdent())); case TIME: return new StyledString(NumberFormatter.formatTimeWithMillis(span.getTimeStamp())); } else { int appId = applicationIds.iterator().next(); ApplicationData application = cachedDataService.getApplicationForId(appId); if (null != application) { return new StyledString(application.getName()); int appId = applicationIds.iterator().next(); int btId = transationsIds.iterator().next(); BusinessTransactionData transaction = cachedDataService.getBusinessTransactionForId(appId, btId); if (null != transaction) { return new StyledString(transaction.getName());
@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 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 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)); }
/** * {@inheritDoc} */ @Override public String getReadableString(Object object) { if (object instanceof JmxSensorValueData) { JmxSensorValueData data = (JmxSensorValueData) object; StringBuilder sb = new StringBuilder(); JmxDefinitionDataIdent jmxDefinitionDataIdent = cachedDataService.getJmxDefinitionDataIdentForId(data.getJmxSensorDefinitionDataIdentId()); for (Column column : Column.values()) { sb.append(getStyledTextForColumn(jmxDefinitionDataIdent, data, column).toString()); sb.append('\t'); } return sb.toString(); } throw new RuntimeException("Could not create the human readable string!"); }
/** * Sets data for the {@link BreadcrumbTitleComposite}. */ private void setDataForBreadcrumbTitleComposite() { // repository breadcrumbTitleComposite.setRepositoryDefinition(repositoryDefinition); // agent PlatformIdent platformIdent = repositoryDefinition.getCachedDataService().getPlatformIdentForId(defaultData.getPlatformIdent()); if (null != platformIdent) { breadcrumbTitleComposite.setAgent(TextFormatter.getAgentDescription(platformIdent), InspectIT.getDefault().getImage(InspectITImages.IMG_AGENT)); } else { breadcrumbTitleComposite.setAgent("All Agents", InspectIT.getDefault().getImage(InspectITImages.IMG_AGENT)); } // sensor info if (0 != defaultData.getSensorTypeIdent()) { SensorTypeIdent sensorTypeIdent = repositoryDefinition.getCachedDataService().getSensorTypeIdentForId(defaultData.getSensorTypeIdent()); String fqn = sensorTypeIdent.getFullyQualifiedClassName(); SensorTypeEnum sensorTypeEnum = SensorTypeEnum.get(fqn); if (null != sensorTypeEnum) { breadcrumbTitleComposite.setGroup(sensorTypeEnum.getDisplayName(), sensorTypeEnum.getImage()); } } else if (defaultData instanceof Span) { // must be set explicitly as no sensor id is set with user spans breadcrumbTitleComposite.setGroup("Tracing SDK", null); } breadcrumbTitleComposite.setView("Details", null); }
/** * {@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); }
/** * Checks if the given timer data has a sensor type that equals {@link SensorTypeEnum#TIMER} or * {@link SensorTypeEnum#AVERAGE_TIMER}, so that a special navigation types are possible or not. * * @param timerData * {@link TimerData} to check. * @return True if given object is of a TimerData class and mentioned sensor types are * registered. False otherwise. */ private boolean isTimerSensorBounded(TimerData timerData) { if ((null == timerData) || (!timerData.getClass().equals(TimerData.class) && !timerData.getClass().equals(AggregatedTimerData.class))) { return false; } IEditorPart editor = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().getActiveEditor(); if (editor instanceof AbstractRootEditor) { RepositoryDefinition repositoryDefinition = ((AbstractRootEditor) editor).getInputDefinition().getRepositoryDefinition(); SensorTypeIdent sensorTypeIdent = repositoryDefinition.getCachedDataService().getSensorTypeIdentForId(timerData.getSensorTypeIdent()); if (null != sensorTypeIdent) { SensorTypeEnum sensorTypeEnum = SensorTypeEnum.get(sensorTypeIdent.getFullyQualifiedClassName()); return (sensorTypeEnum == SensorTypeEnum.TIMER) || (sensorTypeEnum == SensorTypeEnum.AVERAGE_TIMER); } } return false; } }
@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)); }
/** * {@inheritDoc} */ @Override public String[] getStringValues(InvocationSequenceData invocSequence, ICachedDataService cachedDataService) { PlatformIdent pIdent = cachedDataService.getPlatformIdentForId(invocSequence.getPlatformIdent()); if (null != pIdent) { return new String[] { pIdent.getAgentName() }; } else { return new String[0]; } }
@Test public void noPlatform() throws Exception { when(cachedDataService.getPlatformIdentForId(PLATFORM_ID)).thenReturn(null); when(cachedDataService.getMethodIdentForId(METHOD_ID)).thenReturn(methodIdent); 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), hasEntry(Series.TAG_AGENT_ID, String.valueOf(PLATFORM_ID))); assertThat(getTags(pointBuilder), not(hasKey(Series.TAG_AGENT_NAME))); assertThat(getTags(pointBuilder), hasEntry(Series.Methods.TAG_CLASS_FQN, String.valueOf(FQN))); assertThat(getTags(pointBuilder), hasEntry(Series.Methods.TAG_METHOD_NAME, String.valueOf(METHOD))); assertThat(getTags(pointBuilder), hasEntry(Series.Methods.TAG_METHOD_SIGNATURE, String.valueOf(METHOD_SIG))); }
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;
@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)); }
/** * {@inheritDoc} */ @Override public List<String> getColumnValues(Object object) { if (object instanceof JmxSensorValueData) { JmxSensorValueData data = (JmxSensorValueData) object; JmxDefinitionDataIdent jmxDefinitionDataIdent = cachedDataService.getJmxDefinitionDataIdentForId(data.getJmxSensorDefinitionDataIdentId()); List<String> values = new ArrayList<>(); for (Column column : Column.values()) { values.add(getStyledTextForColumn(jmxDefinitionDataIdent, data, column).toString()); } return values; } throw new RuntimeException("Could not create the column values!"); }
@Override public void setInputDefinition(InputDefinition inputDefinition) { super.setInputDefinition(inputDefinition); cachedDataService = inputDefinition.getRepositoryDefinition().getCachedDataService(); if (0 != inputDefinition.getIdDefinition().getSensorTypeId()) { httpSensorTypeIdent = (MethodSensorTypeIdent) cachedDataService.getSensorTypeIdentForId(inputDefinition.getIdDefinition().getSensorTypeId()); String regEx = MethodSensorTypeIdentHelper.getRegEx(httpSensorTypeIdent); if (null != regEx) { try { Pattern.compile(regEx); regExEnabledInSensor = true; } catch (PatternSyntaxException e) { InspectIT.getDefault().createInfoDialog("The HTTP sensor defines the Regular expression " + regEx + " for URI transformation that can not be compiled. The transformation option will not be available.\n\n Reason: " + e.getMessage(), -1); } } } }