Search in sources :

Example 41 with TimeWindow

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;
    }
}
Also used : TimeWindow(com.navercorp.pinpoint.web.util.TimeWindow) TimeWindowSlotCentricSampler(com.navercorp.pinpoint.web.util.TimeWindowSlotCentricSampler) GetMapping(org.springframework.web.bind.annotation.GetMapping)

Example 42 with TimeWindow

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());
    }
}
Also used : TimeWindow(com.navercorp.pinpoint.web.util.TimeWindow) AgentStatDataPoint(com.navercorp.pinpoint.common.server.bo.stat.AgentStatDataPoint) SampledAgentStatDataPoint(com.navercorp.pinpoint.web.vo.stat.SampledAgentStatDataPoint) ArrayList(java.util.ArrayList) List(java.util.List) Test(org.junit.Test)

Aggregations

TimeWindow (com.navercorp.pinpoint.web.util.TimeWindow)42 Test (org.junit.Test)26 Range (com.navercorp.pinpoint.web.vo.Range)25 ArrayList (java.util.ArrayList)14 StatChartGroup (com.navercorp.pinpoint.web.vo.stat.chart.StatChartGroup)13 Chart (com.navercorp.pinpoint.web.vo.chart.Chart)12 Point (com.navercorp.pinpoint.web.vo.chart.Point)12 TimeWindowSampler (com.navercorp.pinpoint.web.util.TimeWindowSampler)8 TimeWindowSlotCentricSampler (com.navercorp.pinpoint.web.util.TimeWindowSlotCentricSampler)8 AgentStatDataPoint (com.navercorp.pinpoint.common.server.bo.stat.AgentStatDataPoint)7 PreAuthorize (org.springframework.security.access.prepost.PreAuthorize)7 RequestMapping (org.springframework.web.bind.annotation.RequestMapping)7 ResponseBody (org.springframework.web.bind.annotation.ResponseBody)7 SampledDataSource (com.navercorp.pinpoint.web.vo.stat.SampledDataSource)6 GetMapping (org.springframework.web.bind.annotation.GetMapping)5 List (java.util.List)4 LinkDataMap (com.navercorp.pinpoint.web.applicationmap.rawdata.LinkDataMap)3 SampledAgentStatDataPoint (com.navercorp.pinpoint.web.vo.stat.SampledAgentStatDataPoint)3 LegacyAgentStatChartGroup (com.navercorp.pinpoint.web.vo.stat.chart.LegacyAgentStatChartGroup)3 StopWatch (org.springframework.util.StopWatch)3