Skip to content

Commit

Permalink
Merge pull request #8 from worldline/feat/fix_documentation
Browse files Browse the repository at this point in the history
feat: Keep working on documentation
  • Loading branch information
alexandre-touret authored Jun 23, 2024
2 parents 252579b + 778fdcc commit 9e0356d
Show file tree
Hide file tree
Showing 80 changed files with 6,391 additions and 608 deletions.
6 changes: 5 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -72,5 +72,9 @@ logs/*.json
logs/*.logfmt
logs/*.gz

### Custom user certificates ###
docker/ca-trust/*


LOG_FILE_IS_UNDEFINED*

LOG_FILE_IS_UNDEFINED
2 changes: 1 addition & 1 deletion .gitpod.Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ FROM gitpod/workspace-full

## Install dependencies
RUN sudo apt update && \
sudo apt install -y curl httpie jq
sudo apt install -y curl httpie jq dos2unix

RUN sudo gpg -k && \
sudo gpg --no-default-keyring --keyring /usr/share/keyrings/k6-archive-keyring.gpg --keyserver hkp://keyserver.ubuntu.com:80 --recv-keys C5AD17C747E3415A3642D57D77C6C491D6AC1D69 && \
Expand Down
9 changes: 9 additions & 0 deletions .gitpod.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,15 @@
image:
file: .gitpod.Dockerfile

vscode:
extensions:
- "redhat.java"
- "vscjava.vscode-gradle@3.13.5"

tasks:
# Download the Grafana OpenTelemetry Java agent and saves it in the instrumentation directory
- name: Download Grafana OpenTelemetry Java agent
before: mkdir -p instrumentation
command: curl -L https://github.com/grafana/grafana-opentelemetry-java/releases/download/v2.4.0-beta.1/grafana-opentelemetry-java.jar -o instrumentation/grafana-opentelemetry-java.jar
- name: Build and start all the infrastructure
command: docker compose up -d --build
4 changes: 1 addition & 3 deletions api-gateway/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
import org.springframework.boot.gradle.tasks.run.BootRun

plugins {
java
id("org.springframework.boot") version "3.3.0"
id("org.springframework.boot") version "3.3.1"
id("io.spring.dependency-management") version "1.1.5"
}

Expand Down
13 changes: 12 additions & 1 deletion api-gateway/src/main/docker/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,11 @@
FROM eclipse-temurin:21-jdk-alpine as build

ENV USE_SYSTEM_CA_CERTS=1

# INSTALL CA Certificates (useful for companies with SSL inspection)
ADD --chmod=644 docker/ca-trust/* /certificates/
RUN export USE_SYSTEM_CA_CERTS=1 && /__cacert_entrypoint.sh

WORKDIR /workspace/app

ENV SERVICE=api-gateway
Expand All @@ -9,11 +16,15 @@ COPY gradle gradle
COPY gradlew .
COPY settings.gradle.kts .

RUN --mount=type=cache,target=/root/.gradle ./gradlew :${SERVICE}:clean :${SERVICE}:build -x test
RUN --mount=type=cache,target=/root/.gradle /__cacert_entrypoint.sh ./gradlew :${SERVICE}:clean :${SERVICE}:build -x test
RUN mkdir -p ${SERVICE}/build/dependency && (cd ${SERVICE}/build/dependency && jar -xf ../libs/*-SNAPSHOT.jar)

FROM eclipse-temurin:21-jre-alpine

# INSTALL CA Certificates (useful for companies with SSL inspection)
ADD --chmod=644 docker/ca-trust/* /certificates/
RUN export USE_SYSTEM_CA_CERTS=1 && /__cacert_entrypoint.sh

ENV SERVICE=api-gateway
ENV LOGS_DIRECTORY=/logs/

Expand Down
18 changes: 18 additions & 0 deletions api-gateway/src/main/resources/application.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,5 +23,23 @@ spring:
uri: lb://FRAUDETECT-SERVICE
predicates:
- Path=/api/fraudetect/**
loadbalancer:
cache:
ttl: 1s
# refresh:
# enabled: false # AOT / Native Image does not support Spring Cloud Refresh Scope

management:
endpoint:
gateway:
enabled: true
endpoints:
web:
exposure:
include: "*"
metrics:
distribution:
percentiles-histogram:
http:
server:
requests: true
48 changes: 15 additions & 33 deletions api-gateway/src/main/resources/logback-spring.xml
Original file line number Diff line number Diff line change
Expand Up @@ -8,39 +8,21 @@
<springProperty scope="context" name="instance" source="spring.application.instance"
defaultValue="" />

<!--<springProfile name="logfmt-logging">
<property name="CONSOLE_LOG_PATTERN"
value="time=%d{yyyy-MM-dd'T'HH:mm:ss.SSSXXX} level=%p pid=${PID:- } thread=%t application=${applicationName} instance=${instance} logger=%logger msg=&quot;%m%wEx&quot;%n" />
<property
name="FILE_LOG_PATTERN"
value="time=%d{yyyy-MM-dd'T'HH:mm:ss.SSSXXX} level=%p pid=${PID:- } thread=%t application=${applicationName} instance=${instance} logger=%logger msg=&quot;%m&quot; err=&quot;%exc&quot;%n" />
<property
name="LOG_FILE"
value="${LOG_FILE}.logfmt"
/>
</springProfile>-->

<springProfile name="json-logging">
<appender name="FILE" class="ch.qos.logback.core.rolling.RollingFileAppender">
<filter class="ch.qos.logback.classic.filter.ThresholdFilter">
<level>${FILE_LOG_THRESHOLD}</level>
</filter>
<encoder class="ch.qos.logback.classic.encoder.JsonEncoder"/>
<file>${LOG_FILE}.json</file>
<rollingPolicy class="ch.qos.logback.core.rolling.SizeAndTimeBasedRollingPolicy">
<fileNamePattern>
${LOGBACK_ROLLINGPOLICY_FILE_NAME_PATTERN:-${LOG_FILE}.%d{yyyy-MM-dd}.%i.gz}</fileNamePattern>
<cleanHistoryOnStart>${LOGBACK_ROLLINGPOLICY_CLEAN_HISTORY_ON_START:-false}</cleanHistoryOnStart>
<maxFileSize>${LOGBACK_ROLLINGPOLICY_MAX_FILE_SIZE:-10MB}</maxFileSize>
<totalSizeCap>${LOGBACK_ROLLINGPOLICY_TOTAL_SIZE_CAP:-0}</totalSizeCap>
<maxHistory>${LOGBACK_ROLLINGPOLICY_MAX_HISTORY:-7}</maxHistory>
</rollingPolicy>
</appender>
</springProfile>

<springProfile name="!json-logging">
<include resource="org/springframework/boot/logging/logback/file-appender.xml" />
</springProfile>
<appender name="FILE" class="ch.qos.logback.core.rolling.RollingFileAppender">
<filter class="ch.qos.logback.classic.filter.ThresholdFilter">
<level>${FILE_LOG_THRESHOLD}</level>
</filter>
<encoder class="ch.qos.logback.classic.encoder.JsonEncoder"/>
<file>${LOG_FILE}.json</file>
<rollingPolicy class="ch.qos.logback.core.rolling.SizeAndTimeBasedRollingPolicy">
<fileNamePattern>
${LOGBACK_ROLLINGPOLICY_FILE_NAME_PATTERN:-${LOG_FILE}.%d{yyyy-MM-dd}.%i.gz}</fileNamePattern>
<cleanHistoryOnStart>${LOGBACK_ROLLINGPOLICY_CLEAN_HISTORY_ON_START:-false}</cleanHistoryOnStart>
<maxFileSize>${LOGBACK_ROLLINGPOLICY_MAX_FILE_SIZE:-10MB}</maxFileSize>
<totalSizeCap>${LOGBACK_ROLLINGPOLICY_TOTAL_SIZE_CAP:-0}</totalSizeCap>
<maxHistory>${LOGBACK_ROLLINGPOLICY_MAX_HISTORY:-7}</maxHistory>
</rollingPolicy>
</appender>

<root level="INFO">
<appender-ref ref="CONSOLE" />
Expand Down
7 changes: 7 additions & 0 deletions api-gateway/src/test/resources/application.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
spring:
cloud:
config:
enabled: false
eureka:
client:
enabled: false
8 changes: 8 additions & 0 deletions api-gateway/src/test/resources/logback-test.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
<configuration>
<include resource="org/springframework/boot/logging/logback/defaults.xml"/>
<include resource="org/springframework/boot/logging/logback/console-appender.xml" />
<root level="INFO">
<appender-ref ref="CONSOLE" />
</root>
</configuration>
34 changes: 28 additions & 6 deletions compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -200,9 +200,11 @@ services:
- GF_PATHS_PROVISIONING=/etc/grafana/provisioning
- GF_AUTH_ANONYMOUS_ENABLED=true
- GF_AUTH_ANONYMOUS_ORG_ROLE=Admin
volumes:
- ./docker/grafana/datasources:/etc/grafana/provisioning/dashboards
entrypoint:
- sh
- -euc
- -xeuc
- |
mkdir -p /etc/grafana/provisioning/datasources
cat <<EOF > /etc/grafana/provisioning/datasources/ds.yaml
Expand All @@ -214,9 +216,16 @@ services:
orgId: 1
url: http://loki:3100
basicAuth: false
isDefault: false
isDefault: true
version: 1
editable: false
editable: true
jsonData:
derivedFields:
- datasourceUid: tempo
matcherRegex: 'trace_id'
matcherType: 'label'
name: TraceID
urlDisplayLabel: 'View Trace'
- name: Prometheus
type: prometheus
uid: prometheus
Expand All @@ -226,24 +235,37 @@ services:
basicAuth: false
isDefault: false
version: 1
editable: false
editable: true
jsonData:
httpMethod: GET
exemplarTraceIdDestinations:
- datasourceUid: tempo
name: TraceID
- name: Tempo
type: tempo
access: proxy
orgId: 1
url: http://tempo:3200
basicAuth: false
isDefault: true
isDefault: false
version: 1
editable: false
editable: true
apiVersion: 1
uid: tempo
jsonData:
httpMethod: GET
serviceMap:
datasourceUid: prometheus
tracesToLogsV2:
datasourceUid: loki
filterBySpanID: false
filterByTraceID: true
tags:
- application
tracesToMetrics:
datasourceUid: prometheus
tags:
- application
EOF
/run.sh
image: grafana/grafana:latest
Expand Down
3 changes: 1 addition & 2 deletions config-server/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
plugins {
java
id("org.springframework.boot") version "3.3.0"
id("org.springframework.boot") version "3.3.1"
id("io.spring.dependency-management") version "1.1.5"
}

Expand All @@ -19,7 +19,6 @@ extra["springCloudVersion"] = "2023.0.2"

dependencies {
implementation("org.springframework.cloud:spring-cloud-config-server")
implementation("org.springframework.boot:spring-boot-starter-actuator")

// Expose metrics with Micrometer using a Prometheus registry
implementation("org.springframework.boot:spring-boot-starter-actuator")
Expand Down
9 changes: 9 additions & 0 deletions config-server/src/main/docker/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,9 @@
FROM eclipse-temurin:21-jdk-alpine as build

# INSTALL CA Certificates (useful for companies with SSL inspection)
ADD --chmod=644 docker/ca-trust/* /certificates/
RUN export USE_SYSTEM_CA_CERTS=1 && /__cacert_entrypoint.sh

WORKDIR /workspace/app

ENV SERVICE=config-server
Expand All @@ -14,6 +19,10 @@ RUN mkdir -p ${SERVICE}/build/dependency && (cd ${SERVICE}/build/dependency && j

FROM eclipse-temurin:21-jre-alpine

# INSTALL CA Certificates (useful for companies with SSL inspection)
ADD --chmod=644 docker/ca-trust/* /certificates/
RUN export USE_SYSTEM_CA_CERTS=1 && /__cacert_entrypoint.sh

ENV SERVICE=config-server
ENV LOGS_DIRECTORY=/logs/

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
package com.worldline.easypay.configserver.config;

import org.springframework.boot.autoconfigure.condition.ConditionalOnClass;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import io.prometheus.metrics.tracer.otel_agent.OpenTelemetryAgentSpanContext;


@Configuration
public class PrometheusRegistryConfiguration {

@Bean
@ConditionalOnClass(name="io.opentelemetry.javaagent.shaded.io.opentelemetry.api.trace.Span")
public OpenTelemetryAgentSpanContext exemplarConfigSupplier() {
return new OpenTelemetryAgentSpanContext();
}
}
1 change: 1 addition & 0 deletions config-server/src/main/resources/application.properties
Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,6 @@ spring.cloud.config.server.native.searchLocations=classpath:/config-server
#spring.cloud.refresh.enabled=false

management.server.port=8890
management.endpoints.web.exposure.include=*

logging.file.name=${LOGS_DIRECTORY:../logs}/${spring.application.instance:${spring.application.name:spring}}.log
13 changes: 12 additions & 1 deletion config-server/src/main/resources/config-server/application.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,21 @@ eureka:
management:
security:
enabled: false
endpoint:
endpoints:
web:
exposure:
include: "*"
metrics:
tags:
application: ${spring.application.name}
instance: ${spring.application.instance}
namespace: local
metrics:
distribution:
percentiles-histogram:
http:
server:
requests: true

logging:
level:
Expand Down
48 changes: 15 additions & 33 deletions config-server/src/main/resources/logback-spring.xml
Original file line number Diff line number Diff line change
Expand Up @@ -8,39 +8,21 @@
<springProperty scope="context" name="instance" source="spring.application.instance"
defaultValue="" />

<!--<springProfile name="logfmt-logging">
<property name="CONSOLE_LOG_PATTERN"
value="time=%d{yyyy-MM-dd'T'HH:mm:ss.SSSXXX} level=%p pid=${PID:- } thread=%t application=${applicationName} instance=${instance} logger=%logger msg=&quot;%m%wEx&quot;%n" />
<property
name="FILE_LOG_PATTERN"
value="time=%d{yyyy-MM-dd'T'HH:mm:ss.SSSXXX} level=%p pid=${PID:- } thread=%t application=${applicationName} instance=${instance} logger=%logger msg=&quot;%m&quot; err=&quot;%exc&quot;%n" />
<property
name="LOG_FILE"
value="${LOG_FILE}.logfmt"
/>
</springProfile>-->

<springProfile name="json-logging">
<appender name="FILE" class="ch.qos.logback.core.rolling.RollingFileAppender">
<filter class="ch.qos.logback.classic.filter.ThresholdFilter">
<level>${FILE_LOG_THRESHOLD}</level>
</filter>
<encoder class="ch.qos.logback.classic.encoder.JsonEncoder"/>
<file>${LOG_FILE}.json</file>
<rollingPolicy class="ch.qos.logback.core.rolling.SizeAndTimeBasedRollingPolicy">
<fileNamePattern>
${LOGBACK_ROLLINGPOLICY_FILE_NAME_PATTERN:-${LOG_FILE}.%d{yyyy-MM-dd}.%i.gz}</fileNamePattern>
<cleanHistoryOnStart>${LOGBACK_ROLLINGPOLICY_CLEAN_HISTORY_ON_START:-false}</cleanHistoryOnStart>
<maxFileSize>${LOGBACK_ROLLINGPOLICY_MAX_FILE_SIZE:-10MB}</maxFileSize>
<totalSizeCap>${LOGBACK_ROLLINGPOLICY_TOTAL_SIZE_CAP:-0}</totalSizeCap>
<maxHistory>${LOGBACK_ROLLINGPOLICY_MAX_HISTORY:-7}</maxHistory>
</rollingPolicy>
</appender>
</springProfile>

<springProfile name="!json-logging">
<include resource="org/springframework/boot/logging/logback/file-appender.xml" />
</springProfile>
<appender name="FILE" class="ch.qos.logback.core.rolling.RollingFileAppender">
<filter class="ch.qos.logback.classic.filter.ThresholdFilter">
<level>${FILE_LOG_THRESHOLD}</level>
</filter>
<encoder class="ch.qos.logback.classic.encoder.JsonEncoder"/>
<file>${LOG_FILE}.json</file>
<rollingPolicy class="ch.qos.logback.core.rolling.SizeAndTimeBasedRollingPolicy">
<fileNamePattern>
${LOGBACK_ROLLINGPOLICY_FILE_NAME_PATTERN:-${LOG_FILE}.%d{yyyy-MM-dd}.%i.gz}</fileNamePattern>
<cleanHistoryOnStart>${LOGBACK_ROLLINGPOLICY_CLEAN_HISTORY_ON_START:-false}</cleanHistoryOnStart>
<maxFileSize>${LOGBACK_ROLLINGPOLICY_MAX_FILE_SIZE:-10MB}</maxFileSize>
<totalSizeCap>${LOGBACK_ROLLINGPOLICY_TOTAL_SIZE_CAP:-0}</totalSizeCap>
<maxHistory>${LOGBACK_ROLLINGPOLICY_MAX_HISTORY:-7}</maxHistory>
</rollingPolicy>
</appender>

<root level="INFO">
<appender-ref ref="CONSOLE" />
Expand Down
8 changes: 8 additions & 0 deletions config-server/src/test/resources/logback-test.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
<configuration>
<include resource="org/springframework/boot/logging/logback/defaults.xml"/>
<include resource="org/springframework/boot/logging/logback/console-appender.xml" />
<root level="INFO">
<appender-ref ref="CONSOLE" />
</root>
</configuration>
Loading

0 comments on commit 9e0356d

Please sign in to comment.