springboot访问tomcat的SlowQueryReport

tomcat jdbc提供了SlowQueryReport这种的interceptor,可以用来记录超过阈值的慢查询sql,除了SlowQueryReportJmx提供jmx访问外,普通web如何访问相关统计信息呢?

获取QueryStats

SlowQueryReport提供了一个静态统计map出来,因此可以直接调用

@RequestMapping(value = "/slow-sql",method = RequestMethod.GET)
    public Object getSlowSql(){
        return SlowQueryReport.getPoolStats(connectionPool.getPool().getName());
    }

返回实例

{
  "select relname from pg_class where relkind='S'": {
    "query": "select relname from pg_class where relkind='S'",
    "nrOfInvocations": 1,
    "maxInvocationTime": 1,
    "maxInvocationDate": 1499354543914,
    "minInvocationTime": 1,
    "minInvocationDate": 1499354543914,
    "totalInvocationTime": 1
  },
  "select authuser0_.id as id1_0_, authuser0_.created_by as created_2_0_, authuser0_.created_date as created_3_0_, authuser0_.last_modified_by as last_mod4_0_, authuser0_.last_modified_date as last_mod5_0_, authuser0_.access_token as access_t6_0_, authuser0_.attachment_type as attachme7_0_, authuser0_.auth_type as auth_typ8_0_, authuser0_.broker_id as broker_i9_0_, authuser0_.deleted as deleted10_0_, authuser0_.dept_name as dept_na11_0_, authuser0_.employee_id as employe12_0_, authuser0_.org_id as org_id13_0_, authuser0_.org_name as org_nam14_0_, authuser0_.position as positio15_0_, authuser0_.principal as princip16_0_, authuser0_.user_name as user_na17_0_, authuser0_.version as version18_0_ from auth_user authuser0_ where ( authuser0_.deleted = 0)": {
    "query": "select authuser0_.id as id1_0_, authuser0_.created_by as created_2_0_, authuser0_.created_date as created_3_0_, authuser0_.last_modified_by as last_mod4_0_, authuser0_.last_modified_date as last_mod5_0_, authuser0_.access_token as access_t6_0_, authuser0_.attachment_type as attachme7_0_, authuser0_.auth_type as auth_typ8_0_, authuser0_.broker_id as broker_i9_0_, authuser0_.deleted as deleted10_0_, authuser0_.dept_name as dept_na11_0_, authuser0_.employee_id as employe12_0_, authuser0_.org_id as org_id13_0_, authuser0_.org_name as org_nam14_0_, authuser0_.position as positio15_0_, authuser0_.principal as princip16_0_, authuser0_.user_name as user_na17_0_, authuser0_.version as version18_0_ from auth_user authuser0_ where ( authuser0_.deleted = 0)",
    "nrOfInvocations": 1,
    "maxInvocationTime": 2,
    "maxInvocationDate": 1499354555423,
    "minInvocationTime": 2,
    "minInvocationDate": 1499354555423,
    "totalInvocationTime": 2
  }
}

maxInvocationTime表示最大的耗时,毫秒单位;
maxInvocationDate表示发生的时间点

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值