From e6a9404c6e38e80eee4271c495f88b321ebe3ad2 Mon Sep 17 00:00:00 2001 From: diegoitaliait Date: Thu, 9 Jan 2025 10:28:18 +0100 Subject: [PATCH 1/9] added virtual threads for java 21 --- src/main/resources/application.yml | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/main/resources/application.yml b/src/main/resources/application.yml index 131e0da..0ac28b3 100644 --- a/src/main/resources/application.yml +++ b/src/main/resources/application.yml @@ -3,6 +3,9 @@ spring: name: ${artifactId} version: ${version} jmx.enabled: true + threads: + virtual: + enabled: true management: endpoint: health: @@ -16,3 +19,5 @@ management: web: exposure.include: info, health app: + + From 55d815bc8ce15c7a4071a390fa446bedb6d9b071 Mon Sep 17 00:00:00 2001 From: diegoitaliait Date: Thu, 9 Jan 2025 10:28:32 +0100 Subject: [PATCH 2/9] added prometheus endpoint --- src/main/resources/application.yml | 21 +++++++++++++++++---- 1 file changed, 17 insertions(+), 4 deletions(-) diff --git a/src/main/resources/application.yml b/src/main/resources/application.yml index 0ac28b3..aa715ab 100644 --- a/src/main/resources/application.yml +++ b/src/main/resources/application.yml @@ -13,11 +13,24 @@ management: group: readiness.include: "*" liveness.include: livenessState,diskSpace,ping + prometheus: + enabled: true endpoints: jmx: exposure.include: "*" web: - exposure.include: info, health -app: - - + exposure.include: info, health, prometheus, metrics + metrics: + tags: + application: ${spring.application.name} + distribution: + percentiles-histogram: + http.server.requests: true + slo: + http.server.requests: 50ms, 100ms, 200ms + enable: + jvm: true + process: true + system: true + http: true +app: \ No newline at end of file From 3d9247a5074c0f98e270666ce3b32945c83eff6b Mon Sep 17 00:00:00 2001 From: diegoitaliait Date: Thu, 9 Jan 2025 10:33:59 +0100 Subject: [PATCH 3/9] added prometheus --- build.gradle.kts | 3 ++- src/main/resources/application.yml | 25 +++++++++++++++---------- 2 files changed, 17 insertions(+), 11 deletions(-) diff --git a/build.gradle.kts b/build.gradle.kts index 3072ff7..31c03a1 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -36,8 +36,9 @@ dependencies { implementation("org.springframework.boot:spring-boot-starter") implementation("org.springframework.boot:spring-boot-starter-web") implementation("org.springframework.boot:spring-boot-starter-actuator") - implementation("io.micrometer:micrometer-tracing-bridge-otel:$micrometerVersion") implementation("org.springdoc:springdoc-openapi-starter-webmvc-ui:$springDocOpenApiVersion") + implementation("io.micrometer:micrometer-tracing-bridge-otel:$micrometerVersion") + implementation("io.micrometer:micrometer-registry-prometheus") implementation("com.fasterxml.jackson.datatype:jackson-datatype-jsr310") implementation("org.openapitools:jackson-databind-nullable:$openApiToolsVersion") diff --git a/src/main/resources/application.yml b/src/main/resources/application.yml index aa715ab..dadb80b 100644 --- a/src/main/resources/application.yml +++ b/src/main/resources/application.yml @@ -7,6 +7,12 @@ spring: virtual: enabled: true management: + endpoints: + web: + exposure: + # Esponendo solo gli endpoint necessari per sicurezza + include: health, info, prometheus, metrics + base-path: /actuator endpoint: health: probes.enabled: true @@ -15,22 +21,21 @@ management: liveness.include: livenessState,diskSpace,ping prometheus: enabled: true - endpoints: - jmx: - exposure.include: "*" - web: - exposure.include: info, health, prometheus, metrics metrics: tags: application: ${spring.application.name} - distribution: - percentiles-histogram: - http.server.requests: true - slo: - http.server.requests: 50ms, 100ms, 200ms + environment: ${spring.profiles.active:default} + # Prometheus + export: + prometheus: + enabled: true + step: 1m + descriptions: true + # Metric type enable: jvm: true process: true system: true http: true + logback: true app: \ No newline at end of file From 253a1310056ff9e4e17b5c499d9ffc2ac2d03b5b Mon Sep 17 00:00:00 2001 From: diegoitaliait Date: Thu, 9 Jan 2025 10:50:23 +0100 Subject: [PATCH 4/9] updated readme --- README.md | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/README.md b/README.md index 83abf99..26a0aae 100644 --- a/README.md +++ b/README.md @@ -54,3 +54,30 @@ Ensure the following tools are installed on your machine: 1. **Java 21+** 2. **Gradle** (or use the Gradle wrapper included in the repository) 3. **Docker** (for Helm-related tasks, optional) + +### Building + +#### Build + +```sh +./gradlew clean build +``` + +#### Build + +```sh +./gradlew clean build +``` + +#### Run local + +```sh +./gradlew bootRun +``` + + +#### Write Locks + +```sh +./gradlew dependencies --write-locks +``` \ No newline at end of file From c13073d6cb2b62e3be7af59ff6f9c1ad0cac55e8 Mon Sep 17 00:00:00 2001 From: diegoitaliait Date: Thu, 9 Jan 2025 10:50:52 +0100 Subject: [PATCH 5/9] updated metric in application.yml --- src/main/resources/application.yml | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/src/main/resources/application.yml b/src/main/resources/application.yml index dadb80b..22a512e 100644 --- a/src/main/resources/application.yml +++ b/src/main/resources/application.yml @@ -1,7 +1,7 @@ spring: application: - name: ${artifactId} - version: ${version} + name: ${artifactId} + version: ${version} jmx.enabled: true threads: virtual: @@ -10,7 +10,6 @@ management: endpoints: web: exposure: - # Esponendo solo gli endpoint necessari per sicurezza include: health, info, prometheus, metrics base-path: /actuator endpoint: @@ -23,15 +22,12 @@ management: enabled: true metrics: tags: - application: ${spring.application.name} - environment: ${spring.profiles.active:default} - # Prometheus + application: ${artifactId} export: prometheus: enabled: true step: 1m descriptions: true - # Metric type enable: jvm: true process: true From 1da7542b46c44eb36979b8f87f008a326b54e829 Mon Sep 17 00:00:00 2001 From: diegoitaliait Date: Thu, 9 Jan 2025 10:51:04 +0100 Subject: [PATCH 6/9] updated gradle locks --- gradle.lockfile | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/gradle.lockfile b/gradle.lockfile index dbe58cc..ab6de54 100644 --- a/gradle.lockfile +++ b/gradle.lockfile @@ -17,6 +17,7 @@ io.micrometer:micrometer-commons:1.14.2=compileClasspath io.micrometer:micrometer-core:1.14.2=compileClasspath io.micrometer:micrometer-jakarta9:1.14.2=compileClasspath io.micrometer:micrometer-observation:1.14.2=compileClasspath +io.micrometer:micrometer-registry-prometheus:1.14.2=compileClasspath io.micrometer:micrometer-tracing-bridge-otel:1.4.1=compileClasspath io.micrometer:micrometer-tracing:1.4.1=compileClasspath io.opentelemetry.instrumentation:opentelemetry-instrumentation-api-incubator:2.9.0-alpha=compileClasspath @@ -30,6 +31,10 @@ io.opentelemetry:opentelemetry-sdk-logs:1.43.0=compileClasspath io.opentelemetry:opentelemetry-sdk-metrics:1.43.0=compileClasspath io.opentelemetry:opentelemetry-sdk-trace:1.43.0=compileClasspath io.opentelemetry:opentelemetry-sdk:1.43.0=compileClasspath +io.prometheus:prometheus-metrics-config:1.3.5=compileClasspath +io.prometheus:prometheus-metrics-core:1.3.5=compileClasspath +io.prometheus:prometheus-metrics-model:1.3.5=compileClasspath +io.prometheus:prometheus-metrics-tracer-common:1.3.5=compileClasspath io.swagger.core.v3:swagger-annotations-jakarta:2.2.25=compileClasspath io.swagger.core.v3:swagger-core-jakarta:2.2.25=compileClasspath io.swagger.core.v3:swagger-models-jakarta:2.2.25=compileClasspath From 136988878a2a64b41c3d7d5ca5941ac8b7f5ec61 Mon Sep 17 00:00:00 2001 From: diegoitaliait Date: Thu, 9 Jan 2025 10:51:48 +0100 Subject: [PATCH 7/9] pre-commit fixs --- .github/workflows/config/trivy.yaml | 2 +- .github/workflows/security-scan.yml | 2 +- .github/workflows/send-notification.yml | 2 +- README.md | 2 +- gradle/wrapper/gradle-wrapper.properties | 2 +- src/main/resources/application.yml | 2 +- 6 files changed, 6 insertions(+), 6 deletions(-) diff --git a/.github/workflows/config/trivy.yaml b/.github/workflows/config/trivy.yaml index 298b3a3..014a329 100644 --- a/.github/workflows/config/trivy.yaml +++ b/.github/workflows/config/trivy.yaml @@ -1,3 +1,3 @@ db: repository: "public.ecr.aws/aquasecurity/trivy-db:2" - java-repository: "public.ecr.aws/aquasecurity/trivy-java-db:1" \ No newline at end of file + java-repository: "public.ecr.aws/aquasecurity/trivy-java-db:1" diff --git a/.github/workflows/security-scan.yml b/.github/workflows/security-scan.yml index 3783154..149c9da 100644 --- a/.github/workflows/security-scan.yml +++ b/.github/workflows/security-scan.yml @@ -67,4 +67,4 @@ jobs: CVE_CRITICAL: ${{needs.BuildAndScan.outputs.CVE_CRITICAL}} CVE_HIGH: ${{needs.BuildAndScan.outputs.CVE_HIGH}} CVE_MEDIUM: ${{needs.BuildAndScan.outputs.CVE_MEDIUM}} - secrets: inherit \ No newline at end of file + secrets: inherit diff --git a/.github/workflows/send-notification.yml b/.github/workflows/send-notification.yml index 5820a14..acb0754 100644 --- a/.github/workflows/send-notification.yml +++ b/.github/workflows/send-notification.yml @@ -46,4 +46,4 @@ jobs: } env: SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }} - SLACK_WEBHOOK_TYPE: INCOMING_WEBHOOK \ No newline at end of file + SLACK_WEBHOOK_TYPE: INCOMING_WEBHOOK diff --git a/README.md b/README.md index 26a0aae..00a0579 100644 --- a/README.md +++ b/README.md @@ -80,4 +80,4 @@ Ensure the following tools are installed on your machine: ```sh ./gradlew dependencies --write-locks -``` \ No newline at end of file +``` diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index ccc1a9b..df97d72 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -4,4 +4,4 @@ distributionUrl=https\://services.gradle.org/distributions/gradle-8.10.2-bin.zip networkTimeout=10000 validateDistributionUrl=true zipStoreBase=GRADLE_USER_HOME -zipStorePath=wrapper/dists \ No newline at end of file +zipStorePath=wrapper/dists diff --git a/src/main/resources/application.yml b/src/main/resources/application.yml index 22a512e..a54b55a 100644 --- a/src/main/resources/application.yml +++ b/src/main/resources/application.yml @@ -34,4 +34,4 @@ management: system: true http: true logback: true -app: \ No newline at end of file +app: From d325d1317d522ee06b9d23b67d911c2429d6a48a Mon Sep 17 00:00:00 2001 From: Diego Lagos <92735530+diegolagospagopa@users.noreply.github.com> Date: Thu, 9 Jan 2025 12:34:53 +0100 Subject: [PATCH 8/9] fix readme --- README.md | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/README.md b/README.md index 00a0579..1ffe483 100644 --- a/README.md +++ b/README.md @@ -28,21 +28,26 @@ Here is a quick overview of the files and directories included in this repositor ## 🚀 Features ### 📜 OpenAPI + - Example OpenAPI specification file (`template-payments-java-repository.openapi.yaml`) to document your RESTful APIs. - Compatible with tools like Swagger and Postman. ### ⚙️ Helm + - Template Helm charts for deploying your Java application on Kubernetes. - Includes `values.yaml` for parameter configuration and pre-defined deployment manifests. ### 🔧 Gradle + - `build.gradle` file with dependencies and plugins for building, testing, and running your Java application. - Compatible with Java 21+. ### ☕ Java + - Example Java application structure with a simple `HelloWorld` class. ### ✅ JUnit + - Example JUnit test cases under the `test/` directory to help you get started with unit testing. --- @@ -50,18 +55,14 @@ Here is a quick overview of the files and directories included in this repositor ## 🛠️ Getting Started ### Prerequisites + Ensure the following tools are installed on your machine: + 1. **Java 21+** 2. **Gradle** (or use the Gradle wrapper included in the repository) 3. **Docker** (for Helm-related tasks, optional) -### Building - -#### Build - -```sh -./gradlew clean build -``` +### Building & Run #### Build @@ -75,7 +76,6 @@ Ensure the following tools are installed on your machine: ./gradlew bootRun ``` - #### Write Locks ```sh From 5cdbb026d52ce9e5d26a6e938a8ea58274ca0d2a Mon Sep 17 00:00:00 2001 From: Diego Lagos <92735530+diegolagospagopa@users.noreply.github.com> Date: Thu, 9 Jan 2025 12:35:01 +0100 Subject: [PATCH 9/9] fix indentation --- build.gradle.kts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build.gradle.kts b/build.gradle.kts index 31c03a1..0fdf645 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -37,7 +37,7 @@ dependencies { implementation("org.springframework.boot:spring-boot-starter-web") implementation("org.springframework.boot:spring-boot-starter-actuator") implementation("org.springdoc:springdoc-openapi-starter-webmvc-ui:$springDocOpenApiVersion") - implementation("io.micrometer:micrometer-tracing-bridge-otel:$micrometerVersion") + implementation("io.micrometer:micrometer-tracing-bridge-otel:$micrometerVersion") implementation("io.micrometer:micrometer-registry-prometheus") implementation("com.fasterxml.jackson.datatype:jackson-datatype-jsr310") implementation("org.openapitools:jackson-databind-nullable:$openApiToolsVersion")