Skip to content

Commit 97bfe14

Browse files
committed
added logging
1 parent 0ad7a77 commit 97bfe14

File tree

8 files changed

+48
-8
lines changed

8 files changed

+48
-8
lines changed

examples-bootiful-gcp/helloworld-service/pom.xml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,12 @@
4646
<groupId>io.micrometer</groupId>
4747
<artifactId>micrometer-registry-prometheus</artifactId>
4848
</dependency>
49+
<dependency>
50+
<groupId>org.projectlombok</groupId>
51+
<artifactId>lombok</artifactId>
52+
<version>1.18.4</version>
53+
<scope>provided</scope>
54+
</dependency>
4955

5056
<dependency>
5157
<groupId>org.springframework.boot</groupId>

examples-bootiful-gcp/helloworld-service/src/main/java/com/example/guestbook/HelloworldApplication.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
*/
1616
package com.example.guestbook;
1717

18+
import lombok.extern.slf4j.Slf4j;
1819
import org.springframework.beans.factory.annotation.Value;
1920
import org.springframework.boot.SpringApplication;
2021
import org.springframework.boot.autoconfigure.SpringBootApplication;
@@ -37,11 +38,13 @@ public static void main(String[] args) {
3738
}
3839

3940
@RestController
41+
@Slf4j
4042
class HelloworldController {
4143
private final String version = "1.0";
4244

4345
@GetMapping("/hello/{name}")
4446
public Map<String, String> hello(@Value("${greeting}") String greetingTemplate, @PathVariable String name) throws UnknownHostException {
47+
log.info("received hello from {}", name);
4548
Map<String, String> response = new HashMap<>();
4649

4750
String hostname = InetAddress.getLocalHost().getHostName();
@@ -54,6 +57,7 @@ public Map<String, String> hello(@Value("${greeting}") String greetingTemplate,
5457
response.put("version", version);
5558
response.put("hostname", hostname);
5659

60+
log.info("responding to {}", name);
5761
return response;
5862
}
5963
}

examples-bootiful-gcp/helloworld-ui/pom.xml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,12 @@
5858
<groupId>io.micrometer</groupId>
5959
<artifactId>micrometer-registry-prometheus</artifactId>
6060
</dependency>
61+
<dependency>
62+
<groupId>org.projectlombok</groupId>
63+
<artifactId>lombok</artifactId>
64+
<version>1.18.4</version>
65+
<scope>provided</scope>
66+
</dependency>
6167

6268
<dependency>
6369
<groupId>org.springframework.boot</groupId>

examples-bootiful-gcp/helloworld-ui/src/main/java/com/example/guestbook/HelloworldUiController.java

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,18 +15,21 @@
1515
*/
1616
package com.example.guestbook;
1717

18+
import lombok.extern.slf4j.Slf4j;
1819
import org.springframework.stereotype.Controller;
1920
import org.springframework.ui.Model;
2021
import org.springframework.web.bind.annotation.*;
2122
import org.springframework.web.context.annotation.SessionScope;
2223

24+
import javax.servlet.http.HttpSession;
2325
import java.util.Map;
2426

2527
/**
2628
* Created by rayt on 5/1/17.
2729
*/
2830
@Controller
2931
@SessionAttributes("name")
32+
@Slf4j
3033
public class HelloworldUiController {
3134
private final HelloworldService helloworldService;
3235
private final GuestbookService guestbookService;
@@ -37,7 +40,8 @@ public HelloworldUiController(HelloworldService helloworldService, GuestbookServ
3740
}
3841

3942
@GetMapping("/")
40-
public String index(Model model) {
43+
public String index(HttpSession session, Model model) {
44+
log.info("starting index");
4145
if (model.containsAttribute("name")) {
4246
String name = (String) model.asMap().get("name");
4347
Map<String, String> greeting = helloworldService.greeting(name);
@@ -51,6 +55,7 @@ public String index(Model model) {
5155

5256
@PostMapping("/greet")
5357
public String greet(@RequestParam String name, @RequestParam String message, Model model) {
58+
log.info("greeting from {}", name);
5459
model.addAttribute("name", name);
5560
if (message != null && !message.trim().isEmpty()) {
5661
guestbookService.add(name, message);

examples-bootiful-gcp/kubernetes/guestbook-deployment.yaml

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ spec:
3737
visualizer/uses: mysql
3838
prometheus.io/scrape: "true"
3939
prometheus.io/port: "8080"
40-
promteheus.io/path: /actuator/prometheus
40+
prometheus.io/path: /actuator/prometheus
4141
spec:
4242
containers:
4343
- name: guestbook-service
@@ -46,6 +46,13 @@ spec:
4646
httpGet:
4747
path: /actuator/health
4848
port: 8080
49+
resources:
50+
requests:
51+
cpu: 0.5
52+
memory: 512Mi
53+
limits:
54+
cpu: 2.0
55+
memory: 1Gi
4956
ports:
5057
- name: http
5158
containerPort: 8080

examples-bootiful-gcp/kubernetes/helloworld-deployment.yaml

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ spec:
3636
annotations:
3737
prometheus.io/scrape: "true"
3838
prometheus.io/port: "8080"
39-
promteheus.io/path: /actuator/prometheus
39+
prometheus.io/path: /actuator/prometheus
4040
spec:
4141
containers:
4242
- name: helloworld-service
@@ -45,6 +45,13 @@ spec:
4545
httpGet:
4646
path: /actuator/health
4747
port: 8080
48+
resources:
49+
requests:
50+
cpu: 0.5
51+
memory: 512Mi
52+
limits:
53+
cpu: 2.0
54+
memory: 1Gi
4855
ports:
4956
- name: http
5057
containerPort: 8080

examples-bootiful-gcp/kubernetes/ui-deployment.yaml

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ spec:
3737
visualizer/uses: helloworld-service,guestbook-service,redis
3838
prometheus.io/scrape: "true"
3939
prometheus.io/port: "8080"
40-
promteheus.io/path: /actuator/prometheus
40+
prometheus.io/path: /actuator/prometheus
4141
spec:
4242
containers:
4343
- name: helloworld-ui
@@ -53,6 +53,13 @@ spec:
5353
httpGet:
5454
path: /actuator/health
5555
port: 8080
56+
resources:
57+
requests:
58+
cpu: 0.5
59+
memory: 512Mi
60+
limits:
61+
cpu: 2.0
62+
memory: 1Gi
5663
ports:
5764
- name: http
5865
containerPort: 8080

examples-bootiful-gcp/pom.xml

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -44,16 +44,14 @@
4444
<artifactId>jib-maven-plugin</artifactId>
4545
<version>0.10.1</version>
4646
<configuration>
47-
<from>
48-
<image>adoptopenjdk/openjdk8-openj9:x86_64-ubuntu-jdk8u192-b12_openj9-0.11.0-slim</image>
49-
</from>
5047
<to>
5148
<image>${docker.image.prefix}/bootiful-${project.artifactId}</image>
5249
</to>
5350
<extraDirectory>${jib.agent.directory}</extraDirectory>
5451
<container>
5552
<jvmFlags>
56-
<jvmFlag>-XX:+ContainerSupport</jvmFlag>
53+
<jvmFlag>-XX:+UnlockExperimentalVMOptions</jvmFlag>
54+
<jvmFlag>-XX:+UseCGroupMemoryLimitForHeap</jvmFlag>
5755
<jvmFlag>-agentpath:/opt/profiler/profiler_java_agent.so=-cprof_service=${project.artifactId},-cprof_service_version=${project.version}</jvmFlag>
5856
<jvmFlag>-agentpath:${stackdriver.debugger.directory}/cdbg_java_agent.so=--logtostderr=1</jvmFlag>
5957
<jvmFlag>-Dcom.google.cdbg.module=${project.artifactId}</jvmFlag>

0 commit comments

Comments
 (0)