Search in sources :

Example 1 with ResponseStatsHistogramHandler

use of io.apiman.manager.api.jdbc.handlers.ResponseStatsHistogramHandler in project apiman by apiman.

the class JdbcMetricsAccessor method getResponseStats.

/**
 * @see io.apiman.manager.api.core.IMetricsAccessor#getResponseStats(java.lang.String, java.lang.String, java.lang.String, io.apiman.manager.api.beans.metrics.HistogramIntervalType, org.joda.time.DateTime, org.joda.time.DateTime)
 */
@Override
public ResponseStatsHistogramBean getResponseStats(String organizationId, String apiId, String version, HistogramIntervalType interval, DateTime from, DateTime to) {
    ResponseStatsHistogramBean rval = new ResponseStatsHistogramBean();
    Map<Long, ResponseStatsDataPoint> index = MetricsAccessorHelper.generateHistogramSkeleton(rval, from, to, interval, ResponseStatsDataPoint.class, Long.class);
    try {
        QueryRunner run = new QueryRunner(ds);
        String gbColumn = groupByColumn(interval);
        // $NON-NLS-1$ //$NON-NLS-2$
        String sql = "SELECT " + gbColumn + ", resp_type, count(*) FROM gw_requests WHERE api_org_id = ? AND api_id = ? AND api_version = ? AND rstart >= ? AND rstart < ? GROUP BY resp_type," + gbColumn;
        ResultSetHandler<ResponseStatsHistogramBean> handler = new ResponseStatsHistogramHandler(rval, index);
        run.query(sql, handler, organizationId, apiId, version, from.getMillis(), to.getMillis());
    } catch (SQLException e) {
        e.printStackTrace();
    }
    return rval;
}
Also used : ResponseStatsHistogramBean(io.apiman.manager.api.beans.metrics.ResponseStatsHistogramBean) ResponseStatsDataPoint(io.apiman.manager.api.beans.metrics.ResponseStatsDataPoint) ResponseStatsHistogramHandler(io.apiman.manager.api.jdbc.handlers.ResponseStatsHistogramHandler) SQLException(java.sql.SQLException) QueryRunner(org.apache.commons.dbutils.QueryRunner)

Aggregations

ResponseStatsDataPoint (io.apiman.manager.api.beans.metrics.ResponseStatsDataPoint)1 ResponseStatsHistogramBean (io.apiman.manager.api.beans.metrics.ResponseStatsHistogramBean)1 ResponseStatsHistogramHandler (io.apiman.manager.api.jdbc.handlers.ResponseStatsHistogramHandler)1 SQLException (java.sql.SQLException)1 QueryRunner (org.apache.commons.dbutils.QueryRunner)1