Stat监控不到spring的事务数

剑指天涯 发布于 2016/03/22 20:14
阅读 370
收藏 0

@wenshao 你好,想跟你请教个问题:

我的环境是,druid版本:1.0.18, spring版本:4.0.5

我在web.xml中配置了stat监控,并且在spring配置文件中配置了拦截器,数据源中也启用了stat


<property name="filters" value="config,wall,stat" />





<tx:advice id="txAdvice" transaction-manager="transactionManager">
        <tx:attributes>
            <tx:method name="del*" propagation="REQUIRED" rollback-for="Exception"/>
            <tx:method name="delete*" propagation="REQUIRED" rollback-for="Exception"/>
            <tx:method name="update*" propagation="REQUIRED" rollback-for="Exception"/>
            <tx:method name="edit*" propagation="REQUIRED" rollback-for="Exception"/>
            <tx:method name="save*" propagation="REQUIRED" rollback-for="Exception"/>
            <tx:method name="add*" propagation="REQUIRED" rollback-for="Exception"/>
            <tx:method name="insert*" propagation="REQUIRED" rollback-for="Exception"/>
            <tx:method name="call*" propagation="SUPPORTS" rollback-for="Exception"/>
            <tx:method name="send*" propagation="NOT_SUPPORTED" rollback-for="Exception"/>
            <tx:method name="addBUserActionLog" propagation="SUPPORTS" rollback-for="Exception"/>
            <tx:method name="*" propagation="SUPPORTS" read-only="true" rollback-for="Exception"/>
        </tx:attributes>
    </tx:advice>
	<bean id="druid-stat-interceptor" class="com.alibaba.druid.support.spring.stat.DruidStatInterceptor" />

    <aop:config expose-proxy="true">
        <!-- 只对业务逻辑层实施事务 -->
        <aop:pointcut id="txPointcut" expression="execution(* com.p2p.service..*.*(..))" />
        <aop:advisor advice-ref="txAdvice" pointcut-ref="txPointcut" order="2"/>
        <aop:advisor advice-ref="druid-stat-interceptor" pointcut-ref="txPointcut" order="3"/>
    </aop:config>



配置监控切面和spring事务切面一样


但是在监控系统上面的事务提交数,和回滚数都是0


我看了下监控过滤器的源码,貌似只加了数据源的事务提交数(JdbcDataSourceStat),并没有添加spring的事务数(StatFilterContext.getInstance().commit())

com.alibaba.druid.filter.stat.StatFilter

@Override
    public void connection_commit(FilterChain chain, ConnectionProxy connection) throws SQLException {
        chain.connection_commit(connection);

        JdbcDataSourceStat dataSourceStat = chain.getDataSource().getDataSourceStat();
        dataSourceStat.getConnectionStat().incrementConnectionCommitCount();
    }



请问是我哪里配置有问题吗?

加载中
返回顶部
顶部