From 545f9c2bbab81d430184823c91d5e9559727c310 Mon Sep 17 00:00:00 2001 From: AngeloCaporaso Date: Fri, 3 May 2024 16:42:29 +0200 Subject: [PATCH 01/16] [PAGOPA-1595] ci(docker): add opentelemetry java agent --- Dockerfile | 15 ++++++++------- README.md | 6 +----- helm/values-dev.yaml | 14 +++++--------- 3 files changed, 14 insertions(+), 21 deletions(-) diff --git a/Dockerfile b/Dockerfile index bb2b956..086e409 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,16 +1,17 @@ # # Build stage # -FROM maven:3.8.2-openjdk-17-slim AS build -COPY src /home/app/src -COPY pom.xml /home/app -RUN mvn -f /home/app/pom.xml clean package -Dmaven.test.skip=true +FROM maven:3.8.4-openjdk-17-slim AS build +WORKDIR /app +COPY pom.xml . +COPY src ./src +RUN mvn -B -DskipTests=true clean package -Dmaven.test.skip=true # # Package stage # FROM openjdk:17-alpine -COPY --from=build /home/app/target/pagopa-gpd-upload*.jar /usr/local/lib/app.jar -RUN true +ADD https://github.com/open-telemetry/opentelemetry-java-instrumentation/releases/download/v1.25.1/opentelemetry-javaagent.jar /opt/opentelemetry-javaagent.jar +COPY --from=build /app/target/pagopa-gpd-upload*.jar /app/app.jar EXPOSE 8080 -ENTRYPOINT ["java","-jar","/usr/local/lib/app.jar"] +ENTRYPOINT ["java", "-javaagent:/opt/opentelemetry-javaagent.jar", "-jar", "/app/app.jar"] \ No newline at end of file diff --git a/README.md b/README.md index 5193c17..a3708f7 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ ## GPD Massive Upload ยต-service -[![Quality Gate Status](https://sonarcloud.io/api/project_badges/measure?project=TODO-set-your-id&metric=alert_status)](https://sonarcloud.io/dashboard?id=TODO-set-your-id) +[![Quality Gate Status](https://sonarcloud.io/api/project_badges/measure?project=pagopa_pagopa-gpd-upload&metric=alert_status)](https://sonarcloud.io/dashboard?id=pagopa_pagopa-gpd-upload) [![Integration Tests](https://github.com/pagopa/pagopa-gpd-upload/actions/workflows/integration_test.yml/badge.svg)](https://github.com/pagopa/pagopa-gpd-upload/actions/workflows/integration_test.yml) @@ -10,10 +10,6 @@ It allows the creditor institutions to: - Get Debt Positions massive Upload status - Get Debt Positions massive Upload report -TODO: generate a index with this tool: https://ecotrust-canada.github.io/markdown-toc/ - -TODO: resolve all the TODOs in this template - --- ## Api Documentation ๐Ÿ“– diff --git a/helm/values-dev.yaml b/helm/values-dev.yaml index 30a43ca..b849b3f 100644 --- a/helm/values-dev.yaml +++ b/helm/values-dev.yaml @@ -73,17 +73,13 @@ microservice-chart: CONTAINER_NAME: "gpd_upload_status" POST_FILE_RETRY_AFTER: '10000' LOG_LEVEL: "DEBUG" - # CORS_CONFIGURATION: '{"origins": ["*"], "methods": ["*"]}' - # OTEL_SERVICE_NAME: # TODO - # OTEL_RESOURCE_ATTRIBUTES: "deployment.environment=dev" - # OTEL_EXPORTER_OTLP_ENDPOINT: "http://otel-collector.elastic-system.svc:4317" - # OTEL_TRACES_EXPORTER: otlp - # OTEL_METRICS_EXPORTER: otlp - # OTEL_LOGS_EXPORTER: none - # OTEL_TRACES_SAMPLER: "always_on" + OTEL_RESOURCE_ATTRIBUTES: "service.name=pagopa-gpd-upload,deployment.environment=dev" + OTEL_EXPORTER_OTLP_ENDPOINT: "http://otel-collector.elastic-system.svc:4317" + OTEL_LOGS_EXPORTER: none + OTEL_TRACES_SAMPLER: "always_on" envSecret: # APPLICATIONINSIGHTS_CONNECTION_STRING: 'ai-d-connection-string' - # OTEL_EXPORTER_OTLP_HEADERS: elastic-apm-secret-token + OTEL_EXPORTER_OTLP_HEADERS: elastic-apm-secret-token BLOB_CONNECTION_STRING: 'gpd-upload-sa-connection-string' COSMOS_KEY: 'gpd-upload-db-key' keyvault: From abdcee467aafbc0c58ea005d727d53c974ecf525 Mon Sep 17 00:00:00 2001 From: pagopa-github-bot Date: Fri, 3 May 2024 14:43:58 +0000 Subject: [PATCH 02/16] Bump to version 0.1.22-1-PAGOPA-1595-elk [skip ci] --- helm/Chart.yaml | 4 ++-- helm/values-dev.yaml | 2 +- helm/values-prod.yaml | 2 +- helm/values-uat.yaml | 2 +- openapi/openapi.json | 2 +- pom.xml | 2 +- 6 files changed, 7 insertions(+), 7 deletions(-) diff --git a/helm/Chart.yaml b/helm/Chart.yaml index 6418ffb..938dce0 100644 --- a/helm/Chart.yaml +++ b/helm/Chart.yaml @@ -2,8 +2,8 @@ apiVersion: v2 name: pagopa-gpd-upload description: Microservice that handles file upload of massive debt positions JSON object type: application -version: 0.67.0 -appVersion: 0.1.22 +version: 0.68.0 +appVersion: 0.1.22-1-PAGOPA-1595-elk dependencies: - name: microservice-chart version: 2.8.0 diff --git a/helm/values-dev.yaml b/helm/values-dev.yaml index b849b3f..3c6b17d 100644 --- a/helm/values-dev.yaml +++ b/helm/values-dev.yaml @@ -4,7 +4,7 @@ microservice-chart: fullnameOverride: "" image: repository: ghcr.io/pagopa/pagopa-gpd-upload - tag: "0.1.22" + tag: "0.1.22-1-PAGOPA-1595-elk" pullPolicy: Always livenessProbe: httpGet: diff --git a/helm/values-prod.yaml b/helm/values-prod.yaml index 1c88da8..d88123f 100644 --- a/helm/values-prod.yaml +++ b/helm/values-prod.yaml @@ -4,7 +4,7 @@ microservice-chart: fullnameOverride: "" image: repository: ghcr.io/pagopa/pagopa-gpd-upload - tag: "0.1.22" + tag: "0.1.22-1-PAGOPA-1595-elk" pullPolicy: Always livenessProbe: httpGet: diff --git a/helm/values-uat.yaml b/helm/values-uat.yaml index 934f17e..9fb1c82 100644 --- a/helm/values-uat.yaml +++ b/helm/values-uat.yaml @@ -4,7 +4,7 @@ microservice-chart: fullnameOverride: "" image: repository: ghcr.io/pagopa/pagopa-gpd-upload - tag: "0.1.22" + tag: "0.1.22-1-PAGOPA-1595-elk" pullPolicy: Always livenessProbe: httpGet: diff --git a/openapi/openapi.json b/openapi/openapi.json index 5729884..5d33ee8 100644 --- a/openapi/openapi.json +++ b/openapi/openapi.json @@ -2,7 +2,7 @@ "openapi": "3.0.1", "info": { "title": "pagopa-gpd-upload", - "version": "0.1.22" + "version": "0.1.22-1-PAGOPA-1595-elk" }, "paths": { "/brokers/{broker-code}/organizations/{organization-fiscal-code}/debtpositions/file": { diff --git a/pom.xml b/pom.xml index 80814b4..8b85362 100644 --- a/pom.xml +++ b/pom.xml @@ -4,7 +4,7 @@ 4.0.0 it.gov.pagopa.gpd.upload pagopa-gpd-upload - 0.1.22 + 0.1.22-1-PAGOPA-1595-elk ${packaging} From 5ee39777737d5f0f47fb15e5bcb6dbedebe5913d Mon Sep 17 00:00:00 2001 From: pagopa-github-bot Date: Mon, 6 May 2024 09:00:51 +0000 Subject: [PATCH 03/16] Bump to version 0.1.22-2-PAGOPA-1595-elk [skip ci] --- helm/Chart.yaml | 4 ++-- helm/values-dev.yaml | 2 +- helm/values-prod.yaml | 2 +- helm/values-uat.yaml | 2 +- openapi/openapi.json | 2 +- pom.xml | 2 +- 6 files changed, 7 insertions(+), 7 deletions(-) diff --git a/helm/Chart.yaml b/helm/Chart.yaml index 938dce0..cdfb5d6 100644 --- a/helm/Chart.yaml +++ b/helm/Chart.yaml @@ -2,8 +2,8 @@ apiVersion: v2 name: pagopa-gpd-upload description: Microservice that handles file upload of massive debt positions JSON object type: application -version: 0.68.0 -appVersion: 0.1.22-1-PAGOPA-1595-elk +version: 0.69.0 +appVersion: 0.1.22-2-PAGOPA-1595-elk dependencies: - name: microservice-chart version: 2.8.0 diff --git a/helm/values-dev.yaml b/helm/values-dev.yaml index 3c6b17d..db2164f 100644 --- a/helm/values-dev.yaml +++ b/helm/values-dev.yaml @@ -4,7 +4,7 @@ microservice-chart: fullnameOverride: "" image: repository: ghcr.io/pagopa/pagopa-gpd-upload - tag: "0.1.22-1-PAGOPA-1595-elk" + tag: "0.1.22-2-PAGOPA-1595-elk" pullPolicy: Always livenessProbe: httpGet: diff --git a/helm/values-prod.yaml b/helm/values-prod.yaml index d88123f..e3eccf4 100644 --- a/helm/values-prod.yaml +++ b/helm/values-prod.yaml @@ -4,7 +4,7 @@ microservice-chart: fullnameOverride: "" image: repository: ghcr.io/pagopa/pagopa-gpd-upload - tag: "0.1.22-1-PAGOPA-1595-elk" + tag: "0.1.22-2-PAGOPA-1595-elk" pullPolicy: Always livenessProbe: httpGet: diff --git a/helm/values-uat.yaml b/helm/values-uat.yaml index 9fb1c82..e614202 100644 --- a/helm/values-uat.yaml +++ b/helm/values-uat.yaml @@ -4,7 +4,7 @@ microservice-chart: fullnameOverride: "" image: repository: ghcr.io/pagopa/pagopa-gpd-upload - tag: "0.1.22-1-PAGOPA-1595-elk" + tag: "0.1.22-2-PAGOPA-1595-elk" pullPolicy: Always livenessProbe: httpGet: diff --git a/openapi/openapi.json b/openapi/openapi.json index 5d33ee8..2207639 100644 --- a/openapi/openapi.json +++ b/openapi/openapi.json @@ -2,7 +2,7 @@ "openapi": "3.0.1", "info": { "title": "pagopa-gpd-upload", - "version": "0.1.22-1-PAGOPA-1595-elk" + "version": "0.1.22-2-PAGOPA-1595-elk" }, "paths": { "/brokers/{broker-code}/organizations/{organization-fiscal-code}/debtpositions/file": { diff --git a/pom.xml b/pom.xml index 8b85362..99bf562 100644 --- a/pom.xml +++ b/pom.xml @@ -4,7 +4,7 @@ 4.0.0 it.gov.pagopa.gpd.upload pagopa-gpd-upload - 0.1.22-1-PAGOPA-1595-elk + 0.1.22-2-PAGOPA-1595-elk ${packaging} From dd8f1c99fa9d52d879104cc9cf68e44b4f0b1732 Mon Sep 17 00:00:00 2001 From: AngeloCaporaso Date: Mon, 6 May 2024 11:33:20 +0200 Subject: [PATCH 04/16] [PAGOPA-1595] ci(ELK): Add OTEL_SERVICE_NAME --- helm/values-dev.yaml | 1 + 1 file changed, 1 insertion(+) diff --git a/helm/values-dev.yaml b/helm/values-dev.yaml index d2a4913..54995b7 100644 --- a/helm/values-dev.yaml +++ b/helm/values-dev.yaml @@ -73,6 +73,7 @@ microservice-chart: CONTAINER_NAME: "gpd_upload_status" POST_FILE_RETRY_AFTER: '10000' LOG_LEVEL: "DEBUG" + OTEL_SERVICE_NAME: "pagopa-gpd-upload" OTEL_RESOURCE_ATTRIBUTES: "service.name=pagopa-gpd-upload,deployment.environment=dev" OTEL_EXPORTER_OTLP_ENDPOINT: "http://otel-collector.elastic-system.svc:4317" OTEL_LOGS_EXPORTER: none From 528c677d0849967abd0da82d89e8851ab4b6da76 Mon Sep 17 00:00:00 2001 From: pagopa-github-bot Date: Mon, 6 May 2024 09:34:49 +0000 Subject: [PATCH 05/16] Bump to version 0.1.23-1-PAGOPA-1595-elk [skip ci] --- helm/Chart.yaml | 4 ++-- helm/values-dev.yaml | 2 +- helm/values-prod.yaml | 2 +- helm/values-uat.yaml | 2 +- openapi/openapi.json | 2 +- pom.xml | 2 +- 6 files changed, 7 insertions(+), 7 deletions(-) diff --git a/helm/Chart.yaml b/helm/Chart.yaml index f154fe7..db73487 100644 --- a/helm/Chart.yaml +++ b/helm/Chart.yaml @@ -2,8 +2,8 @@ apiVersion: v2 name: pagopa-gpd-upload description: Microservice that handles file upload of massive debt positions JSON object type: application -version: 0.68.0 -appVersion: 0.1.23 +version: 0.69.0 +appVersion: 0.1.23-1-PAGOPA-1595-elk dependencies: - name: microservice-chart version: 2.8.0 diff --git a/helm/values-dev.yaml b/helm/values-dev.yaml index 54995b7..8d06bab 100644 --- a/helm/values-dev.yaml +++ b/helm/values-dev.yaml @@ -4,7 +4,7 @@ microservice-chart: fullnameOverride: "" image: repository: ghcr.io/pagopa/pagopa-gpd-upload - tag: "0.1.23" + tag: "0.1.23-1-PAGOPA-1595-elk" pullPolicy: Always livenessProbe: httpGet: diff --git a/helm/values-prod.yaml b/helm/values-prod.yaml index a98a156..272c312 100644 --- a/helm/values-prod.yaml +++ b/helm/values-prod.yaml @@ -4,7 +4,7 @@ microservice-chart: fullnameOverride: "" image: repository: ghcr.io/pagopa/pagopa-gpd-upload - tag: "0.1.23" + tag: "0.1.23-1-PAGOPA-1595-elk" pullPolicy: Always livenessProbe: httpGet: diff --git a/helm/values-uat.yaml b/helm/values-uat.yaml index fcb8a41..781538c 100644 --- a/helm/values-uat.yaml +++ b/helm/values-uat.yaml @@ -4,7 +4,7 @@ microservice-chart: fullnameOverride: "" image: repository: ghcr.io/pagopa/pagopa-gpd-upload - tag: "0.1.23" + tag: "0.1.23-1-PAGOPA-1595-elk" pullPolicy: Always livenessProbe: httpGet: diff --git a/openapi/openapi.json b/openapi/openapi.json index c40e1c1..b5d0ed0 100644 --- a/openapi/openapi.json +++ b/openapi/openapi.json @@ -4,7 +4,7 @@ "description": "Microservice to manage PagoPA GPD Upload", "termsOfService": "https://www.pagopa.gov.it/", "title": "pagoPA GPD Upload", - "version": "0.1.23" + "version": "0.1.23-1-PAGOPA-1595-elk" }, "servers": [ { diff --git a/pom.xml b/pom.xml index f76319e..1317de2 100644 --- a/pom.xml +++ b/pom.xml @@ -4,7 +4,7 @@ 4.0.0 it.gov.pagopa.gpd.upload pagopa-gpd-upload - 0.1.23 + 0.1.23-1-PAGOPA-1595-elk ${packaging} From 86a97898a7f9e5110c199d48f9bc7089d5a57551 Mon Sep 17 00:00:00 2001 From: pagopa-github-bot Date: Mon, 6 May 2024 09:40:49 +0000 Subject: [PATCH 06/16] Bump to version 0.1.23-2-PAGOPA-1595-elk [skip ci] --- helm/Chart.yaml | 4 ++-- helm/values-dev.yaml | 2 +- helm/values-prod.yaml | 2 +- helm/values-uat.yaml | 2 +- openapi/openapi.json | 2 +- pom.xml | 2 +- 6 files changed, 7 insertions(+), 7 deletions(-) diff --git a/helm/Chart.yaml b/helm/Chart.yaml index db73487..462d498 100644 --- a/helm/Chart.yaml +++ b/helm/Chart.yaml @@ -2,8 +2,8 @@ apiVersion: v2 name: pagopa-gpd-upload description: Microservice that handles file upload of massive debt positions JSON object type: application -version: 0.69.0 -appVersion: 0.1.23-1-PAGOPA-1595-elk +version: 0.70.0 +appVersion: 0.1.23-2-PAGOPA-1595-elk dependencies: - name: microservice-chart version: 2.8.0 diff --git a/helm/values-dev.yaml b/helm/values-dev.yaml index 8d06bab..63cdd24 100644 --- a/helm/values-dev.yaml +++ b/helm/values-dev.yaml @@ -4,7 +4,7 @@ microservice-chart: fullnameOverride: "" image: repository: ghcr.io/pagopa/pagopa-gpd-upload - tag: "0.1.23-1-PAGOPA-1595-elk" + tag: "0.1.23-2-PAGOPA-1595-elk" pullPolicy: Always livenessProbe: httpGet: diff --git a/helm/values-prod.yaml b/helm/values-prod.yaml index 272c312..a3fa63c 100644 --- a/helm/values-prod.yaml +++ b/helm/values-prod.yaml @@ -4,7 +4,7 @@ microservice-chart: fullnameOverride: "" image: repository: ghcr.io/pagopa/pagopa-gpd-upload - tag: "0.1.23-1-PAGOPA-1595-elk" + tag: "0.1.23-2-PAGOPA-1595-elk" pullPolicy: Always livenessProbe: httpGet: diff --git a/helm/values-uat.yaml b/helm/values-uat.yaml index 781538c..6b5b9f9 100644 --- a/helm/values-uat.yaml +++ b/helm/values-uat.yaml @@ -4,7 +4,7 @@ microservice-chart: fullnameOverride: "" image: repository: ghcr.io/pagopa/pagopa-gpd-upload - tag: "0.1.23-1-PAGOPA-1595-elk" + tag: "0.1.23-2-PAGOPA-1595-elk" pullPolicy: Always livenessProbe: httpGet: diff --git a/openapi/openapi.json b/openapi/openapi.json index b5d0ed0..ad72df2 100644 --- a/openapi/openapi.json +++ b/openapi/openapi.json @@ -4,7 +4,7 @@ "description": "Microservice to manage PagoPA GPD Upload", "termsOfService": "https://www.pagopa.gov.it/", "title": "pagoPA GPD Upload", - "version": "0.1.23-1-PAGOPA-1595-elk" + "version": "0.1.23-2-PAGOPA-1595-elk" }, "servers": [ { diff --git a/pom.xml b/pom.xml index 1317de2..013bf8c 100644 --- a/pom.xml +++ b/pom.xml @@ -4,7 +4,7 @@ 4.0.0 it.gov.pagopa.gpd.upload pagopa-gpd-upload - 0.1.23-1-PAGOPA-1595-elk + 0.1.23-2-PAGOPA-1595-elk ${packaging} From 659861b77dd4d05ebd72143eb2c7ef96b147c496 Mon Sep 17 00:00:00 2001 From: AngeloCaporaso Date: Mon, 6 May 2024 12:20:32 +0200 Subject: [PATCH 07/16] [PAGOPA-1595] ci(helm): Config UAT OTEL --- helm/values-uat.yaml | 15 ++++++--------- 1 file changed, 6 insertions(+), 9 deletions(-) diff --git a/helm/values-uat.yaml b/helm/values-uat.yaml index 6b5b9f9..e236272 100644 --- a/helm/values-uat.yaml +++ b/helm/values-uat.yaml @@ -73,17 +73,14 @@ microservice-chart: CONTAINER_NAME: "gpd_upload_status" POST_FILE_RETRY_AFTER: '10000' LOG_LEVEL: "INFO" - # CORS_CONFIGURATION: '{"origins": ["*"], "methods": ["*"]}' - # OTEL_SERVICE_NAME: # TODO - # OTEL_RESOURCE_ATTRIBUTES: "deployment.environment=dev" - # OTEL_EXPORTER_OTLP_ENDPOINT: "http://otel-collector.elastic-system.svc:4317" - # OTEL_TRACES_EXPORTER: otlp - # OTEL_METRICS_EXPORTER: otlp - # OTEL_LOGS_EXPORTER: none - # OTEL_TRACES_SAMPLER: "always_on" + OTEL_SERVICE_NAME: "pagopa-gpd-upload" + OTEL_RESOURCE_ATTRIBUTES: "deployment.environment=uat" + OTEL_EXPORTER_OTLP_ENDPOINT: "http://otel-collector.elastic-system.svc:4317" + OTEL_LOGS_EXPORTER: none + OTEL_TRACES_SAMPLER: "always_on" envSecret: # APPLICATIONINSIGHTS_CONNECTION_STRING: 'ai-d-connection-string' - # OTEL_EXPORTER_OTLP_HEADERS: elastic-apm-secret-token + OTEL_EXPORTER_OTLP_HEADERS: elastic-apm-secret-token BLOB_CONNECTION_STRING: 'gpd-upload-sa-connection-string' COSMOS_KEY: 'gpd-upload-db-key' keyvault: From d165154d441cebf0447a9a5b4878c5e494f5644d Mon Sep 17 00:00:00 2001 From: pagopa-github-bot Date: Mon, 6 May 2024 10:22:11 +0000 Subject: [PATCH 08/16] Bump to version 0.1.23-3-PAGOPA-1595-elk [skip ci] --- helm/Chart.yaml | 4 ++-- helm/values-dev.yaml | 2 +- helm/values-prod.yaml | 2 +- helm/values-uat.yaml | 2 +- openapi/openapi.json | 2 +- pom.xml | 2 +- 6 files changed, 7 insertions(+), 7 deletions(-) diff --git a/helm/Chart.yaml b/helm/Chart.yaml index 462d498..832cc9f 100644 --- a/helm/Chart.yaml +++ b/helm/Chart.yaml @@ -2,8 +2,8 @@ apiVersion: v2 name: pagopa-gpd-upload description: Microservice that handles file upload of massive debt positions JSON object type: application -version: 0.70.0 -appVersion: 0.1.23-2-PAGOPA-1595-elk +version: 0.71.0 +appVersion: 0.1.23-3-PAGOPA-1595-elk dependencies: - name: microservice-chart version: 2.8.0 diff --git a/helm/values-dev.yaml b/helm/values-dev.yaml index 63cdd24..163bb94 100644 --- a/helm/values-dev.yaml +++ b/helm/values-dev.yaml @@ -4,7 +4,7 @@ microservice-chart: fullnameOverride: "" image: repository: ghcr.io/pagopa/pagopa-gpd-upload - tag: "0.1.23-2-PAGOPA-1595-elk" + tag: "0.1.23-3-PAGOPA-1595-elk" pullPolicy: Always livenessProbe: httpGet: diff --git a/helm/values-prod.yaml b/helm/values-prod.yaml index a3fa63c..a351599 100644 --- a/helm/values-prod.yaml +++ b/helm/values-prod.yaml @@ -4,7 +4,7 @@ microservice-chart: fullnameOverride: "" image: repository: ghcr.io/pagopa/pagopa-gpd-upload - tag: "0.1.23-2-PAGOPA-1595-elk" + tag: "0.1.23-3-PAGOPA-1595-elk" pullPolicy: Always livenessProbe: httpGet: diff --git a/helm/values-uat.yaml b/helm/values-uat.yaml index e236272..01d025c 100644 --- a/helm/values-uat.yaml +++ b/helm/values-uat.yaml @@ -4,7 +4,7 @@ microservice-chart: fullnameOverride: "" image: repository: ghcr.io/pagopa/pagopa-gpd-upload - tag: "0.1.23-2-PAGOPA-1595-elk" + tag: "0.1.23-3-PAGOPA-1595-elk" pullPolicy: Always livenessProbe: httpGet: diff --git a/openapi/openapi.json b/openapi/openapi.json index ad72df2..6ea2c32 100644 --- a/openapi/openapi.json +++ b/openapi/openapi.json @@ -4,7 +4,7 @@ "description": "Microservice to manage PagoPA GPD Upload", "termsOfService": "https://www.pagopa.gov.it/", "title": "pagoPA GPD Upload", - "version": "0.1.23-2-PAGOPA-1595-elk" + "version": "0.1.23-3-PAGOPA-1595-elk" }, "servers": [ { diff --git a/pom.xml b/pom.xml index 013bf8c..6cff207 100644 --- a/pom.xml +++ b/pom.xml @@ -4,7 +4,7 @@ 4.0.0 it.gov.pagopa.gpd.upload pagopa-gpd-upload - 0.1.23-2-PAGOPA-1595-elk + 0.1.23-3-PAGOPA-1595-elk ${packaging} From d245ba6a7677070a27a4f0d35c96a4862e4882d2 Mon Sep 17 00:00:00 2001 From: AngeloCaporaso Date: Fri, 10 May 2024 14:21:04 +0200 Subject: [PATCH 09/16] [PAGOPA-1595] ci: Config logback for elastic logging --- .env.sample | 10 ++++++++++ .gitignore | 3 ++- README.md | 12 ++++++++++++ pom.xml | 6 ++++++ src/main/resources/logback.xml | 16 +++++++++------- 5 files changed, 39 insertions(+), 8 deletions(-) create mode 100644 .env.sample diff --git a/.env.sample b/.env.sample new file mode 100644 index 0000000..989b41b --- /dev/null +++ b/.env.sample @@ -0,0 +1,10 @@ +export BLOB_SAS_URL="" +export BLOB_SAS_TOKEN="" +export BLOB_CONNECTION_STRING="" +COSMOS_URI="" +COSMOS_KEY="" +DB_NAME="" +CONTAINER_NAME="gpd-upload-status-container-name" +POST_FILE_RETRY_AFTER="10000" +LOG_LEVEL=INFO +OTEL_SERVICE_NAME=pagopa-gpd-upload diff --git a/.gitignore b/.gitignore index 4379a6c..2f4f58c 100644 --- a/.gitignore +++ b/.gitignore @@ -32,7 +32,8 @@ hs_err_pid* # Project files /target/ **/node_modules -**/.env +**/**.env +**.env .cache_ggshield # Helm diff --git a/README.md b/README.md index a3708f7..1bb87c6 100644 --- a/README.md +++ b/README.md @@ -55,6 +55,18 @@ docker run -p 8080:8080 --env-file ### Run the project +``` +cp .env.sample .env +``` + +After setting all required environment variables + +``` +set -o allexport +source .env +set +o allexport +``` + Start the micronaut application with this command: `mvn mn:run` diff --git a/pom.xml b/pom.xml index 6cff207..8445ab2 100644 --- a/pom.xml +++ b/pom.xml @@ -23,6 +23,7 @@ 2.17.0 4.1.0 false + 1.6.0 it.gov.pagopa.gpd.upload.aot.generated netty it.gov.pagopa.gpd.upload.Application @@ -126,6 +127,11 @@ 5.0.0 + + co.elastic.logging + logback-ecs-encoder + ${logback.ecs.version} + diff --git a/src/main/resources/logback.xml b/src/main/resources/logback.xml index 2d77bda..59f0bc0 100644 --- a/src/main/resources/logback.xml +++ b/src/main/resources/logback.xml @@ -1,14 +1,16 @@ + - - - %cyan(%d{HH:mm:ss.SSS}) %gray([%thread]) %highlight(%-5level) %magenta(%logger{36}) - %msg%n + + ${OTEL_SERVICE_NAME} - - + + + + - + + \ No newline at end of file From 441f35a96fd9d7f4c7d98cde713faace05daf379 Mon Sep 17 00:00:00 2001 From: pagopa-github-bot Date: Fri, 10 May 2024 12:22:21 +0000 Subject: [PATCH 10/16] Bump to version 0.1.23-4-PAGOPA-1595-elk [skip ci] --- helm/Chart.yaml | 4 ++-- helm/values-dev.yaml | 2 +- helm/values-prod.yaml | 2 +- helm/values-uat.yaml | 2 +- openapi/openapi.json | 2 +- pom.xml | 2 +- 6 files changed, 7 insertions(+), 7 deletions(-) diff --git a/helm/Chart.yaml b/helm/Chart.yaml index 832cc9f..b5db26e 100644 --- a/helm/Chart.yaml +++ b/helm/Chart.yaml @@ -2,8 +2,8 @@ apiVersion: v2 name: pagopa-gpd-upload description: Microservice that handles file upload of massive debt positions JSON object type: application -version: 0.71.0 -appVersion: 0.1.23-3-PAGOPA-1595-elk +version: 0.72.0 +appVersion: 0.1.23-4-PAGOPA-1595-elk dependencies: - name: microservice-chart version: 2.8.0 diff --git a/helm/values-dev.yaml b/helm/values-dev.yaml index 163bb94..9be568b 100644 --- a/helm/values-dev.yaml +++ b/helm/values-dev.yaml @@ -4,7 +4,7 @@ microservice-chart: fullnameOverride: "" image: repository: ghcr.io/pagopa/pagopa-gpd-upload - tag: "0.1.23-3-PAGOPA-1595-elk" + tag: "0.1.23-4-PAGOPA-1595-elk" pullPolicy: Always livenessProbe: httpGet: diff --git a/helm/values-prod.yaml b/helm/values-prod.yaml index a351599..42c8862 100644 --- a/helm/values-prod.yaml +++ b/helm/values-prod.yaml @@ -4,7 +4,7 @@ microservice-chart: fullnameOverride: "" image: repository: ghcr.io/pagopa/pagopa-gpd-upload - tag: "0.1.23-3-PAGOPA-1595-elk" + tag: "0.1.23-4-PAGOPA-1595-elk" pullPolicy: Always livenessProbe: httpGet: diff --git a/helm/values-uat.yaml b/helm/values-uat.yaml index 01d025c..e874c33 100644 --- a/helm/values-uat.yaml +++ b/helm/values-uat.yaml @@ -4,7 +4,7 @@ microservice-chart: fullnameOverride: "" image: repository: ghcr.io/pagopa/pagopa-gpd-upload - tag: "0.1.23-3-PAGOPA-1595-elk" + tag: "0.1.23-4-PAGOPA-1595-elk" pullPolicy: Always livenessProbe: httpGet: diff --git a/openapi/openapi.json b/openapi/openapi.json index 6ea2c32..41ab8ad 100644 --- a/openapi/openapi.json +++ b/openapi/openapi.json @@ -4,7 +4,7 @@ "description": "Microservice to manage PagoPA GPD Upload", "termsOfService": "https://www.pagopa.gov.it/", "title": "pagoPA GPD Upload", - "version": "0.1.23-3-PAGOPA-1595-elk" + "version": "0.1.23-4-PAGOPA-1595-elk" }, "servers": [ { diff --git a/pom.xml b/pom.xml index 8445ab2..181d465 100644 --- a/pom.xml +++ b/pom.xml @@ -4,7 +4,7 @@ 4.0.0 it.gov.pagopa.gpd.upload pagopa-gpd-upload - 0.1.23-3-PAGOPA-1595-elk + 0.1.23-4-PAGOPA-1595-elk ${packaging} From 7f8eb08d46efb898de333395bbca9ebad02af265 Mon Sep 17 00:00:00 2001 From: AngeloCaporaso Date: Fri, 10 May 2024 15:04:46 +0200 Subject: [PATCH 11/16] [PAGOPA-1595] ci: append to log version and env --- src/main/resources/logback.xml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/main/resources/logback.xml b/src/main/resources/logback.xml index 59f0bc0..df8d9f8 100644 --- a/src/main/resources/logback.xml +++ b/src/main/resources/logback.xml @@ -4,6 +4,8 @@ ${OTEL_SERVICE_NAME} + ${project.version} + ${ENV} From b1f382a2ae98fcf846084cec7b03e1170d93fe35 Mon Sep 17 00:00:00 2001 From: AngeloCaporaso Date: Fri, 10 May 2024 18:47:23 +0200 Subject: [PATCH 12/16] [PAGOPA-1595] ci: Add log aspect for ELK dashboard --- pom.xml | 6 ++ .../gpd/upload/config/ExampleAnnotation.java | 13 ++++ .../gpd/upload/config/ExampleInterceptor.java | 22 ++++++ .../pagopa/gpd/upload/config/LogAspect.java | 76 +++++++++++++++++++ 4 files changed, 117 insertions(+) create mode 100644 src/main/java/it/gov/pagopa/gpd/upload/config/ExampleAnnotation.java create mode 100644 src/main/java/it/gov/pagopa/gpd/upload/config/ExampleInterceptor.java create mode 100644 src/main/java/it/gov/pagopa/gpd/upload/config/LogAspect.java diff --git a/pom.xml b/pom.xml index 181d465..4cef82c 100644 --- a/pom.xml +++ b/pom.xml @@ -24,6 +24,7 @@ 4.1.0 false 1.6.0 + 3.1.8 it.gov.pagopa.gpd.upload.aot.generated netty it.gov.pagopa.gpd.upload.Application @@ -37,6 +38,11 @@ + + io.reactivex.rxjava3 + rxjava + ${reactivex.rxjava.version} + org.mockito mockito-junit-jupiter diff --git a/src/main/java/it/gov/pagopa/gpd/upload/config/ExampleAnnotation.java b/src/main/java/it/gov/pagopa/gpd/upload/config/ExampleAnnotation.java new file mode 100644 index 0000000..f14abc9 --- /dev/null +++ b/src/main/java/it/gov/pagopa/gpd/upload/config/ExampleAnnotation.java @@ -0,0 +1,13 @@ +package it.gov.pagopa.gpd.upload.config; + +import io.micronaut.aop.Around; +import java.lang.annotation.*; +import static java.lang.annotation.ElementType.*; +import static java.lang.annotation.RetentionPolicy.RUNTIME; + +@Documented +@Retention(RUNTIME) +@Target({TYPE, METHOD}) +@Around +public @interface ExampleAnnotation { +} \ No newline at end of file diff --git a/src/main/java/it/gov/pagopa/gpd/upload/config/ExampleInterceptor.java b/src/main/java/it/gov/pagopa/gpd/upload/config/ExampleInterceptor.java new file mode 100644 index 0000000..c04cb46 --- /dev/null +++ b/src/main/java/it/gov/pagopa/gpd/upload/config/ExampleInterceptor.java @@ -0,0 +1,22 @@ +package it.gov.pagopa.gpd.upload.config; + +import io.micronaut.aop.InterceptorBean; +import io.micronaut.aop.MethodInterceptor; +import io.micronaut.aop.MethodInvocationContext; +import io.micronaut.core.annotation.Nullable; + +import jakarta.inject.Singleton; + + +@Singleton +@InterceptorBean(ExampleAnnotation.class) +public class ExampleInterceptor implements MethodInterceptor { + + @Nullable + @Override + public Object intercept(MethodInvocationContext context) { + // + // @ExampleAnnotation to use it around method + return context.proceed(); + } +} \ No newline at end of file diff --git a/src/main/java/it/gov/pagopa/gpd/upload/config/LogAspect.java b/src/main/java/it/gov/pagopa/gpd/upload/config/LogAspect.java new file mode 100644 index 0000000..483dcea --- /dev/null +++ b/src/main/java/it/gov/pagopa/gpd/upload/config/LogAspect.java @@ -0,0 +1,76 @@ +package it.gov.pagopa.gpd.upload.config; + +import com.fasterxml.jackson.core.JsonProcessingException; +import com.fasterxml.jackson.databind.ObjectMapper; +import com.fasterxml.jackson.datatype.jsr310.JavaTimeModule; +import io.micronaut.http.HttpRequest; +import io.micronaut.http.MutableHttpResponse; +import io.micronaut.http.annotation.Filter; +import io.micronaut.http.filter.HttpServerFilter; +import io.micronaut.http.filter.ServerFilterChain; +import io.reactivex.rxjava3.core.Flowable; +import lombok.extern.slf4j.Slf4j; +import org.reactivestreams.Publisher; +import org.slf4j.MDC; + +import java.util.UUID; + + +@Filter("/*") +@Slf4j +public class LogAspect implements HttpServerFilter { + public static final String START_TIME = "startTime"; + public static final String METHOD = "method"; + public static final String STATUS = "status"; + public static final String CODE = "httpCode"; + public static final String RESPONSE_TIME = "responseTime"; + public static final String RESPONSE = "response"; + public static final String FAULT_CODE = "faultCode"; + public static final String FAULT_DETAIL = "faultDetail"; + public static final String REQUEST_ID = "requestId"; + public static final String OPERATION_ID = "operationId"; + public static final String ARGS = "args"; + + @Override + public Publisher> doFilter(HttpRequest request, ServerFilterChain chain) { + long startTime = System.currentTimeMillis(); + MDC.put(METHOD, request.getMethodName()); + MDC.put(START_TIME, String.valueOf(System.currentTimeMillis())); + MDC.put(OPERATION_ID, UUID.randomUUID().toString()); + if(MDC.get(REQUEST_ID) == null) { + var requestId = UUID.randomUUID().toString(); + MDC.put(REQUEST_ID, requestId); + } + String params = request.getParameters().asMap().toString(); + MDC.put(ARGS, params); + + log.info("Invoking API operation {} - args: {}", request.getMethodName(), params); + + return Flowable.fromPublisher(chain.proceed(request)).flatMap(response -> { + + MDC.put(STATUS, "OK"); + MDC.put(CODE, String.valueOf(response.getStatus().getCode())); + MDC.put(RESPONSE_TIME, String.valueOf(System.currentTimeMillis() - startTime)); + MDC.put(RESPONSE, toJsonString(response.getBody().toString())); + log.info("Successful API operation {} - result: {}", request.getMethodName(), response); + MDC.remove(RESPONSE); + MDC.remove(STATUS); + MDC.remove(CODE); + MDC.remove(RESPONSE_TIME); + MDC.remove(START_TIME); + + return Flowable.just(response); + }); + } + + private static String toJsonString(Object param) { + try { + return new ObjectMapper() + .registerModule(new JavaTimeModule()) + .writeValueAsString(param); + } catch (JsonProcessingException e) { + log.warn("An error occurred when trying to parse a parameter", e); + return "parsing error"; + } + } +} \ No newline at end of file From 34af52e9a3e87ef0299976f27c4b1b2b486755d0 Mon Sep 17 00:00:00 2001 From: pagopa-github-bot Date: Fri, 10 May 2024 16:49:19 +0000 Subject: [PATCH 13/16] Bump to version 0.1.23-5-PAGOPA-1595-elk [skip ci] --- helm/Chart.yaml | 4 ++-- helm/values-dev.yaml | 2 +- helm/values-prod.yaml | 2 +- helm/values-uat.yaml | 2 +- openapi/openapi.json | 2 +- pom.xml | 2 +- 6 files changed, 7 insertions(+), 7 deletions(-) diff --git a/helm/Chart.yaml b/helm/Chart.yaml index b5db26e..596ad62 100644 --- a/helm/Chart.yaml +++ b/helm/Chart.yaml @@ -2,8 +2,8 @@ apiVersion: v2 name: pagopa-gpd-upload description: Microservice that handles file upload of massive debt positions JSON object type: application -version: 0.72.0 -appVersion: 0.1.23-4-PAGOPA-1595-elk +version: 0.73.0 +appVersion: 0.1.23-5-PAGOPA-1595-elk dependencies: - name: microservice-chart version: 2.8.0 diff --git a/helm/values-dev.yaml b/helm/values-dev.yaml index 9be568b..c10c47a 100644 --- a/helm/values-dev.yaml +++ b/helm/values-dev.yaml @@ -4,7 +4,7 @@ microservice-chart: fullnameOverride: "" image: repository: ghcr.io/pagopa/pagopa-gpd-upload - tag: "0.1.23-4-PAGOPA-1595-elk" + tag: "0.1.23-5-PAGOPA-1595-elk" pullPolicy: Always livenessProbe: httpGet: diff --git a/helm/values-prod.yaml b/helm/values-prod.yaml index 42c8862..00699e2 100644 --- a/helm/values-prod.yaml +++ b/helm/values-prod.yaml @@ -4,7 +4,7 @@ microservice-chart: fullnameOverride: "" image: repository: ghcr.io/pagopa/pagopa-gpd-upload - tag: "0.1.23-4-PAGOPA-1595-elk" + tag: "0.1.23-5-PAGOPA-1595-elk" pullPolicy: Always livenessProbe: httpGet: diff --git a/helm/values-uat.yaml b/helm/values-uat.yaml index e874c33..9030caf 100644 --- a/helm/values-uat.yaml +++ b/helm/values-uat.yaml @@ -4,7 +4,7 @@ microservice-chart: fullnameOverride: "" image: repository: ghcr.io/pagopa/pagopa-gpd-upload - tag: "0.1.23-4-PAGOPA-1595-elk" + tag: "0.1.23-5-PAGOPA-1595-elk" pullPolicy: Always livenessProbe: httpGet: diff --git a/openapi/openapi.json b/openapi/openapi.json index 41ab8ad..c42bbb5 100644 --- a/openapi/openapi.json +++ b/openapi/openapi.json @@ -4,7 +4,7 @@ "description": "Microservice to manage PagoPA GPD Upload", "termsOfService": "https://www.pagopa.gov.it/", "title": "pagoPA GPD Upload", - "version": "0.1.23-4-PAGOPA-1595-elk" + "version": "0.1.23-5-PAGOPA-1595-elk" }, "servers": [ { diff --git a/pom.xml b/pom.xml index 4cef82c..f49e3a7 100644 --- a/pom.xml +++ b/pom.xml @@ -4,7 +4,7 @@ 4.0.0 it.gov.pagopa.gpd.upload pagopa-gpd-upload - 0.1.23-4-PAGOPA-1595-elk + 0.1.23-5-PAGOPA-1595-elk ${packaging} From 1d9479a9b96223286c6afe33df808ce0b5f1756e Mon Sep 17 00:00:00 2001 From: AngeloCaporaso Date: Fri, 10 May 2024 19:03:57 +0200 Subject: [PATCH 14/16] [PAGOPA-1595] ci: Adjust log --- src/main/java/it/gov/pagopa/gpd/upload/config/LogAspect.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/main/java/it/gov/pagopa/gpd/upload/config/LogAspect.java b/src/main/java/it/gov/pagopa/gpd/upload/config/LogAspect.java index 483dcea..bea1280 100644 --- a/src/main/java/it/gov/pagopa/gpd/upload/config/LogAspect.java +++ b/src/main/java/it/gov/pagopa/gpd/upload/config/LogAspect.java @@ -34,7 +34,8 @@ public class LogAspect implements HttpServerFilter { @Override public Publisher> doFilter(HttpRequest request, ServerFilterChain chain) { long startTime = System.currentTimeMillis(); - MDC.put(METHOD, request.getMethodName()); + String path = request.getPath(); + MDC.put(METHOD, request.getMethod() + " " + path.substring(path.lastIndexOf('/'))); MDC.put(START_TIME, String.valueOf(System.currentTimeMillis())); MDC.put(OPERATION_ID, UUID.randomUUID().toString()); if(MDC.get(REQUEST_ID) == null) { From 783d83372402deee682795e98902f6ac9e2d3197 Mon Sep 17 00:00:00 2001 From: pagopa-github-bot Date: Fri, 10 May 2024 17:24:18 +0000 Subject: [PATCH 15/16] Bump to version 0.1.23-6-PAGOPA-1595-elk [skip ci] --- helm/Chart.yaml | 4 ++-- helm/values-dev.yaml | 2 +- helm/values-prod.yaml | 2 +- helm/values-uat.yaml | 2 +- openapi/openapi.json | 2 +- pom.xml | 2 +- 6 files changed, 7 insertions(+), 7 deletions(-) diff --git a/helm/Chart.yaml b/helm/Chart.yaml index 596ad62..f12a155 100644 --- a/helm/Chart.yaml +++ b/helm/Chart.yaml @@ -2,8 +2,8 @@ apiVersion: v2 name: pagopa-gpd-upload description: Microservice that handles file upload of massive debt positions JSON object type: application -version: 0.73.0 -appVersion: 0.1.23-5-PAGOPA-1595-elk +version: 0.74.0 +appVersion: 0.1.23-6-PAGOPA-1595-elk dependencies: - name: microservice-chart version: 2.8.0 diff --git a/helm/values-dev.yaml b/helm/values-dev.yaml index c10c47a..23e6342 100644 --- a/helm/values-dev.yaml +++ b/helm/values-dev.yaml @@ -4,7 +4,7 @@ microservice-chart: fullnameOverride: "" image: repository: ghcr.io/pagopa/pagopa-gpd-upload - tag: "0.1.23-5-PAGOPA-1595-elk" + tag: "0.1.23-6-PAGOPA-1595-elk" pullPolicy: Always livenessProbe: httpGet: diff --git a/helm/values-prod.yaml b/helm/values-prod.yaml index 00699e2..9ec2b26 100644 --- a/helm/values-prod.yaml +++ b/helm/values-prod.yaml @@ -4,7 +4,7 @@ microservice-chart: fullnameOverride: "" image: repository: ghcr.io/pagopa/pagopa-gpd-upload - tag: "0.1.23-5-PAGOPA-1595-elk" + tag: "0.1.23-6-PAGOPA-1595-elk" pullPolicy: Always livenessProbe: httpGet: diff --git a/helm/values-uat.yaml b/helm/values-uat.yaml index 9030caf..8e287e4 100644 --- a/helm/values-uat.yaml +++ b/helm/values-uat.yaml @@ -4,7 +4,7 @@ microservice-chart: fullnameOverride: "" image: repository: ghcr.io/pagopa/pagopa-gpd-upload - tag: "0.1.23-5-PAGOPA-1595-elk" + tag: "0.1.23-6-PAGOPA-1595-elk" pullPolicy: Always livenessProbe: httpGet: diff --git a/openapi/openapi.json b/openapi/openapi.json index c42bbb5..f21b01d 100644 --- a/openapi/openapi.json +++ b/openapi/openapi.json @@ -4,7 +4,7 @@ "description": "Microservice to manage PagoPA GPD Upload", "termsOfService": "https://www.pagopa.gov.it/", "title": "pagoPA GPD Upload", - "version": "0.1.23-5-PAGOPA-1595-elk" + "version": "0.1.23-6-PAGOPA-1595-elk" }, "servers": [ { diff --git a/pom.xml b/pom.xml index f49e3a7..fdabf4b 100644 --- a/pom.xml +++ b/pom.xml @@ -4,7 +4,7 @@ 4.0.0 it.gov.pagopa.gpd.upload pagopa-gpd-upload - 0.1.23-5-PAGOPA-1595-elk + 0.1.23-6-PAGOPA-1595-elk ${packaging} From 25ba1417d562ef1ee30c3a9e6373b35d59ac8d53 Mon Sep 17 00:00:00 2001 From: AngeloCaporaso Date: Mon, 13 May 2024 09:07:04 +0200 Subject: [PATCH 16/16] [PAGOPA-1595] ci(helm): Add ELK config --- helm/values-prod.yaml | 15 ++++++--------- 1 file changed, 6 insertions(+), 9 deletions(-) diff --git a/helm/values-prod.yaml b/helm/values-prod.yaml index 9ec2b26..03f823f 100644 --- a/helm/values-prod.yaml +++ b/helm/values-prod.yaml @@ -78,17 +78,14 @@ microservice-chart: CONTAINER_NAME: "gpd_upload_status" POST_FILE_RETRY_AFTER: '2000' LOG_LEVEL: "INFO" - # CORS_CONFIGURATION: '{"origins": ["*"], "methods": ["*"]}' - # OTEL_SERVICE_NAME: # TODO - # OTEL_RESOURCE_ATTRIBUTES: "deployment.environment=prod" - # OTEL_EXPORTER_OTLP_ENDPOINT: "http://otel-collector.elastic-system.svc:4317" - # OTEL_TRACES_EXPORTER: otlp - # OTEL_METRICS_EXPORTER: otlp - # OTEL_LOGS_EXPORTER: none - # OTEL_TRACES_SAMPLER: "always_on" + OTEL_SERVICE_NAME: "pagopa-gpd-upload" + OTEL_RESOURCE_ATTRIBUTES: "deployment.environment=prod" + OTEL_EXPORTER_OTLP_ENDPOINT: "http://otel-collector.elastic-system.svc:4317" + OTEL_LOGS_EXPORTER: none + OTEL_TRACES_SAMPLER: "always_on" envSecret: # APPLICATIONINSIGHTS_CONNECTION_STRING: 'ai-p-connection-string' - # OTEL_EXPORTER_OTLP_HEADERS: elastic-apm-secret-token + OTEL_EXPORTER_OTLP_HEADERS: elastic-apm-secret-token BLOB_CONNECTION_STRING: 'gpd-upload-sa-connection-string' COSMOS_KEY: 'gpd-upload-db-key' keyvault: