コード例 #1
0
  /**
   * Get top n external service response time trend data.
   *
   * @param appId the application identification
   * @param time time range, only one
   * @param period period in second
   * @param limit top n limit
   * @return application level top n
   */
  @RequestMapping(value = {"trend/rt"})
  public TrendResponse responseTime(
      @RequestParam(value = "appId") Long appId,
      @RequestParam(value = "time[]") String[] time,
      @RequestParam(value = "period") Long period,
      @RequestParam(value = "limit", defaultValue = "5") Integer limit) {
    validApplicationId(appId, RETRIEVE_APP_RT_TREND);
    validSingleTimeRanges(time, RETRIEVE_APP_RT_TREND);
    validPeriod(period, RETRIEVE_APP_RT_TREND);
    validLimit(limit, RETRIEVE_APP_RT_TREND);

    final StatisticMetricValue[] metricName = new StatisticMetricValue[] {RESPONSE_TIME, PV, CPM};
    List<TimeRange> timeRanges = TimeUtils.convertToRange(time);

    final TimeRange timeRange = timeRanges.get(0);

    Iterable<ExternalService> transactions = automaticService.getExternalServicesOfApp(appId);

    Iterable<ExternalServiceStatistic> transactionsStatistic =
        automaticService.getExternalServiceStatistic(transactions, timeRange, period);

    TrendContext<String> trendContext =
        ExternalServiceUtils.topByAvgResponseTime(
            period, limit, timeRange, transactions, transactionsStatistic);

    return TrendUtils.toTrendResponse(trendContext, metricName);
  }
コード例 #2
0
  /**
   * Get all external service cpm of the application.
   *
   * @param appId the application identification
   * @param time time range, only one
   * @param period period in second
   * @return application level cpm
   */
  @RequestMapping(value = {"trend/cpm"})
  public TrendResponse cpm(
      @RequestParam(value = "appId") Long appId,
      @RequestParam(value = "time[]") String[] time,
      @RequestParam(value = "period") Long period) {
    validApplicationId(appId, RETRIEVE_APP_CPM_TREND);
    validTimeRanges(time, RETRIEVE_APP_CPM_TREND);
    validPeriod(period, RETRIEVE_APP_CPM_TREND);

    final StatisticMetricValue[] metricName = new StatisticMetricValue[] {CPM, RESPONSE_TIME, PV};
    final ServiceType serviceType = ServiceType.EXTERNAL;
    List<TimeRange> timeRanges = TimeUtils.convertToRange(time);

    TrendContext trendContext =
        automaticService.getMetricDataOfApp(appId, timeRanges, period, serviceType);

    return TrendUtils.toTrendResponse(trendContext, metricName);
  }