/** * Checks if this data has the inspectIT tagging header set. * * @return if this data has the inspectIT tagging header set. */ public boolean hasInspectItTaggingHeader() { return null != getInspectItTaggingHeaderValue(); }
HttpInfo httpInfo = httpTimerData.getHttpInfo(); String tag = httpInfo.hasInspectItTaggingHeader() ? httpInfo.getInspectItTaggingHeaderValue() : null; // NOPMD String requestMethod = httpInfo.getRequestMethod();
/** * Finds matching template for the given {@link HttpTimerData} by tag value. * * @param httpTimerData * Data to find matching template. * @param templates * List of templates to search. * @return Matching template of <code>null</code> if one can not be found. */ private HttpTimerData findTemplateForTagData(HttpTimerData httpTimerData, List<HttpTimerData> templates) { for (HttpTimerData template : templates) { if (Objects.equals(template.getHttpInfo().getInspectItTaggingHeaderValue(), httpTimerData.getHttpInfo().getInspectItTaggingHeaderValue())) { if (HttpTimerData.REQUEST_METHOD_MULTIPLE.equals(template.getHttpInfo().getRequestMethod()) || Objects.equals(template.getHttpInfo().getRequestMethod(), httpTimerData.getHttpInfo().getRequestMethod())) { return template; } } } return null; }
tags.add(httpTimerData.getHttpInfo().getInspectItTaggingHeaderValue());
/** * {@inheritDoc} */ @Override public Object getAggregationKey(HttpTimerData httpData) { final int prime = 31; int result = 0; if (uriBased) { result = (prime * result) + ((httpData.getHttpInfo().getUri() == null) ? 0 : httpData.getHttpInfo().getUri().hashCode()); } else { result = (prime * result) + ((httpData.getHttpInfo().getInspectItTaggingHeaderValue() == null) ? 0 : httpData.getHttpInfo().getInspectItTaggingHeaderValue().hashCode()); } if (includeRequestMethod) { result = (prime * result) + ((httpData.getHttpInfo().getRequestMethod() == null) ? 0 : httpData.getHttpInfo().getRequestMethod().hashCode()); } return result; }
/** * {@inheritDoc} */ @Override public List<HttpTimerData> getChartingHttpTimerDataFromDateToDate(Collection<HttpTimerData> templates, Date fromDate, Date toDate, boolean retrieveByTag) { if (CollectionUtils.isNotEmpty(templates)) { StorageIndexQuery query = httpDataQueryFactory.getFindAllHttpTimersQuery(templates.iterator().next(), fromDate, toDate); if (!retrieveByTag) { Set<String> uris = new HashSet<>(); for (HttpTimerData httpTimerData : templates) { if (!HttpInfo.UNDEFINED.equals(httpTimerData.getHttpInfo().getUri())) { uris.add(httpTimerData.getHttpInfo().getUri()); } } query.addIndexingRestriction(IndexQueryRestrictionFactory.isInCollection("uri", uris)); } else { Set<String> tags = new HashSet<>(); for (HttpTimerData httpTimerData : templates) { if (httpTimerData.getHttpInfo().hasInspectItTaggingHeader()) { tags.add(httpTimerData.getHttpInfo().getInspectItTaggingHeaderValue()); } } query.addIndexingRestriction(IndexQueryRestrictionFactory.isInCollection("inspectItTaggingHeaderValue", tags)); } return super.executeQuery(query, TIMESTAMP_COMPARATOR); } else { return Collections.emptyList(); } }
@Test public void noUri() throws Exception { when(cachedDataService.getPlatformIdentForId(PLATFORM_ID)).thenReturn(null); long time = RandomUtils.nextLong(); when(data.getPlatformIdent()).thenReturn(PLATFORM_ID); when(data.getTimeStamp()).thenReturn(new Timestamp(time)); when(data.getHttpInfo()).thenReturn(httpInfo); when(httpInfo.getUri()).thenReturn(null); when(httpInfo.hasInspectItTaggingHeader()).thenReturn(false); when(httpInfo.getInspectItTaggingHeaderValue()).thenReturn(null); Collection<Builder> pointBuilderCol = builder.createBuilders(data); assertThat(pointBuilderCol.size(), is(1)); Builder pointBuilder = pointBuilderCol.iterator().next(); assertThat(getMeasurement(pointBuilder), is(Series.Http.NAME)); assertThat(getTime(pointBuilder), is(time)); assertThat(getPrecision(pointBuilder), is(TimeUnit.MILLISECONDS)); assertThat(getTags(pointBuilder), not(hasKey(Series.Http.TAG_URI))); assertThat(getFields(pointBuilder), hasEntry(Series.Http.FIELD_DURATION, (Object) data.getDuration())); }
@Test public void noTag() throws Exception { when(cachedDataService.getPlatformIdentForId(PLATFORM_ID)).thenReturn(platformIdent); long time = RandomUtils.nextLong(); when(data.getPlatformIdent()).thenReturn(PLATFORM_ID); when(data.getTimeStamp()).thenReturn(new Timestamp(time)); when(data.getHttpInfo()).thenReturn(httpInfo); when(httpInfo.getUri()).thenReturn(URI); when(httpInfo.hasInspectItTaggingHeader()).thenReturn(false); when(httpInfo.getInspectItTaggingHeaderValue()).thenReturn(null); Collection<Builder> pointBuilderCol = builder.createBuilders(data); assertThat(pointBuilderCol.size(), is(1)); Builder pointBuilder = pointBuilderCol.iterator().next(); assertThat(getMeasurement(pointBuilder), is(Series.Http.NAME)); assertThat(getTime(pointBuilder), is(time)); assertThat(getPrecision(pointBuilder), is(TimeUnit.MILLISECONDS)); assertThat(getTags(pointBuilder), not(hasKey(Series.Http.TAG_INSPECTIT_TAGGING_HEADER))); assertThat(getFields(pointBuilder), hasEntry(Series.Http.FIELD_DURATION, (Object) data.getDuration())); }
@Test public void noPlatform() throws Exception { when(cachedDataService.getPlatformIdentForId(PLATFORM_ID)).thenReturn(null); long time = RandomUtils.nextLong(); when(data.getPlatformIdent()).thenReturn(PLATFORM_ID); when(data.getTimeStamp()).thenReturn(new Timestamp(time)); when(data.getHttpInfo()).thenReturn(httpInfo); when(httpInfo.getUri()).thenReturn(URI); when(httpInfo.hasInspectItTaggingHeader()).thenReturn(true); when(httpInfo.getInspectItTaggingHeaderValue()).thenReturn(TAG); Collection<Builder> pointBuilderCol = builder.createBuilders(data); assertThat(pointBuilderCol.size(), is(1)); Builder pointBuilder = pointBuilderCol.iterator().next(); assertThat(getMeasurement(pointBuilder), is(Series.Http.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(getFields(pointBuilder), hasEntry(Series.Http.FIELD_DURATION, (Object) data.getDuration())); }
@Test public void happyPath() throws Exception { when(cachedDataService.getPlatformIdentForId(PLATFORM_ID)).thenReturn(platformIdent); long time = RandomUtils.nextLong(); when(data.getPlatformIdent()).thenReturn(PLATFORM_ID); when(data.getTimeStamp()).thenReturn(new Timestamp(time)); when(data.getDuration()).thenReturn(RandomUtils.nextDouble()); when(data.getHttpInfo()).thenReturn(httpInfo); when(httpInfo.getUri()).thenReturn(URI); when(httpInfo.hasInspectItTaggingHeader()).thenReturn(true); when(httpInfo.getInspectItTaggingHeaderValue()).thenReturn(TAG); Collection<Builder> pointBuilderCol = builder.createBuilders(data); assertThat(pointBuilderCol.size(), is(1)); Builder pointBuilder = pointBuilderCol.iterator().next(); assertThat(getMeasurement(pointBuilder), is(Series.Http.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.Http.TAG_URI, String.valueOf(URI))); assertThat(getTags(pointBuilder), hasEntry(Series.Http.TAG_INSPECTIT_TAGGING_HEADER, String.valueOf(TAG))); assertThat(getFields(pointBuilder), hasEntry(Series.Http.FIELD_DURATION, (Object) data.getDuration())); }
/** * {@inheritDoc} */ @Override protected void addTags(HttpTimerData data, Builder builder) { super.addTags(data, builder); HttpInfo httpInfo = data.getHttpInfo(); if (null != httpInfo.getUri()) { builder.tag(Series.Http.TAG_URI, httpInfo.getUri()); } if (httpInfo.hasInspectItTaggingHeader()) { builder.tag(Series.Http.TAG_INSPECTIT_TAGGING_HEADER, httpInfo.getInspectItTaggingHeaderValue()); } }
/** * {@inheritDoc} */ @Override public int compare(HttpTimerData o1, HttpTimerData o2) { switch (this) { case URI: return ObjectUtils.compare(o1.getHttpInfo().getUri(), o2.getHttpInfo().getUri()); case HTTP_METHOD: return ObjectUtils.compare(o1.getHttpInfo().getRequestMethod(), o2.getHttpInfo().getRequestMethod()); case TAG_VALUE: return ObjectUtils.compare(o1.getHttpInfo().getInspectItTaggingHeaderValue(), o2.getHttpInfo().getInspectItTaggingHeaderValue()); default: return 0; } }
table.addContentRow("Tag Value:", null, new DetailsCellContent[] { new DetailsCellContent(httpTimerData.getHttpInfo().getInspectItTaggingHeaderValue()) });
assertThat(result.getHttpInfo().getUri(), is(equalTo(HttpInfo.UNDEFINED))); assertThat(result.getHttpInfo().hasInspectItTaggingHeader(), is(equalTo(true))); assertThat(result.getHttpInfo().getInspectItTaggingHeaderValue(), is(equalTo("tag1"))); assertThat(result.getDuration(), is(equalTo(600d))); assertThat(result.getCpuDuration(), is(equalTo(30d)));
/** * Returns the series key for the {@link HttpTimerData} object. * * @param httpTimerData * {@link HttpTimerData}. * @return Key used to initialize the series and later on compare which series data should be * added to. */ @Override protected Comparable<?> getSeriesKey(HttpTimerData httpTimerData) { if (regExTransformation && (httpTimerData instanceof RegExAggregatedHttpTimerData)) { return "Transformed URI: " + ((RegExAggregatedHttpTimerData) httpTimerData).getTransformedUri() + " [" + httpTimerData.getHttpInfo().getRequestMethod() + "]"; } else { if (plotByTagValue) { return "Tag: " + httpTimerData.getHttpInfo().getInspectItTaggingHeaderValue() + " [" + httpTimerData.getHttpInfo().getRequestMethod() + "]"; } else { return "URI: " + httpTimerData.getHttpInfo().getUri() + " [" + httpTimerData.getHttpInfo().getRequestMethod() + "]"; } } }
return "URI: " + timerData.getHttpInfo().getUri(); } else { return "Usecase: " + timerData.getHttpInfo().getInspectItTaggingHeaderValue();
HttpTimerData template = templates.get(0); if (plotByTagValue) { editorPropertiesData.setViewName("Tag: " + template.getHttpInfo().getInspectItTaggingHeaderValue() + " [" + template.getHttpInfo().getRequestMethod() + "]"); } else { editorPropertiesData.setViewName("URI: " + template.getHttpInfo().getUri() + " [" + template.getHttpInfo().getRequestMethod() + "]");
case USE_CASE: if (InvocationSequenceDataHelper.hasHttpTimerData(o1) && InvocationSequenceDataHelper.hasHttpTimerData(o2)) { String useCase1 = ((HttpTimerData) o1.getTimerData()).getHttpInfo().getInspectItTaggingHeaderValue(); String useCase2 = ((HttpTimerData) o2.getTimerData()).getHttpInfo().getInspectItTaggingHeaderValue(); return ObjectUtils.compare(useCase1, useCase2); } else if (InvocationSequenceDataHelper.hasHttpTimerData(o1)) {
/** * {@inheritDoc} */ @Override public IAggregatedData<HttpTimerData> getClone(HttpTimerData httpData) { AggregatedHttpTimerData clone = new AggregatedHttpTimerData(); clone.setPlatformIdent(httpData.getPlatformIdent()); clone.setSensorTypeIdent(httpData.getSensorTypeIdent()); clone.setMethodIdent(httpData.getMethodIdent()); clone.setCharting(httpData.isCharting()); if (uriBased) { clone.getHttpInfo().setUri(httpData.getHttpInfo().getUri()); } else { // Aggregation based on Usecase. We reset the URI so that we can easily know // that use case aggregation is used. clone.getHttpInfo().setUri(HttpInfo.UNDEFINED); clone.getHttpInfo().setInspectItTaggingHeaderValue(httpData.getHttpInfo().getInspectItTaggingHeaderValue()); } clone.getHttpInfo().setRequestMethod(httpData.getHttpInfo().getRequestMethod()); return clone; }
String useCase = ((HttpTimerData) data.getTimerData()).getHttpInfo().getInspectItTaggingHeaderValue(); if (null != useCase) { return new StyledString(useCase);