BAEL-1064 (#2748)
* BAEL-1064 * add spring-milestones repo to pom * more endpoints for spring integration metrics
This commit is contained in:
+56
-2
@@ -16,6 +16,8 @@
|
||||
<dep.ver.metrics>3.1.2</dep.ver.metrics>
|
||||
<dep.ver.servlet>3.1.0</dep.ver.servlet>
|
||||
<netflix.servo.ver>0.12.17</netflix.servo.ver>
|
||||
<micrometer.ver>1.0.0-rc.2</micrometer.ver>
|
||||
<spring.boot.ver>2.0.0.M5</spring.boot.ver>
|
||||
</properties>
|
||||
|
||||
<dependencies>
|
||||
@@ -57,12 +59,64 @@
|
||||
<version>${netflix.servo.ver}</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>io.micrometer</groupId>
|
||||
<artifactId>micrometer-registry-atlas</artifactId>
|
||||
<version>${micrometer.ver}</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>io.micrometer</groupId>
|
||||
<artifactId>micrometer-spring-legacy</artifactId>
|
||||
<version>${micrometer.ver}</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-web</artifactId>
|
||||
<version>${spring.boot.ver}</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>com.fasterxml.jackson.core</groupId>
|
||||
<artifactId>jackson-databind</artifactId>
|
||||
<version>2.9.1</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.fasterxml.jackson.dataformat</groupId>
|
||||
<artifactId>jackson-dataformat-smile</artifactId>
|
||||
<version>2.8.9</version>
|
||||
<scope>test</scope>
|
||||
<version>2.9.1</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>com.netflix.spectator</groupId>
|
||||
<artifactId>spectator-api</artifactId>
|
||||
<version>0.57.1</version>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
<dependencyManagement>
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-dependencies</artifactId>
|
||||
<type>pom</type>
|
||||
<scope>import</scope>
|
||||
<version>${spring.boot.ver}</version>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
</dependencyManagement>
|
||||
|
||||
<repositories>
|
||||
<repository>
|
||||
<id>spring-milestones</id>
|
||||
<name>Spring Milestones</name>
|
||||
<url>https://repo.spring.io/libs-milestone</url>
|
||||
<snapshots>
|
||||
<enabled>false</enabled>
|
||||
</snapshots>
|
||||
</repository>
|
||||
</repositories>
|
||||
|
||||
</project>
|
||||
|
||||
@@ -0,0 +1,20 @@
|
||||
package com.baeldung.metrics.micrometer;
|
||||
|
||||
import io.micrometer.core.instrument.binder.jvm.JvmThreadMetrics;
|
||||
import org.springframework.boot.SpringApplication;
|
||||
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
|
||||
@SpringBootApplication
|
||||
public class MicrometerApp {
|
||||
|
||||
@Bean
|
||||
JvmThreadMetrics threadMetrics() {
|
||||
return new JvmThreadMetrics();
|
||||
}
|
||||
|
||||
public static void main(String[] args) throws Exception {
|
||||
SpringApplication.run(MicrometerApp.class, args);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,54 @@
|
||||
package com.baeldung.metrics.micrometer;
|
||||
|
||||
import io.micrometer.core.annotation.Timed;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import java.io.IOException;
|
||||
import java.security.SecureRandom;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
/**
|
||||
* @author aiet
|
||||
*/
|
||||
@RestController
|
||||
@Timed("people")
|
||||
public class PeopleController {
|
||||
|
||||
private static final SecureRandom SECURE_RANDOM = new SecureRandom();
|
||||
|
||||
@GetMapping("/people")
|
||||
@Timed(value = "people.all", longTask = true)
|
||||
public List<String> listPeople() throws InterruptedException {
|
||||
int seconds2Sleep = SECURE_RANDOM.nextInt(500);
|
||||
System.out.println(seconds2Sleep);
|
||||
TimeUnit.MILLISECONDS.sleep(seconds2Sleep);
|
||||
return Arrays.asList("Jim", "Tom", "Tim");
|
||||
}
|
||||
|
||||
@PostMapping("/people")
|
||||
@Timed(value = "people.update", longTask = true)
|
||||
public List<String> putPeople() throws InterruptedException {
|
||||
int seconds2Sleep = SECURE_RANDOM.nextInt(1000);
|
||||
System.out.println(seconds2Sleep);
|
||||
TimeUnit.MILLISECONDS.sleep(seconds2Sleep);
|
||||
return Arrays.asList("Jim", "Tom", "Tim");
|
||||
}
|
||||
|
||||
@GetMapping("/asset")
|
||||
@Timed(value = "people.asset", longTask = true)
|
||||
public void test() throws Exception {
|
||||
throw new Exception("error!");
|
||||
}
|
||||
|
||||
@GetMapping("/property")
|
||||
@Timed(value = "people.property", longTask = true)
|
||||
public void property(HttpServletResponse response) throws IOException {
|
||||
response.sendRedirect("/asset");
|
||||
}
|
||||
|
||||
}
|
||||
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user