Skip to content
Snippets Groups Projects
Commit 184a7b8c authored by Antoine Rey's avatar Antoine Rey
Browse files

Fix #31 Services cannot contact with Zipkin server

parent 422bad17
No related branches found
No related tags found
No related merge requests found
...@@ -54,6 +54,10 @@ ...@@ -54,6 +54,10 @@
</dependency> </dependency>
<!-- Spring Cloud --> <!-- Spring Cloud -->
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-sleuth-zipkin</artifactId>
</dependency>
<dependency> <dependency>
<groupId>org.springframework.cloud</groupId> <groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-config</artifactId> <artifactId>spring-cloud-starter-config</artifactId>
......
...@@ -21,6 +21,8 @@ import java.util.List; ...@@ -21,6 +21,8 @@ import java.util.List;
import javax.validation.Valid; import javax.validation.Valid;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpStatus; import org.springframework.http.HttpStatus;
import org.springframework.samples.petclinic.customers.model.Owner; import org.springframework.samples.petclinic.customers.model.Owner;
...@@ -47,6 +49,8 @@ import org.springframework.web.bind.annotation.RestController; ...@@ -47,6 +49,8 @@ import org.springframework.web.bind.annotation.RestController;
@RequiredArgsConstructor(onConstructor = @__(@Autowired)) @RequiredArgsConstructor(onConstructor = @__(@Autowired))
class OwnerResource { class OwnerResource {
private static final Logger LOG = LoggerFactory.getLogger(OwnerResource.class);
private final OwnerRepository ownerRepository; private final OwnerRepository ownerRepository;
/** /**
...@@ -88,6 +92,7 @@ class OwnerResource { ...@@ -88,6 +92,7 @@ class OwnerResource {
ownerModel.setCity(ownerRequest.getCity()); ownerModel.setCity(ownerRequest.getCity());
ownerModel.setAddress(ownerRequest.getAddress()); ownerModel.setAddress(ownerRequest.getAddress());
ownerModel.setTelephone(ownerRequest.getTelephone()); ownerModel.setTelephone(ownerRequest.getTelephone());
LOG.info("Saving owner {}", ownerModel);
return ownerRepository.save(ownerModel); return ownerRepository.save(ownerModel);
} }
} }
...@@ -16,24 +16,15 @@ ...@@ -16,24 +16,15 @@
package org.springframework.samples.petclinic.customers.web; package org.springframework.samples.petclinic.customers.web;
import lombok.RequiredArgsConstructor; import lombok.RequiredArgsConstructor;
import org.slf4j.Logger;
import java.util.List; import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpStatus; import org.springframework.http.HttpStatus;
import org.springframework.samples.petclinic.customers.model.Owner; import org.springframework.samples.petclinic.customers.model.*;
import org.springframework.samples.petclinic.customers.model.OwnerRepository;
import org.springframework.samples.petclinic.customers.model.Pet;
import org.springframework.samples.petclinic.customers.model.PetRepository;
import org.springframework.samples.petclinic.customers.model.PetType;
import org.springframework.samples.petclinic.monitoring.Monitored; import org.springframework.samples.petclinic.monitoring.Monitored;
import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.*;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping; import java.util.List;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.ResponseStatus;
import org.springframework.web.bind.annotation.RestController;
/** /**
* @author Juergen Hoeller * @author Juergen Hoeller
...@@ -45,6 +36,8 @@ import org.springframework.web.bind.annotation.RestController; ...@@ -45,6 +36,8 @@ import org.springframework.web.bind.annotation.RestController;
@RequiredArgsConstructor(onConstructor = @__(@Autowired)) @RequiredArgsConstructor(onConstructor = @__(@Autowired))
class PetResource { class PetResource {
private static final Logger LOG = LoggerFactory.getLogger(PetResource.class);
private final PetRepository petRepository; private final PetRepository petRepository;
private final OwnerRepository ownerRepository; private final OwnerRepository ownerRepository;
...@@ -83,6 +76,7 @@ class PetResource { ...@@ -83,6 +76,7 @@ class PetResource {
petRepository.findPetTypeById(petRequest.getTypeId()) petRepository.findPetTypeById(petRequest.getTypeId())
.ifPresent(pet::setType); .ifPresent(pet::setType);
LOG.info("Saving pet {}", pet);
petRepository.save(pet); petRepository.save(pet);
} }
......
...@@ -45,6 +45,10 @@ ...@@ -45,6 +45,10 @@
</dependency> </dependency>
<!-- Spring Cloud--> <!-- Spring Cloud-->
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-sleuth-zipkin</artifactId>
</dependency>
<dependency> <dependency>
<groupId>org.springframework.cloud</groupId> <groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-config</artifactId> <artifactId>spring-cloud-starter-config</artifactId>
......
...@@ -16,21 +16,16 @@ ...@@ -16,21 +16,16 @@
package org.springframework.samples.petclinic.visits.web; package org.springframework.samples.petclinic.visits.web;
import lombok.RequiredArgsConstructor; import lombok.RequiredArgsConstructor;
import org.slf4j.Logger;
import java.util.List; import org.slf4j.LoggerFactory;
import javax.validation.Valid;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpStatus; import org.springframework.http.HttpStatus;
import org.springframework.samples.petclinic.visits.model.Visit; import org.springframework.samples.petclinic.visits.model.Visit;
import org.springframework.samples.petclinic.visits.model.VisitRepository; import org.springframework.samples.petclinic.visits.model.VisitRepository;
import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.*;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping; import javax.validation.Valid;
import org.springframework.web.bind.annotation.RequestBody; import java.util.List;
import org.springframework.web.bind.annotation.ResponseStatus;
import org.springframework.web.bind.annotation.RestController;
/** /**
* @author Juergen Hoeller * @author Juergen Hoeller
...@@ -43,6 +38,9 @@ import org.springframework.web.bind.annotation.RestController; ...@@ -43,6 +38,9 @@ import org.springframework.web.bind.annotation.RestController;
@RequiredArgsConstructor(onConstructor = @__(@Autowired)) @RequiredArgsConstructor(onConstructor = @__(@Autowired))
public class VisitResource { public class VisitResource {
private static final Logger LOG = LoggerFactory.getLogger(VisitResource.class);
private final VisitRepository visitRepository; private final VisitRepository visitRepository;
@PostMapping("owners/*/pets/{petId}/visits") @PostMapping("owners/*/pets/{petId}/visits")
...@@ -52,6 +50,7 @@ public class VisitResource { ...@@ -52,6 +50,7 @@ public class VisitResource {
@PathVariable("petId") int petId) { @PathVariable("petId") int petId) {
visit.setPetId(petId); visit.setPetId(petId);
LOG.info("Saving visit {}", visit);
visitRepository.save(visit); visitRepository.save(visit);
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment