Bladeren bron

Merge branch 'dev' of chenweida/patient-co-management into dev

chenweida 8 jaren geleden
bovenliggende
commit
ad68b4aca1

+ 24 - 1
Jolokia-admin-server/pom.xml

@ -8,7 +8,10 @@
    <version>1.0.0</version>
    <modelVersion>4.0.0</modelVersion>
    <properties>
        <version.spring-framework>4.2.5.RELEASE</version.spring-framework>
        <version.spring-boot>1.3.5.RELEASE</version.spring-boot>
    </properties>
    <dependencies>
        <dependency>
            <groupId>de.codecentric</groupId>
@ -20,6 +23,26 @@
            <artifactId>spring-boot-admin-server-ui</artifactId>
            <version>1.3.5</version>
        </dependency>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-actuator-docs</artifactId>
            <version>${version.spring-boot}</version>
        </dependency>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-actuator</artifactId>
            <version>${version.spring-boot}</version>
        </dependency>
        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-context</artifactId>
            <version>${version.spring-framework}</version>
        </dependency>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-aop</artifactId>
            <version>${version.spring-boot}</version>
        </dependency>
    </dependencies>
</project>

+ 48 - 0
Jolokia-admin-server/src/main/java/com/yihu/wlyy/jolokia/config/counter/RestCounter.java

@ -0,0 +1,48 @@
package com.yihu.wlyy.jolokia.config.counter;
import org.aspectj.lang.JoinPoint;
import org.aspectj.lang.ProceedingJoinPoint;
import org.aspectj.lang.annotation.Around;
import org.aspectj.lang.annotation.Aspect;
import org.aspectj.lang.annotation.Before;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.actuate.metrics.CounterService;
import org.springframework.boot.actuate.metrics.GaugeService;
import org.springframework.stereotype.Component;
/**
 * Created by chenweida on 2017/7/25.
 * 访问的接口计数器
 */
@Aspect
@Component
public class RestCounter {
    @Autowired
    private CounterService counterService;
    @Autowired
    private GaugeService gaugeService;
    /**
     * 统计访问接口的次数
     * @param joinPoint
     */
    @Before("execution(* com.test.bookpub.controller.*.*(..))")
    public void countServiceInvoke(JoinPoint joinPoint) {
        counterService.increment(joinPoint.getSignature() + "");
    }
    /**
     * 计算访问接口的耗时数
     * @param pjp
     * @throws Throwable
     */
    @Around("execution(* com.test.bookpub.controller.*.*(..))")
    public void latencyService(ProceedingJoinPoint pjp) throws Throwable {
        long start = System.currentTimeMillis();
        pjp.proceed();
        long end = System.currentTimeMillis();
        gaugeService.submit(pjp.getSignature().toString(), end - start);
    }
}

+ 7 - 1
Jolokia-admin-server/src/main/resources/application.yml

@ -1,6 +1,12 @@
server:
  port: 8082
spring:
  boot:
    admin:
      preferIp: true
      url: http://localhost:${server.port}
  jackson:
    serialization:
      indent_output: true
  aop:
    auto: true

+ 1 - 0
patient-co-statistics-es/src/main/resources/application.yml

@ -9,6 +9,7 @@ spring:
      url: http://localhost:8082
      username: jkzl
      password: jkzlehr
  datasource:
    primaryReadWrite:
      driver-class-name: com.mysql.jdbc.Driver