Skip to content

Commit

Permalink
feat: [PAGOPA-2202] log optimization (#6)
Browse files Browse the repository at this point in the history
* [PAGOPA-2202] log opt: updated maven plugin version


---------

Co-authored-by: pagopa-github-bot <github-bot@pagopa.it>
Co-authored-by: pasqualespica <36746022+pasqualespica@users.noreply.github.com>
  • Loading branch information
3 people authored Oct 4, 2024
1 parent f895bd3 commit 05bb8f3
Show file tree
Hide file tree
Showing 6 changed files with 38 additions and 12 deletions.
10 changes: 7 additions & 3 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -6,22 +6,26 @@ WORKDIR /build
COPY . .
RUN mvn clean package -Dmaven.test.skip=true


#
# Package stage
#
FROM amazoncorretto:17.0.9-alpine3.18@sha256:df48bf2e183230040890460ddb4359a10aa6c7aad24bd88899482c52053c7e17 as builder
COPY --from=buildtime /build/target/*.jar application.jar
RUN java -Djarmode=layertools -jar application.jar extract


FROM ghcr.io/pagopa/docker-base-springboot-openjdk17:v1.1.0@sha256:6fa320d452fa22066441f1ef292d15eb06f944bc8bca293e1a91ea460d30a613
ADD --chown=spring:spring https://github.com/open-telemetry/opentelemetry-java-instrumentation/releases/download/v1.25.1/opentelemetry-javaagent.jar .
#ADD --chown=spring:spring https://github.com/open-telemetry/opentelemetry-java-instrumentation/releases/download/v1.25.1/opentelemetry-javaagent.jar .

COPY --chown=spring:spring --from=builder dependencies/ ./
COPY --chown=spring:spring --from=builder snapshot-dependencies/ ./
COPY --chown=spring:spring docker/applicationinsights.json ./applicationinsights.json

# https://github.com/moby/moby/issues/37965#issuecomment-426853382
RUN true
COPY --chown=spring:spring --from=builder spring-boot-loader/ ./
COPY --chown=spring:spring --from=builder application/ ./

EXPOSE 8080

ENTRYPOINT ["java","-javaagent:opentelemetry-javaagent.jar","--enable-preview","org.springframework.boot.loader.JarLauncher"]
#ENTRYPOINT ["java","-javaagent:opentelemetry-javaagent.jar","--enable-preview","org.springframework.boot.loader.JarLauncher"]
19 changes: 19 additions & 0 deletions docker/applicationinsights.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
{
"selfDiagnostics": {
"destination": "console",
"level": "INFO"
},
"sampling": {
"requestsPerSecond": 5
},
"preview": {
"sampling": {
"overrides": [
{
"telemetryKind": "exception",
"percentage": 100
}
]
}
}
}
13 changes: 8 additions & 5 deletions docker/run_docker.sh
Original file line number Diff line number Diff line change
Expand Up @@ -26,25 +26,28 @@ if test -f "$FILE"; then
rm .env
fi
config=$(yq -r '."microservice-chart".envConfig' ../helm/values-$ENV.yaml)
# set word splitting
IFS=$'\n'
for line in $(echo "$config" | jq -r '. | to_entries[] | select(.key) | "\(.key)=\(.value)"'); do
for line in $(echo "$config" | yq -r '. | to_entries[] | select(.key) | "\(.key)=\(.value)"'); do
echo "$line" >> .env
done

keyvault=$(yq -r '."microservice-chart".keyvault.name' ../helm/values-$ENV.yaml)
secret=$(yq -r '."microservice-chart".envSecret' ../helm/values-$ENV.yaml)
for line in $(echo "$secret" | jq -r '. | to_entries[] | select(.key) | "\(.key)=\(.value)"'); do
for line in $(echo "$secret" | yq -r '. | to_entries[] | select(.key) | "\(.key)=\(.value)"'); do
IFS='=' read -r -a array <<< "$line"
response=$(az keyvault secret show --vault-name $keyvault --name "${array[1]}")
value=$(echo "$response" | jq -r '.value')
response=$(echo "$response" | tr -d '\n')
value=$(echo "$response" | yq -r '.value')
value=$(echo "$value" | sed 's/\$/\$\$/g')
value=$(echo "$value" | tr -d '\n')
echo "${array[0]}=$value" >> .env
done


stack_name=$(cd .. && basename "$PWD")
docker compose -p "${stack_name}" up -d --remove-orphans --force-recreate --build


# waiting the containers
printf 'Waiting for the service'
attempt_counter=0
Expand All @@ -59,4 +62,4 @@ until $(curl --output /dev/null --silent --head --fail http://localhost:8080/act
attempt_counter=$((attempt_counter+1))
sleep 5
done
echo 'Service Started'
echo 'Service Started'
2 changes: 1 addition & 1 deletion helm/values-prod.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ microservice-chart:
APPLICATIONINSIGHTS_ROLE_NAME: "pagopa-nodo-verifyko-aux"
ENV: 'aks-dev'
APP_LOGGING_LEVEL: 'INFO'
DEFAULT_LOGGING_LEVEL: 'INFO'
DEFAULT_LOGGING_LEVEL: 'WARN'
CORS_CONFIGURATION: '{"origins": ["*"], "methods": ["*"]}'
CACHE_ENABLED: 'true'
VERIFYKO_COLDSTORAGE_TABLE: 'events'
Expand Down
4 changes: 2 additions & 2 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@
<dependency>
<groupId>co.elastic.logging</groupId>
<artifactId>logback-ecs-encoder</artifactId>
<version>1.5.0</version>
<version>1.6.0</version>
</dependency>
</dependencies>

Expand Down Expand Up @@ -156,7 +156,7 @@
<plugin>
<groupId>org.sonarsource.scanner.maven</groupId>
<artifactId>sonar-maven-plugin</artifactId>
<version>3.3.0.603</version>
<version>3.7.0.1746</version>
<executions>
<execution>
<phase>verify</phase>
Expand Down
2 changes: 1 addition & 1 deletion src/main/resources/application.properties
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ springdoc.writer-with-default-pretty-printer=true
server.servlet.context-path=/
server.port=8080
# Logging
logging.level.root=${DEFAULT_LOGGING_LEVEL:INFO}
logging.level.root=${DEFAULT_LOGGING_LEVEL:WARN}
logging.level.it.gov.pagopa=${APP_LOGGING_LEVEL:INFO}
# CORS configuration
cors.configuration=${CORS_CONFIGURATION:'{"origins": ["*"], "methods": ["*"]}'}
Expand Down

0 comments on commit 05bb8f3

Please sign in to comment.