diff --git a/pom.xml b/pom.xml index 1958e2487..3627c00de 100644 --- a/pom.xml +++ b/pom.xml @@ -33,7 +33,6 @@ 2.0.4.RELEASE Finchley.SR2 2.0.0.RC2 - 1.0.5 2.22.0 @@ -79,18 +78,6 @@ test - - - io.micrometer - micrometer-core - ${micrometer.version} - - - - io.micrometer - micrometer-registry-prometheus - ${micrometer.version} - diff --git a/spring-petclinic-api-gateway/pom.xml b/spring-petclinic-api-gateway/pom.xml index ae40e34eb..790845120 100644 --- a/spring-petclinic-api-gateway/pom.xml +++ b/spring-petclinic-api-gateway/pom.xml @@ -87,10 +87,6 @@ org.projectlombok lombok - - io.micrometer - micrometer-core - io.micrometer micrometer-registry-prometheus diff --git a/spring-petclinic-customers-service/pom.xml b/spring-petclinic-customers-service/pom.xml index dc5928e47..9c411deb6 100644 --- a/spring-petclinic-customers-service/pom.xml +++ b/spring-petclinic-customers-service/pom.xml @@ -77,10 +77,6 @@ org.projectlombok lombok - - io.micrometer - micrometer-core - io.micrometer micrometer-registry-prometheus 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 80916f3ef..179104349 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 @@ -15,7 +15,7 @@ */ package org.springframework.samples.petclinic.customers.web; -import io.micrometer.core.instrument.MeterRegistry; +import io.micrometer.core.annotation.Timed; import lombok.RequiredArgsConstructor; import lombok.extern.slf4j.Slf4j; import org.springframework.http.HttpStatus; @@ -36,12 +36,12 @@ */ @RequestMapping("/owners") @RestController +@Timed("petclinic.owner") @RequiredArgsConstructor @Slf4j class OwnerResource { private final OwnerRepository ownerRepository; - private final MeterRegistry registry; /** * Create Owner @@ -49,7 +49,6 @@ class OwnerResource { @PostMapping @ResponseStatus(HttpStatus.CREATED) public void createOwner(@Valid @RequestBody Owner owner) { - registry.counter("create.owner").increment(); ownerRepository.save(owner); } @@ -84,7 +83,6 @@ public Owner updateOwner(@PathVariable("ownerId") int ownerId, @Valid @RequestBo ownerModel.setAddress(ownerRequest.getAddress()); ownerModel.setTelephone(ownerRequest.getTelephone()); log.info("Saving owner {}", ownerModel); - registry.counter("update.owner").increment(); return ownerRepository.save(ownerModel); } } 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 34c8c70d6..3bb7f7bf5 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 @@ -15,7 +15,7 @@ */ package org.springframework.samples.petclinic.customers.web; -import io.micrometer.core.instrument.MeterRegistry; +import io.micrometer.core.annotation.Timed; import lombok.RequiredArgsConstructor; import lombok.extern.slf4j.Slf4j; import org.springframework.http.HttpStatus; @@ -32,13 +32,13 @@ * @author Maciej Szarlinski */ @RestController +@Timed("petclinic.pet") @RequiredArgsConstructor @Slf4j class PetResource { private final PetRepository petRepository; private final OwnerRepository ownerRepository; - private final MeterRegistry registry; @GetMapping("/petTypes") @@ -57,7 +57,6 @@ public void processCreationForm( Owner owner = optionalOwner.orElseThrow(() -> new ResourceNotFoundException("Owner "+ownerId+" not found")); owner.addPet(pet); - registry.counter("create.pet").increment(); save(pet, petRequest); } @@ -66,7 +65,6 @@ public void processCreationForm( public void processUpdateForm(@RequestBody PetRequest petRequest) { int petId = petRequest.getId(); Pet pet = findPetById(petId); - registry.counter("update.pet").increment(); save(pet, petRequest); } diff --git a/spring-petclinic-customers-service/src/test/java/org/springframework/samples/petclinic/customers/web/PetResourceTest.java b/spring-petclinic-customers-service/src/test/java/org/springframework/samples/petclinic/customers/web/PetResourceTest.java index 5b2b3303c..04a6e0079 100644 --- a/spring-petclinic-customers-service/src/test/java/org/springframework/samples/petclinic/customers/web/PetResourceTest.java +++ b/spring-petclinic-customers-service/src/test/java/org/springframework/samples/petclinic/customers/web/PetResourceTest.java @@ -2,7 +2,6 @@ import java.util.Optional; -import io.micrometer.core.instrument.MeterRegistry; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.ExtendWith; import org.springframework.beans.factory.annotation.Autowired; @@ -42,9 +41,6 @@ class PetResourceTest { @MockBean OwnerRepository ownerRepository; - @MockBean - MeterRegistry registry; - @Test void shouldGetAPetInJSonFormat() throws Exception { diff --git a/spring-petclinic-vets-service/pom.xml b/spring-petclinic-vets-service/pom.xml index 99b957703..9f3c58cd7 100644 --- a/spring-petclinic-vets-service/pom.xml +++ b/spring-petclinic-vets-service/pom.xml @@ -93,10 +93,6 @@ mysql-connector-java runtime - - io.micrometer - micrometer-core - io.micrometer micrometer-registry-prometheus diff --git a/spring-petclinic-visits-service/pom.xml b/spring-petclinic-visits-service/pom.xml index c60737406..2bf6cc5d0 100644 --- a/spring-petclinic-visits-service/pom.xml +++ b/spring-petclinic-visits-service/pom.xml @@ -76,10 +76,6 @@ mysql-connector-java runtime - - io.micrometer - micrometer-core - io.micrometer micrometer-registry-prometheus 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 5905f3715..8f6bd5ca1 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 @@ -18,7 +18,7 @@ import java.util.List; import javax.validation.Valid; -import io.micrometer.core.instrument.MeterRegistry; +import io.micrometer.core.annotation.Timed; import lombok.RequiredArgsConstructor; import lombok.Value; import lombok.extern.slf4j.Slf4j; @@ -43,10 +43,10 @@ @RestController @RequiredArgsConstructor @Slf4j +@Timed("petclinic.visit") class VisitResource { private final VisitRepository visitRepository; - private final MeterRegistry registry; @PostMapping("owners/*/pets/{petId}/visits") @ResponseStatus(HttpStatus.NO_CONTENT) @@ -56,7 +56,6 @@ void create( visit.setPetId(petId); log.info("Saving visit {}", visit); - registry.counter("create.visit").increment(); visitRepository.save(visit); } diff --git a/spring-petclinic-visits-service/src/test/java/org/springframework/samples/petclinic/visits/web/VisitResourceTest.java b/spring-petclinic-visits-service/src/test/java/org/springframework/samples/petclinic/visits/web/VisitResourceTest.java index 3409b30ab..25d33f24b 100644 --- a/spring-petclinic-visits-service/src/test/java/org/springframework/samples/petclinic/visits/web/VisitResourceTest.java +++ b/spring-petclinic-visits-service/src/test/java/org/springframework/samples/petclinic/visits/web/VisitResourceTest.java @@ -1,6 +1,5 @@ package org.springframework.samples.petclinic.visits.web; -import io.micrometer.core.instrument.MeterRegistry; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.ExtendWith; import org.springframework.beans.factory.annotation.Autowired; @@ -30,9 +29,6 @@ class VisitResourceTest { @MockBean VisitRepository visitRepository; - @MockBean - MeterRegistry registry; - @Test void shouldFetchVisits() throws Exception { given(visitRepository.findByPetIdIn(asList(111, 222)))