This is an automated email from the ASF dual-hosted git repository. kezhenxu94 pushed a commit to branch log-trace in repository https://gitbox.apache.org/repos/asf/skywalking-showcase.git
commit e11372631da5e85cc1ceff3f87b2e3a3ee255d87 Author: kezhenxu94 <[email protected]> AuthorDate: Tue Feb 15 20:19:08 2022 +0800 Add logs-traces correlation --- Makefile.in | 1 + deploy/platform/docker/docker-compose.agent.yaml | 4 ++-- deploy/platform/kubernetes/feature-cluster/resources.yaml | 7 +++++++ .../platform/kubernetes/feature-single-node/resources.yaml | 9 +++++++++ services/gateway-service/Dockerfile | 4 +++- services/gateway-service/Makefile | 2 +- services/songs-service/Dockerfile | 4 +++- services/songs-service/Makefile | 2 +- services/songs-service/build.gradle | 1 + .../showcase/services/song/controller/SongController.java | 4 ++++ services/songs-service/src/main/resources/logback.xml | 13 +++++++++++++ 11 files changed, 45 insertions(+), 6 deletions(-) diff --git a/Makefile.in b/Makefile.in index 03ce498..c9c8c30 100644 --- a/Makefile.in +++ b/Makefile.in @@ -31,6 +31,7 @@ SW_ROCKET_BOT_IMAGE ?= ghcr.io/apache/skywalking/ui:d3ea14d960ee52f66cc634307999 SW_CLI_IMAGE ?= ghcr.io/apache/skywalking-cli/skywalking-cli:8c5725f2c4c47de6091748c1b4747f0d6047ad8e SW_EVENT_EXPORTER_IMAGE ?= ghcr.io/apache/skywalking-kubernetes-event-exporter/skywalking-kubernetes-event-exporter:8a012a3f968cb139f817189afb9b3748841bba22 +SW_AGENT_JAVA_TAG ?= 00cf97e425ce1e91dcf4903092360ca40c49bcbe-java8 SW_AGENT_NODEJS_BACKEND_VERSION ?= e755659c7f308d3b5589619778c8360308cb14f8 SW_AGENT_NODEJS_FRONTEND_VERSION ?= af0565a67d382b683c1dbd94c379b7080db61449 diff --git a/deploy/platform/docker/docker-compose.agent.yaml b/deploy/platform/docker/docker-compose.agent.yaml index 6b2bd67..d9678a0 100644 --- a/deploy/platform/docker/docker-compose.agent.yaml +++ b/deploy/platform/docker/docker-compose.agent.yaml @@ -26,7 +26,7 @@ services: SW_AGENT_NAME: gateway SW_AGENT_COLLECTOR_BACKEND_SERVICES: oap:11800 healthcheck: - test: [ "CMD-SHELL", "wget -O /dev/null http://localhost/actuator/health" ] + test: [ "CMD-SHELL", "curl http://localhost/actuator/health" ] interval: 30s timeout: 10s retries: 3 @@ -44,7 +44,7 @@ services: SW_AGENT_NAME: songs SW_AGENT_COLLECTOR_BACKEND_SERVICES: oap:11800 healthcheck: - test: [ "CMD-SHELL", "wget -O /dev/null http://localhost/actuator/health" ] + test: [ "CMD-SHELL", "curl http://localhost/actuator/health" ] interval: 30s timeout: 10s retries: 3 diff --git a/deploy/platform/kubernetes/feature-cluster/resources.yaml b/deploy/platform/kubernetes/feature-cluster/resources.yaml index 44441f9..8b60bdc 100644 --- a/deploy/platform/kubernetes/feature-cluster/resources.yaml +++ b/deploy/platform/kubernetes/feature-cluster/resources.yaml @@ -94,6 +94,13 @@ spec: - name: elasticsearch image: ${ES_IMAGE} imagePullPolicy: Always + resources: + limits: + cpu: 4000m + memory: "4096Mi" + requests: + cpu: 1000m + memory: "1024Mi" ports: - containerPort: 9200 env: diff --git a/deploy/platform/kubernetes/feature-single-node/resources.yaml b/deploy/platform/kubernetes/feature-single-node/resources.yaml index 24c1529..477e652 100644 --- a/deploy/platform/kubernetes/feature-single-node/resources.yaml +++ b/deploy/platform/kubernetes/feature-single-node/resources.yaml @@ -94,6 +94,13 @@ spec: - name: elasticsearch image: ${ES_IMAGE} imagePullPolicy: Always + resources: + limits: + cpu: 4000m + memory: "4096Mi" + requests: + cpu: 2000m + memory: "2048Mi" ports: - containerPort: 9200 env: @@ -101,6 +108,8 @@ spec: value: 'single-node' - name: 'bootstrap.memory_lock' value: 'true' + - name: 'ES_JAVA_OPTS' + value: '-Xms1g -Xmx4g' --- apiVersion: v1 diff --git a/services/gateway-service/Dockerfile b/services/gateway-service/Dockerfile index 9164054..cdba71d 100644 --- a/services/gateway-service/Dockerfile +++ b/services/gateway-service/Dockerfile @@ -16,8 +16,10 @@ # under the License. # +ARG SW_AGENT_JAVA_TAG + # @feature: java-agent; -FROM ghcr.io/apache/skywalking-java/jdk-11:latest +FROM ghcr.io/apache/skywalking-java/skywalking-java:$SW_AGENT_JAVA_TAG COPY build/libs/gateway-service-0.0.1-SNAPSHOT.jar /app.jar diff --git a/services/gateway-service/Makefile b/services/gateway-service/Makefile index 10b5d5a..dc02c7e 100644 --- a/services/gateway-service/Makefile +++ b/services/gateway-service/Makefile @@ -29,7 +29,7 @@ clean: docker: docker.build docker.build: build - docker build . -t $(HUB)/gateway-service:$(TAG) + docker build --build-arg SW_AGENT_JAVA_TAG=${SW_AGENT_JAVA_TAG} . -t $(HUB)/gateway-service:$(TAG) docker build . -t $(HUB)/gateway-service:$(TAG)-agentless -f Dockerfile.agentless docker.push: docker.build diff --git a/services/songs-service/Dockerfile b/services/songs-service/Dockerfile index d7cde50..9270948 100644 --- a/services/songs-service/Dockerfile +++ b/services/songs-service/Dockerfile @@ -16,8 +16,10 @@ # under the License. # +ARG SW_AGENT_JAVA_TAG + # @feature: java-agent; -FROM ghcr.io/apache/skywalking-java/jdk-11:latest +FROM ghcr.io/apache/skywalking-java/skywalking-java:$SW_AGENT_JAVA_TAG COPY build/libs/songs-service-0.0.1-SNAPSHOT.jar /app.jar diff --git a/services/songs-service/Makefile b/services/songs-service/Makefile index 3bdb669..a9ee024 100644 --- a/services/songs-service/Makefile +++ b/services/songs-service/Makefile @@ -29,7 +29,7 @@ clean: docker: docker.build docker.build: build - docker build . -t $(HUB)/songs-service:$(TAG) + docker build --build-arg SW_AGENT_JAVA_TAG=${SW_AGENT_JAVA_TAG} . -t $(HUB)/songs-service:$(TAG) docker build . -t $(HUB)/songs-service:$(TAG)-agentless -f Dockerfile.agentless docker.push: docker.build diff --git a/services/songs-service/build.gradle b/services/songs-service/build.gradle index 8cc1ad2..e5d8785 100644 --- a/services/songs-service/build.gradle +++ b/services/songs-service/build.gradle @@ -42,6 +42,7 @@ dependencies { implementation 'org.springframework.boot:spring-boot-starter-actuator' implementation 'org.springframework.kafka:spring-kafka' implementation 'com.h2database:h2' + implementation 'org.apache.skywalking:apm-toolkit-logback-1.x:8.9.0' compileOnly 'org.projectlombok:lombok' annotationProcessor 'org.projectlombok:lombok' testImplementation 'org.springframework.boot:spring-boot-starter-test' diff --git a/services/songs-service/src/main/java/org/apache/skywalking/showcase/services/song/controller/SongController.java b/services/songs-service/src/main/java/org/apache/skywalking/showcase/services/song/controller/SongController.java index 7e0074d..812846c 100644 --- a/services/songs-service/src/main/java/org/apache/skywalking/showcase/services/song/controller/SongController.java +++ b/services/songs-service/src/main/java/org/apache/skywalking/showcase/services/song/controller/SongController.java @@ -20,12 +20,14 @@ package org.apache.skywalking.showcase.services.song.controller; import java.util.List; import lombok.RequiredArgsConstructor; +import lombok.extern.slf4j.Slf4j; import org.apache.skywalking.showcase.services.song.entity.Song; import org.apache.skywalking.showcase.services.song.repo.SongsRepo; import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RestController; +@Slf4j @RestController @RequiredArgsConstructor @RequestMapping("/songs") @@ -34,11 +36,13 @@ public class SongController { @GetMapping public List<Song> songs() { + log.info("Listing all songs"); return songsRepo.findAll(); } @GetMapping("/top") public List<Song> top() { + log.info("Listing top songs"); return songsRepo.findByLikedGreaterThan(1000); } } diff --git a/services/songs-service/src/main/resources/logback.xml b/services/songs-service/src/main/resources/logback.xml new file mode 100644 index 0000000..26951d0 --- /dev/null +++ b/services/songs-service/src/main/resources/logback.xml @@ -0,0 +1,13 @@ +<?xml version="1.0" encoding="UTF-8"?> +<configuration> + <appender name="grpc-log" class="org.apache.skywalking.apm.toolkit.log.logback.v1.x.log.GRPCLogClientAppender"> + <encoder class="ch.qos.logback.core.encoder.LayoutWrappingEncoder"> + <layout class="org.apache.skywalking.apm.toolkit.log.logback.v1.x.mdc.TraceIdMDCPatternLogbackLayout"> + <Pattern>%d{yyyy-MM-dd HH:mm:ss.SSS} [%X{tid}] [%thread] %-5level %logger{36} -%msg%n</Pattern> + </layout> + </encoder> + </appender> + <root level="INFO"> + <appender-ref ref="grpc-log"/> + </root> +</configuration>
