Search in sources :

Example 26 with TimeWindow

use of com.navercorp.pinpoint.web.util.TimeWindow in project pinpoint by naver.

the class AgentStatController method getAgentStatChart.

@PreAuthorize("hasPermission(new com.navercorp.pinpoint.web.vo.AgentParam(#agentId, #to), 'agentParam', 'inspector')")
@RequestMapping(value = "/chart", method = RequestMethod.GET)
@ResponseBody
public AgentStatChartGroup getAgentStatChart(@RequestParam("agentId") String agentId, @RequestParam("from") long from, @RequestParam("to") long to) {
    TimeWindowSampler sampler = new TimeWindowSlotCentricSampler();
    TimeWindow timeWindow = new TimeWindow(new Range(from, to), sampler);
    return this.agentStatChartService.selectAgentChart(agentId, timeWindow);
}
Also used : TimeWindowSampler(com.navercorp.pinpoint.web.util.TimeWindowSampler) Range(com.navercorp.pinpoint.web.vo.Range) TimeWindow(com.navercorp.pinpoint.web.util.TimeWindow) TimeWindowSlotCentricSampler(com.navercorp.pinpoint.web.util.TimeWindowSlotCentricSampler) PreAuthorize(org.springframework.security.access.prepost.PreAuthorize) RequestMapping(org.springframework.web.bind.annotation.RequestMapping) ResponseBody(org.springframework.web.bind.annotation.ResponseBody)

Example 27 with TimeWindow

use of com.navercorp.pinpoint.web.util.TimeWindow in project pinpoint by naver.

the class AgentStatController method getAgentStatChartList.

@PreAuthorize("hasPermission(new com.navercorp.pinpoint.web.vo.AgentParam(#agentId, #to), 'agentParam', 'inspector')")
@RequestMapping(value = "/chartList", method = RequestMethod.GET, params = { "interval" })
@ResponseBody
public List<AgentStatChartGroup> getAgentStatChartList(@RequestParam("agentId") String agentId, @RequestParam("from") long from, @RequestParam("to") long to, @RequestParam("interval") Integer interval) {
    final int minSamplingInterval = 5;
    final long intervalMs = interval < minSamplingInterval ? minSamplingInterval * 1000L : interval * 1000L;
    TimeWindowSampler sampler = new TimeWindowSampler() {

        @Override
        public long getWindowSize(Range range) {
            return intervalMs;
        }
    };
    TimeWindow timeWindow = new TimeWindow(new Range(from, to), sampler);
    return this.agentStatChartService.selectAgentChartList(agentId, timeWindow);
}
Also used : TimeWindowSampler(com.navercorp.pinpoint.web.util.TimeWindowSampler) Range(com.navercorp.pinpoint.web.vo.Range) TimeWindow(com.navercorp.pinpoint.web.util.TimeWindow) AgentStatDataPoint(com.navercorp.pinpoint.common.server.bo.stat.AgentStatDataPoint) PreAuthorize(org.springframework.security.access.prepost.PreAuthorize) RequestMapping(org.springframework.web.bind.annotation.RequestMapping) ResponseBody(org.springframework.web.bind.annotation.ResponseBody)

Example 28 with TimeWindow

use of com.navercorp.pinpoint.web.util.TimeWindow in project pinpoint by naver.

the class LegacyAgentStatController method getAgentStatV2.

@Deprecated
@PreAuthorize("hasPermission(new com.navercorp.pinpoint.web.vo.AgentParam(#agentId, #to), 'agentParam', 'inspector')")
@RequestMapping(value = "/getAgentStat/v2", method = RequestMethod.GET)
@ResponseBody
public LegacyAgentStatChartGroup getAgentStatV2(@RequestParam("agentId") String agentId, @RequestParam("from") long from, @RequestParam("to") long to, @RequestParam(value = "sampleRate", required = false) Integer sampleRate) throws Exception {
    StopWatch watch = new StopWatch();
    watch.start("agentStatService.selectAgentStatList");
    TimeWindow timeWindow = new TimeWindow(new Range(from, to), new TimeWindowSlotCentricSampler());
    LegacyAgentStatChartGroup chartGroup = this.v2Service.selectAgentStatList(agentId, timeWindow);
    watch.stop();
    if (logger.isInfoEnabled()) {
        logger.info("getAgentStatV2(agentId={}, from={}, to={}) : {}ms", agentId, from, to, watch.getLastTaskTimeMillis());
    }
    return chartGroup;
}
Also used : LegacyAgentStatChartGroup(com.navercorp.pinpoint.web.vo.stat.chart.LegacyAgentStatChartGroup) Range(com.navercorp.pinpoint.web.vo.Range) TimeWindow(com.navercorp.pinpoint.web.util.TimeWindow) StopWatch(org.springframework.util.StopWatch) TimeWindowSlotCentricSampler(com.navercorp.pinpoint.web.util.TimeWindowSlotCentricSampler) PreAuthorize(org.springframework.security.access.prepost.PreAuthorize) RequestMapping(org.springframework.web.bind.annotation.RequestMapping) ResponseBody(org.springframework.web.bind.annotation.ResponseBody)

Example 29 with TimeWindow

use of com.navercorp.pinpoint.web.util.TimeWindow in project pinpoint by naver.

the class DataSourceChartGroupTest method basicFunctionTest1.

@Test
public void basicFunctionTest1() {
    long currentTimeMillis = System.currentTimeMillis();
    TimeWindow timeWindow = new TimeWindow(Range.newRange(currentTimeMillis - 300000, currentTimeMillis));
    List<SampledDataSource> sampledDataSourceList = createSampledDataSourceList(timeWindow);
    StatChartGroup dataSourceChartGroup = DataSourceChart.newDataSourceChartGroup(timeWindow, sampledDataSourceList, serviceTypeRegistryService);
    assertEquals(sampledDataSourceList, dataSourceChartGroup);
}
Also used : StatChartGroup(com.navercorp.pinpoint.web.vo.stat.chart.StatChartGroup) SampledDataSource(com.navercorp.pinpoint.web.vo.stat.SampledDataSource) TimeWindow(com.navercorp.pinpoint.web.util.TimeWindow) Test(org.junit.Test)

Example 30 with TimeWindow

use of com.navercorp.pinpoint.web.util.TimeWindow in project pinpoint by naver.

the class DataSourceChartGroupTest method basicFunctionTest2.

@Test
public void basicFunctionTest2() {
    long currentTimeMillis = System.currentTimeMillis();
    TimeWindow timeWindow = new TimeWindow(Range.newRange(currentTimeMillis - 300000, currentTimeMillis));
    List<SampledDataSource> sampledDataSourceList = Collections.emptyList();
    DataSourceChart dataSourceChartGroup = new DataSourceChart(timeWindow, sampledDataSourceList, serviceTypeRegistryService);
    Assert.assertEquals(-1, dataSourceChartGroup.getId());
    Assert.assertEquals(null, dataSourceChartGroup.getJdbcUrl());
    Assert.assertEquals(null, dataSourceChartGroup.getDatabaseName());
    Assert.assertEquals(null, dataSourceChartGroup.getServiceType());
    Map<StatChartGroup.ChartType, Chart<? extends Point>> charts = dataSourceChartGroup.getCharts().getCharts();
    Assert.assertEquals(2, charts.size());
    for (Chart<? extends Point> chart : charts.values()) {
        Assert.assertTrue(CollectionUtils.isEmpty(chart.getPoints()));
    }
}
Also used : SampledDataSource(com.navercorp.pinpoint.web.vo.stat.SampledDataSource) Point(com.navercorp.pinpoint.web.vo.chart.Point) TimeWindow(com.navercorp.pinpoint.web.util.TimeWindow) Chart(com.navercorp.pinpoint.web.vo.chart.Chart) 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