Skip to content

Commit 149ceab

Browse files
committed
running Docker-Compose
1 parent 26a4ef6 commit 149ceab

41 files changed

Lines changed: 191 additions & 278 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

spring-cloud/tracing/README.md

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
# Log Tracing with Spring Cloud Sleuth
2+
3+
This project shows how to implement tracing in a network of Spring Boot applications.
4+
5+
## Companion Blog Article
6+
The companion blog article to this repository can be found [here](https://reflectoring.io/tracing-with-spring-cloud-sleuth/).
7+
8+
## Getting Started
9+
10+
* build the sources with `./gradlew clean build` (don't forge to also do this after every change to the code, otherwise Docker will start the old image)
11+
* run the applications in Docker with `docker-compose up --build`

spring-cloud/tracing/build.gradle

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ buildscript {
55
}
66

77
plugins {
8-
id 'org.springframework.boot' version '2.5.6'
8+
id 'org.springframework.boot' version '2.5.6' apply(false) // we don't want the root project to be a Spring Boot project
99
id 'io.spring.dependency-management' version '1.0.11.RELEASE'
1010
id 'java'
1111
}
@@ -14,14 +14,6 @@ repositories {
1414
mavenCentral()
1515
}
1616

17-
bootJar {
18-
enabled = false
19-
}
20-
21-
jar {
22-
enabled = true
23-
}
24-
2517
subprojects {
2618

2719
apply plugin: 'java'
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
version: "3.5"
2+
3+
services:
4+
5+
downstream:
6+
build: ./downstream-service/
7+
image: downstream:latest
8+
ports:
9+
- "8080:8080"
10+
11+
upstream:
12+
build: ./upstream-service/
13+
image: upstream:latest
14+
ports:
15+
- "8081:8081"

spring-cloud/tracing/sleuth-downstream-service/.gitignore renamed to spring-cloud/tracing/downstream-service/.gitignore

File renamed without changes.
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
FROM adoptopenjdk/openjdk11:alpine-jre
2+
ARG JAR_FILE=build/libs/*.jar
3+
COPY ${JAR_FILE} application.jar
4+
EXPOSE 8080
5+
ENTRYPOINT ["java","-jar","/application.jar"]
File renamed without changes.

spring-cloud/tracing/sleuth-downstream-service/build.gradle renamed to spring-cloud/tracing/downstream-service/build.gradle

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,14 @@
11
dependencies {
22
implementation 'org.springframework.boot:spring-boot-starter-web'
33
implementation 'org.springframework.cloud:spring-cloud-starter-sleuth'
4-
implementation 'org.springframework.cloud:spring-cloud-starter-openfeign'
54
testImplementation 'org.springframework.boot:spring-boot-starter-test'
5+
}
6+
7+
bootJar {
8+
enabled = true
9+
mainClass.set('com.example.demo.DemoApplication')
10+
}
11+
12+
jar {
13+
enabled = false
614
}

spring-cloud/tracing/sleuth-downstream-service/src/main/java/com/example/demo/Address.java renamed to spring-cloud/tracing/downstream-service/src/main/java/com/example/demo/Address.java

File renamed without changes.
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
package com.example.demo;
2+
3+
import org.springframework.beans.factory.annotation.Value;
4+
import org.springframework.stereotype.Component;
5+
import org.springframework.web.client.RestTemplate;
6+
7+
@Component
8+
public class AddressClient {
9+
10+
private final RestTemplate restTemplate;
11+
private final String baseUrl;
12+
13+
public AddressClient(
14+
RestTemplate restTemplate,
15+
@Value("${addressClient.baseUrl}") String baseUrl) {
16+
this.restTemplate = restTemplate;
17+
this.baseUrl = baseUrl;
18+
}
19+
20+
Address getAddressForCustomerId(long id) {
21+
return restTemplate.getForObject(String.format("%s/addresses/%d", baseUrl, id), Address.class);
22+
}
23+
24+
}

spring-cloud/tracing/sleuth-downstream-service/src/main/java/com/example/demo/Controller.java renamed to spring-cloud/tracing/downstream-service/src/main/java/com/example/demo/Controller.java

File renamed without changes.

0 commit comments

Comments
 (0)