From 8abbb8bc89d94e75d46c068be5da30dea588c29d Mon Sep 17 00:00:00 2001 From: Stefan Siegl Date: Mon, 16 Apr 2018 21:22:48 +0200 Subject: [PATCH 1/6] increased hysteric timeout to 5s --- .../src/main/resources/application.yml | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/spring-petclinic-api-gateway/src/main/resources/application.yml b/spring-petclinic-api-gateway/src/main/resources/application.yml index e7de112c9..0fb78aef1 100644 --- a/spring-petclinic-api-gateway/src/main/resources/application.yml +++ b/spring-petclinic-api-gateway/src/main/resources/application.yml @@ -6,3 +6,10 @@ zuul: visits-service: /visit/** customers-service: /customer/** api-gateway: /gateway/** +hystrix: + command: + default: + execution: + isolation: + thread: + timeoutInMilliseconds=5000 From 58ceb6ec44c872f91f546d4d6060ac947910aeb7 Mon Sep 17 00:00:00 2001 From: Stefan Siegl Date: Thu, 12 Apr 2018 16:04:08 +0200 Subject: [PATCH 2/6] Integrated a small random performance problem with Visits --- .../samples/petclinic/visits/web/VisitResource.java | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/spring-petclinic-visits-service/src/main/java/org/springframework/samples/petclinic/visits/web/VisitResource.java b/spring-petclinic-visits-service/src/main/java/org/springframework/samples/petclinic/visits/web/VisitResource.java index b99a01dcc..c4635e6f6 100644 --- a/spring-petclinic-visits-service/src/main/java/org/springframework/samples/petclinic/visits/web/VisitResource.java +++ b/spring-petclinic-visits-service/src/main/java/org/springframework/samples/petclinic/visits/web/VisitResource.java @@ -25,6 +25,7 @@ import javax.validation.Valid; import java.util.List; +import java.util.Random; /** * @author Juergen Hoeller @@ -53,6 +54,16 @@ public void create( @GetMapping("owners/*/pets/{petId}/visits") public List visits(@PathVariable("petId") int petId) { + + // lets spice things a bit up and sometimes integrate some longer load times + if (Math.random() < 0.1) { + try { + Thread.currentThread().sleep(2000); + } catch (InterruptedException e) { + // ignore + } + } + return visitRepository.findByPetId(petId); } } From b3d4f5dc9a7038c973fdbae6083b3ea0d63c2334 Mon Sep 17 00:00:00 2001 From: Stefan Siegl Date: Fri, 20 Apr 2018 11:38:03 +0200 Subject: [PATCH 3/6] added more performance problems --- .../customers/web/OwnerResource.java | 21 ++++++++++++------- .../petclinic/customers/web/PetResource.java | 10 +++++++++ 2 files changed, 24 insertions(+), 7 deletions(-) diff --git a/spring-petclinic-customers-service/src/main/java/org/springframework/samples/petclinic/customers/web/OwnerResource.java b/spring-petclinic-customers-service/src/main/java/org/springframework/samples/petclinic/customers/web/OwnerResource.java index d3ea877a7..9ad9e1e53 100644 --- a/spring-petclinic-customers-service/src/main/java/org/springframework/samples/petclinic/customers/web/OwnerResource.java +++ b/spring-petclinic-customers-service/src/main/java/org/springframework/samples/petclinic/customers/web/OwnerResource.java @@ -17,10 +17,7 @@ import java.util.Collections; import java.util.List; -import java.util.concurrent.Callable; -import java.util.concurrent.ExecutorService; -import java.util.concurrent.Executors; -import java.util.concurrent.Future; +import java.util.concurrent.*; import javax.validation.Valid; @@ -54,10 +51,10 @@ @Slf4j class OwnerResource { - private final OwnerRepository ownerRepository; + private final OwnerRepository ownerRepository = null; private final ExecutorService executor = Executors.newCachedThreadPool(); - + /** * Create Owner */ @@ -73,6 +70,16 @@ public void createOwner(@Valid @RequestBody Owner owner) { */ @GetMapping(value = "/{ownerId}") public Owner findOwner(@PathVariable("ownerId") int ownerId) { + + // introduce some performance problem (in the most easy way) + if (ownerId % 11 == 0) { + try { + TimeUnit.SECONDS.sleep(1); + } catch (InterruptedException e) { + e.printStackTrace(); + } + } + return ownerRepository.findOne(ownerId); } @@ -87,7 +94,7 @@ public List call() throws Exception { return ownerRepository.findAll(); } }); - + try { return future.get(); } catch (Exception e) { diff --git a/spring-petclinic-customers-service/src/main/java/org/springframework/samples/petclinic/customers/web/PetResource.java b/spring-petclinic-customers-service/src/main/java/org/springframework/samples/petclinic/customers/web/PetResource.java index 4bc30831c..fdac0119f 100644 --- a/spring-petclinic-customers-service/src/main/java/org/springframework/samples/petclinic/customers/web/PetResource.java +++ b/spring-petclinic-customers-service/src/main/java/org/springframework/samples/petclinic/customers/web/PetResource.java @@ -24,6 +24,7 @@ import org.springframework.web.bind.annotation.*; import java.util.List; +import java.util.concurrent.TimeUnit; /** * @author Juergen Hoeller @@ -63,6 +64,15 @@ public void processCreationForm( @ResponseStatus(HttpStatus.NO_CONTENT) @Monitored public void processUpdateForm(@RequestBody PetRequest petRequest) { + // only do that is we have a "Snake" (type 4) + if (petRequest.getTypeId() == 4) { + try { + TimeUnit.SECONDS.sleep(2); + } catch (InterruptedException e) { + e.printStackTrace(); + } + } + save(petRepository.findOne(petRequest.getId()), petRequest); } From cd7d58537f4baf95645961497595d24084a74273 Mon Sep 17 00:00:00 2001 From: Tobias Angerstein Date: Mon, 23 Apr 2018 17:39:53 +0200 Subject: [PATCH 4/6] Bugfix: Remove null initialization Disable hystrix timeout --- .../src/main/resources/application.yml | 5 ++--- .../samples/petclinic/customers/web/OwnerResource.java | 2 +- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/spring-petclinic-api-gateway/src/main/resources/application.yml b/spring-petclinic-api-gateway/src/main/resources/application.yml index 0fb78aef1..fe8dea6e5 100644 --- a/spring-petclinic-api-gateway/src/main/resources/application.yml +++ b/spring-petclinic-api-gateway/src/main/resources/application.yml @@ -10,6 +10,5 @@ hystrix: command: default: execution: - isolation: - thread: - timeoutInMilliseconds=5000 + timeout: + enabled: false \ No newline at end of file diff --git a/spring-petclinic-customers-service/src/main/java/org/springframework/samples/petclinic/customers/web/OwnerResource.java b/spring-petclinic-customers-service/src/main/java/org/springframework/samples/petclinic/customers/web/OwnerResource.java index 9ad9e1e53..88bef4708 100644 --- a/spring-petclinic-customers-service/src/main/java/org/springframework/samples/petclinic/customers/web/OwnerResource.java +++ b/spring-petclinic-customers-service/src/main/java/org/springframework/samples/petclinic/customers/web/OwnerResource.java @@ -51,7 +51,7 @@ @Slf4j class OwnerResource { - private final OwnerRepository ownerRepository = null; + private final OwnerRepository ownerRepository; private final ExecutorService executor = Executors.newCachedThreadPool(); From bb41a9fa0b5726045c3a8fe1faa2054a24fa806c Mon Sep 17 00:00:00 2001 From: Tobias Angerstein Date: Tue, 24 Apr 2018 08:45:33 +0200 Subject: [PATCH 5/6] Enable windows10 compatibility: Add C:\windows\system32 to PATH variable --- start_all_with_inspectIT.bat | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/start_all_with_inspectIT.bat b/start_all_with_inspectIT.bat index 436d12244..ab9d88714 100644 --- a/start_all_with_inspectIT.bat +++ b/start_all_with_inspectIT.bat @@ -8,7 +8,7 @@ rem !!!!do not use spaces in the path of inspectIT installation folder!!!! set AGENTDIR=%1 set WAITTIME=5 set /a "x = 0" - +set PATH=%PATH%;C:\windows\system32; rem STARTTYPE, z.B. /B = start without open a new windows, /MIN start minized in new windows set STARTTYPE=/B From f1ee00b870bcdf043a39c9411f148839a3529f59 Mon Sep 17 00:00:00 2001 From: Stefan Siegl Date: Fri, 20 Apr 2018 11:38:27 +0200 Subject: [PATCH 6/6] improved documentation --- README.md | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/README.md b/README.md index c1e9177e8..0d392a886 100644 --- a/README.md +++ b/README.md @@ -79,6 +79,18 @@ You can then access petclinic here: http://localhost:8080/ Our issue tracker is available here: https://github.com/spring-petclinic/spring-petclinic-microservices/issues + +## Performance "problems" +This extension includes some very simple performance problems on purpose to visualize how APM tools can +detect these and show them to the user. + +- Creating a new pet with the type Snake will impose a 2s delay. +- Finding a customer with a customer ID that can be divided by 11 will impose a 1s delay. +- Loading the visits will impose 2s delay with a probability of 10 percent. + +## Intellij setup + +- Please make sure to install the Lombok Plugin ## Database configuration In its default configuration, Petclinic uses an in-memory database (HSQLDB) which