【问题标题】:How to - Spring MVC and Spring-Data-Rest controllers with CodaHale-Metrics如何 - 使用 CodaHale-Metrics 的 Spring MVC 和 Spring-Data-Rest 控制器
【发布时间】:2014-06-23 18:57:21
【问题描述】:

如何使用 Spring AOP 和/或使用 http://www.ryantenney.com/metrics-spring/ 库注入 Coda Hale Metrics。有没有例子?

【问题讨论】:

    标签: spring-mvc spring-aop metrics spring-data-rest codahale-metrics


    【解决方案1】:

    我想通了。如果http://www.ryantenney.com/metrics-spring/ 中的所有功能都被记录在案,那就太好了:) 但是,嘿,这就是它是开源的原因。

    <metrics:annotation-driven metric-registry="metrics" />
    <!-- Monitoring the controller  -->
    <beans:bean id="monitoringInterceptor" class="com.ryantenney.metrics.spring.TimedMethodInterceptor">
        <beans:constructor-arg ref="metrics"/>
        <beans:constructor-arg>
            <beans:value type="java.lang.Class">org.myapp.controller.MyController</beans:value>
        </beans:constructor-arg>
    </beans:bean>
    
    <aop:config>
        <!-- name of the class or interface -->
        <aop:pointcut id="monitoringPointcut" expression="execution(* org.myapp.controller.MyController..*(..))"/>
        <aop:advisor advice-ref="monitoringInterceptor" pointcut-ref="monitoringPointcut"/>
    </aop:config>  
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2021-05-07
      • 2015-06-05
      • 1970-01-01
      • 2016-02-07
      • 2016-01-22
      • 2014-09-08
      • 1970-01-01
      相关资源
      最近更新 更多