use of com.navercorp.pinpoint.web.util.TimeWindow in project pinpoint by naver.
the class ApplicationStatController method getAgentStatChart.
@GetMapping()
public StatChart getAgentStatChart(@RequestParam("applicationId") String applicationId, @RequestParam("from") long from, @RequestParam("to") long to) {
TimeWindowSlotCentricSampler sampler = new TimeWindowSlotCentricSampler();
TimeWindow timeWindow = new TimeWindow(Range.newRange(from, to), sampler);
try {
return this.applicationStatChartService.selectApplicationChart(applicationId, timeWindow);
} catch (Exception e) {
logger.error("error", e);
throw e;
}
}
use of com.navercorp.pinpoint.web.util.TimeWindow in project pinpoint by naver.
the class SampledAgentStatResultExtractorTest method one_to_one_sampler_should_not_down_sample_data_points.
@Test
public void one_to_one_sampler_should_not_down_sample_data_points() throws Exception {
// Given
final int numValues = 10;
final long initialTimestamp = System.currentTimeMillis();
final long finalTimestamp = initialTimestamp + (DEFAULT_TIME_INTERVAL * numValues);
final TimeWindow timeWindow = new TimeWindow(Range.newRange(initialTimestamp, finalTimestamp), ONE_TO_ONE_SAMPLER);
final List<TestAgentStatDataPoint> dataPoints = createDataPoints(finalTimestamp, DEFAULT_TIME_INTERVAL, numValues);
final Map<Long, List<TestAgentStatDataPoint>> expectedDataPointSlotMap = getExpectedDataPointSlotMap(timeWindow, dataPoints);
when(this.rowMapper.mapRow(this.result, 0)).thenReturn(dataPoints);
TestAgentStatSampler testAgentStatSampler = new TestAgentStatSampler();
SampledAgentStatResultExtractor<TestAgentStatDataPoint, TestSampledAgentStatDataPoint> resultExtractor = new SampledAgentStatResultExtractor<>(timeWindow, this.rowMapper, testAgentStatSampler);
// When
List<TestSampledAgentStatDataPoint> sampledDataPoints = resultExtractor.extractData(this.resultScanner);
// Then
for (TestSampledAgentStatDataPoint sampledDataPoint : sampledDataPoints) {
List<TestAgentStatDataPoint> expectedSampledDataPoints = expectedDataPointSlotMap.get(sampledDataPoint.getBaseTimestamp());
Assert.assertEquals(expectedSampledDataPoints, sampledDataPoint.getDataPointsToSample());
}
}
Aggregations