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 @@
</dependency>
<!-- Spring Cloud -->
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-sleuth-zipkin</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-config</artifactId>
......
......@@ -21,6 +21,8 @@ import java.util.List;
import javax.validation.Valid;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpStatus;
import org.springframework.samples.petclinic.customers.model.Owner;
......@@ -47,6 +49,8 @@ import org.springframework.web.bind.annotation.RestController;
@RequiredArgsConstructor(onConstructor = @__(@Autowired))
class OwnerResource {
private static final Logger LOG = LoggerFactory.getLogger(OwnerResource.class);
private final OwnerRepository ownerRepository;
/**
......@@ -88,6 +92,7 @@ class OwnerResource {
ownerModel.setCity(ownerRequest.getCity());
ownerModel.setAddress(ownerRequest.getAddress());
ownerModel.setTelephone(ownerRequest.getTelephone());
LOG.info("Saving owner {}", ownerModel);
return ownerRepository.save(ownerModel);
}
}
......@@ -16,24 +16,15 @@
package org.springframework.samples.petclinic.customers.web;
import lombok.RequiredArgsConstructor;
import java.util.List;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpStatus;
import org.springframework.samples.petclinic.customers.model.Owner;
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.customers.model.*;
import org.springframework.samples.petclinic.monitoring.Monitored;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
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;
import org.springframework.web.bind.annotation.*;
import java.util.List;
/**
* @author Juergen Hoeller
......@@ -45,6 +36,8 @@ import org.springframework.web.bind.annotation.RestController;
@RequiredArgsConstructor(onConstructor = @__(@Autowired))
class PetResource {
private static final Logger LOG = LoggerFactory.getLogger(PetResource.class);
private final PetRepository petRepository;
private final OwnerRepository ownerRepository;
......@@ -83,6 +76,7 @@ class PetResource {
petRepository.findPetTypeById(petRequest.getTypeId())
.ifPresent(pet::setType);
LOG.info("Saving pet {}", pet);
petRepository.save(pet);
}
......
......@@ -45,6 +45,10 @@
</dependency>
<!-- Spring Cloud-->
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-sleuth-zipkin</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-config</artifactId>
......
......@@ -16,21 +16,16 @@
package org.springframework.samples.petclinic.visits.web;
import lombok.RequiredArgsConstructor;
import java.util.List;
import javax.validation.Valid;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpStatus;
import org.springframework.samples.petclinic.visits.model.Visit;
import org.springframework.samples.petclinic.visits.model.VisitRepository;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.ResponseStatus;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.bind.annotation.*;
import javax.validation.Valid;
import java.util.List;
/**
* @author Juergen Hoeller
......@@ -43,6 +38,9 @@ import org.springframework.web.bind.annotation.RestController;
@RequiredArgsConstructor(onConstructor = @__(@Autowired))
public class VisitResource {
private static final Logger LOG = LoggerFactory.getLogger(VisitResource.class);
private final VisitRepository visitRepository;
@PostMapping("owners/*/pets/{petId}/visits")
......@@ -52,6 +50,7 @@ public class VisitResource {
@PathVariable("petId") int petId) {
visit.setPetId(petId);
LOG.info("Saving visit {}", 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