From 73c6ba97aa1c81f66ee5ae5cb6c4f93fd11984ac Mon Sep 17 00:00:00 2001 From: maxsca <130107847+maxsca@users.noreply.github.com> Date: Thu, 4 Apr 2024 18:32:19 +0200 Subject: [PATCH] NOD-784 logging --- openapi/openapi.json | 301 ++++++++-------------- src/test/resources/application.properties | 110 +++++++- 2 files changed, 209 insertions(+), 202 deletions(-) diff --git a/openapi/openapi.json b/openapi/openapi.json index 003ddfaf..926beedb 100644 --- a/openapi/openapi.json +++ b/openapi/openapi.json @@ -1,232 +1,151 @@ { - "openapi": "3.0.1", - "info": { - "description": "A service that permits to handle nodoInviaRPT and nodoInviaCarrelloRPT request from WISP, interfacing", - "termsOfService": "https://www.pagopa.gov.it/", - "title": "wisp-converter", - "version": "0.0.4" + "openapi" : "3.0.1", + "info" : { + "description" : "A service that permits to handle nodoInviaRPT and nodoInviaCarrelloRPT request from WISP, interfacing", + "termsOfService" : "https://www.pagopa.gov.it/", + "title" : "wisp-converter", + "version" : "0.0.4" }, - "servers": [ - { - "url": "http://localhost", - "description": "Generated server url" - } - ], - "paths": { - "/info": { - "get": { - "operationId": "healthCheck", - "responses": { - "200": { - "content": { - "application/json": { - "schema": { - "$ref": "#/components/schemas/AppInfo" - } - } - }, - "description": "OK.", - "headers": { - "X-Request-Id": { - "description": "This header identifies the call", - "schema": { - "type": "string" - } - } - } - }, - "401": { - "description": "Wrong or missing function key.", - "headers": { - "X-Request-Id": { - "description": "This header identifies the call", - "schema": { - "type": "string" - } - } - } - }, - "403": { - "description": "Forbidden.", - "headers": { - "X-Request-Id": { - "description": "This header identifies the call", - "schema": { - "type": "string" - } - } - } - }, - "500": { - "content": { - "application/json": { - "schema": { - "$ref": "#/components/schemas/ProblemJson" + "servers" : [ { + "url" : "http://localhost", + "description" : "Generated server url" + } ], + "tags" : [ { + "description" : "Application info APIs", + "name" : "Home" + }, { + "description" : "Conversion and redirection APIs", + "name" : "Redirect" + } ], + "paths" : { + "/info" : { + "get" : { + "operationId" : "healthCheck", + "responses" : { + "200" : { + "content" : { + "application/json" : { + "schema" : { + "$ref" : "#/components/schemas/AppInfoResponse" } } }, - "description": "Service unavailable.", - "headers": { - "X-Request-Id": { - "description": "This header identifies the call", - "schema": { - "type": "string" + "description" : "OK.", + "headers" : { + "X-Request-Id" : { + "description" : "This header identifies the call", + "schema" : { + "type" : "string" } } } } }, - "security": [ - { - "ApiKey": [] - } - ], - "summary": "Return OK if application is started", - "tags": [ - "Home" - ] + "security" : [ { + "ApiKey" : [ ] + } ], + "summary" : "Return OK if application is started", + "tags" : [ "Home" ] }, - "parameters": [ - { - "description": "This header identifies the call, if not passed it is self-generated. This ID is returned in the response.", - "in": "header", - "name": "X-Request-Id", - "schema": { - "type": "string" - } + "parameters" : [ { + "description" : "This header identifies the call, if not passed it is self-generated. This ID is returned in the response.", + "in" : "header", + "name" : "X-Request-Id", + "schema" : { + "type" : "string" } - ] + } ] }, - "/redirect": { - "get": { - "operationId": "redirect", - "parameters": [ - { - "example": "identificativoIntermediarioPA_sessionId", - "in": "query", - "name": "sessionId", - "required": true, - "schema": { - "type": "string" - } + "/redirect" : { + "get" : { + "operationId" : "redirect_1", + "parameters" : [ { + "example" : "identificativoIntermediarioPA_sessionId", + "in" : "query", + "name" : "sessionId", + "required" : true, + "schema" : { + "type" : "string" } - ], - "responses": { - "302": { - "description": "Redirect to Checkout service.", - "headers": { - "X-Request-Id": { - "description": "This header identifies the call", - "schema": { - "type": "string" - } - } - } - }, - "401": { - "description": "Wrong or missing function key.", - "headers": { - "X-Request-Id": { - "description": "This header identifies the call", - "schema": { - "type": "string" + } ], + "responses" : { + "200" : { + "content" : { + "*/*" : { + "schema" : { + "$ref" : "#/components/schemas/RedirectResponse" } } - } - }, - "403": { - "description": "Forbidden.", - "headers": { - "X-Request-Id": { - "description": "This header identifies the call", - "schema": { - "type": "string" + }, + "description" : "Redirect info to Checkout service.", + "headers" : { + "X-Request-Id" : { + "description" : "This header identifies the call", + "schema" : { + "type" : "string" } } } }, - "500": { - "content": { - "text/html": {} - }, - "description": "Internal server error.", - "headers": { - "X-Request-Id": { - "description": "This header identifies the call", - "schema": { - "type": "string" + "302" : { + "description" : "Redirect to Checkout service.", + "headers" : { + "X-Request-Id" : { + "description" : "This header identifies the call", + "schema" : { + "type" : "string" } } } } }, - "security": [ - { - "ApiKey": [] - } - ], - "tags": [ - "Home" - ] + "security" : [ { + "ApiKey" : [ ] + } ], + "tags" : [ "Redirect" ] }, - "parameters": [ - { - "description": "This header identifies the call, if not passed it is self-generated. This ID is returned in the response.", - "in": "header", - "name": "X-Request-Id", - "schema": { - "type": "string" - } + "parameters" : [ { + "description" : "This header identifies the call, if not passed it is self-generated. This ID is returned in the response.", + "in" : "header", + "name" : "X-Request-Id", + "schema" : { + "type" : "string" } - ] + } ] } }, - "components": { - "schemas": { - "AppInfo": { - "type": "object", - "properties": { - "environment": { - "type": "string" + "components" : { + "schemas" : { + "AppInfoResponse" : { + "type" : "object", + "properties" : { + "environment" : { + "type" : "string" }, - "name": { - "type": "string" + "name" : { + "type" : "string" }, - "version": { - "type": "string" + "version" : { + "type" : "string" } } }, - "ProblemJson": { - "type": "object", - "properties": { - "detail": { - "type": "string", - "description": "A human readable explanation specific to this occurrence of the problem.", - "example": "There was an error processing the request" - }, - "status": { - "maximum": 600, - "minimum": 100, - "type": "integer", - "description": "The HTTP status code generated by the origin server for this occurrence of the problem.", - "format": "int32", - "example": 200 - }, - "title": { - "type": "string", - "description": "A short, summary of the problem type. Written in english and readable for engineers (usually not suited for non technical stakeholders and not localized); example: Service Unavailable" + "RedirectResponse" : { + "type" : "object", + "properties" : { + "redirect-url" : { + "type" : "string" } } } }, - "securitySchemes": { - "ApiKey": { - "description": "The API key to access this function app.", - "in": "header", - "name": "Ocp-Apim-Subscription-Key", - "type": "apiKey" + "securitySchemes" : { + "ApiKey" : { + "description" : "The API key to access this function app.", + "in" : "header", + "name" : "Ocp-Apim-Subscription-Key", + "type" : "apiKey" } } } -} +} \ No newline at end of file diff --git a/src/test/resources/application.properties b/src/test/resources/application.properties index b0c4b6f2..8f4c6be8 100644 --- a/src/test/resources/application.properties +++ b/src/test/resources/application.properties @@ -3,7 +3,8 @@ info.application.name=@project.name@ info.application.artifactId=@project.artifactId@ info.application.version=@project.version@ info.application.description=@project.description@ -info.properties.environment=test +info.properties.environment=${ENV:azure} + # Actuator management.endpoints.web.exposure.include=health,info @@ -13,23 +14,27 @@ management.endpoint.health.probes.enabled=true management.health.livenessState.enabled=true management.health.readinessState.enabled=true + # Openapi springdoc.writer-with-order-by-keys=true springdoc.writer-with-default-pretty-printer=true + # Server server.servlet.context-path=/ server.port=8080 + # Logging logging.level.root=${DEFAULT_LOGGING_LEVEL:INFO} -logging.level.it.gov.pagopa=${APP_LOGGING_LEVEL:DEBUG} - +logging.level.it.gov.pagopa=${APP_LOGGING_LEVEL:INFO} otel.service.name=${OTEL_SERVICE_NAME:pagopa-wisp-converter} + # CORS configuration cors.configuration=${CORS_CONFIGURATION:{"origins": ["*"], "methods": ["*"]}} + # Databases configuration azure.cosmos.uri=${COSMOS_URI:https://pagopa-d-weu-nodo-wispconv-cosmos-account.documents.azure.com:443/} azure.cosmos.key=${COSMOS_KEY} @@ -39,18 +44,101 @@ spring.redis.host=${REDIS_HOST:pagopa-d-redis.redis.cache.windows.net} spring.redis.port=${REDIS_PORT:6380} spring.redis.password=${REDIS_PASSWORD} -# Common client configuration -client.retry.max-attempts=${CLIENT_RETRY_MAXATTEMPT:1} -client.retry.max-delay=${CLIENT_RETRY_MAXDELAY:2000} # GPD client configuration -client.gpd.subscription-key=${CLIENT_GPD_SUBKEY:none} +client.gpd.read-timeout=${CLIENT_GPD_READ_TIMEOUT:5000} +client.gpd.connect-timeout=${CLIENT_GPD_READ_TIMEOUT:5000} +client.gpd.base-path=${CLIENT_GPD_HOST:none} +client.gpd.api-key=${CLIENT_GPD_SUBKEY:none} + # IUV generator client configuration -client.iuv-generator.host=${CLIENT_IUVGENERATOR_HOST:none} -client.iuv-generator.api.generate.path=/organizations/{organization-fiscal-code}/iuv -client.iuv-generator.subscription-key=${CLIENT_IUVGENERATOR_SUBKEY:none} +client.iuvgenerator.read-timeout=${CLIENT_IUVGENERATOR_READ_TIMEOUT:5000} +client.iuvgenerator.connect-timeout=${CLIENT_IUVGENERATOR_READ_TIMEOUT:5000} +client.iuvgenerator.base-path=${CLIENT_IUVGENERATOR_HOST:https://api.dev.platform.pagopa.it/shared/iuv-generator-service/v1} +client.iuvgenerator.api-key=${CLIENT_IUVGENERATOR_SUBKEY:none} + + +# Checkout generator client configuration +client.checkout.read-timeout=${CLIENT_CHECKOUT_READ_TIMEOUT:5000} +client.checkout.connect-timeout=${CLIENT_CHECKOUT_READ_TIMEOUT:5000} +client.checkout.base-path=${CLIENT_CHECKOUT_HOST:none} +client.checkout.api-key=${CLIENT_CHECKOUT_SUBKEY:none} + + +## Decoupler's APIM policy configuration +client.decoupler-caching.read-timeout=${CLIENT_DECOUPLERCACHING_READ_TIMEOUT:5000} +client.decoupler-caching.connect-timeout=${CLIENT_DECOUPLERCACHING_READ_TIMEOUT:5000} +client.decoupler-caching.base-path=${CLIENT_DECOUPLERCACHING_HOST:none} +client.decoupler-caching.api-key=${CLIENT_DECOUPLERCACHING_SUBKEY:none} + # Application domain configuration wisp-converter.aux-digit=3 -wisp-converter.segregation-code=48 \ No newline at end of file +wisp-converter.segregation-code=48 +wisp-converter.cached-requestid-mapping.ttl.minutes=${CACHED_REQUESTID_MAPPING_TTL_MINUTES:1440} + +# Error +error.code.uri=${ERROR_CODE_URI:https://pagopa.gov/error-code} + + +## Exclude url from filter +filter.exclude-url-patterns=/swagger-ui/**,/v3/api-docs/** + +## Server Logging filter +log.server.request.include-headers=true +log.server.request.include-client-info=true +log.server.request.include-payload=true +log.server.request.max-payload-length=10000 +log.server.request.pretty=true + +log.server.response.include-headers=true +log.server.response.include-payload=true +log.server.response.max-payload-length=10000 +log.server.response.pretty=true + +## Client logging Checkout +log.client.checkout.request.include-headers=true +log.client.checkout.request.include-payload=true +log.client.checkout.request.max-payload-length=10000 +log.client.checkout.response.include-headers=true +log.client.checkout.response.include-payload=true +log.client.checkout.response.max-payload-length=10000 +log.client.checkout.mask.header.name=${CLIENT_CHECKOUT_API_KEY_NAME:Ocp-Apim-Subscription-Key} +log.client.checkout.request.pretty=true +log.client.checkout.response.pretty=true + +## Client logging Decoupler Caching +log.client.decoupler-caching.request.include-headers=true +log.client.decoupler-caching.request.include-payload=true +log.client.decoupler-caching.request.max-payload-length=10000 +log.client.decoupler-caching.response.include-headers=true +log.client.decoupler-caching.response.include-payload=true +log.client.decoupler-caching.response.max-payload-length=10000 +log.client.decoupler-caching.mask.header.name=${CLIENT_DECOUPLERCACHING_API_KEY_NAME:Ocp-Apim-Subscription-Key} +log.client.decoupler-caching.request.pretty=true +log.client.decoupler-caching.response.pretty=true + +## Client logging Iuv Generator +log.client.iuvgenerator.request.include-headers=true +log.client.iuvgenerator.request.include-payload=true +log.client.iuvgenerator.request.max-payload-length=10000 +log.client.iuvgenerator.response.include-headers=true +log.client.iuvgenerator.response.include-payload=true +log.client.iuvgenerator.response.max-payload-length=10000 +log.client.iuvgenerator.mask.header.name=${CLIENT_IUVGENERATOR_API_KEY_NAME:Ocp-Apim-Subscription-Key} +log.client.iuvgenerator.request.pretty=true +log.client.iuvgenerator.response.pretty=true + +## Client logging Gpd +log.client.gpd.request.include-headers=true +log.client.gpd.request.include-payload=true +log.client.gpd.request.max-payload-length=10000 +log.client.gpd.response.include-headers=true +log.client.gpd.response.include-payload=true +log.client.gpd.response.max-payload-length=10000 +log.client.gpd.mask.header.name=${CLIENT_GPD_API_KEY_NAME:Ocp-Apim-Subscription-Key} +log.client.gpd.request.pretty=true +log.client.gpd.response.pretty=true + +