Skip to content

Commit

Permalink
otel
Browse files Browse the repository at this point in the history
  • Loading branch information
jacopocarlini committed Oct 10, 2024
2 parents 600d329 + d7f6e91 commit 74845e7
Show file tree
Hide file tree
Showing 10 changed files with 29 additions and 56 deletions.
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -22,4 +22,4 @@ COPY --chown=spring:spring --from=builder snapshot-dependencies/ ./
# 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/ ./
COPY --chown=spring:spring --from=builder application/ ./
19 changes: 0 additions & 19 deletions docker/applicationinsights.json

This file was deleted.

4 changes: 2 additions & 2 deletions helm/Chart.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ apiVersion: v2
name: pagopa-gpd-payments
description: Microservice that exposes API for payment receipts retrieving and other operations
type: application
version: 0.113.0
appVersion: 0.12.29
version: 0.117.0
appVersion: 0.12.30
dependencies:
- name: microservice-chart
version: 2.4.0
Expand Down
9 changes: 2 additions & 7 deletions helm/values-dev.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ microservice-chart:
fullnameOverride: ""
image:
repository: ghcr.io/pagopa/pagopa-gpd-payments
tag: "0.12.29"
tag: "0.12.30"
pullPolicy: Always
livenessProbe:
httpGet:
Expand Down Expand Up @@ -84,11 +84,7 @@ microservice-chart:
QUEUE_RECEIVE_INVISIBILITY_TIME: "300"
CRON_JOB_SCHEDULE_RETRY_ENABLED: "true"
CRON_JOB_SCHEDULE_RETRY_TRIGGER: "0 0 0,6,12,18 * * *"
OTEL_SERVICE_NAME: "pagopa-gpd-payments"
OTEL_RESOURCE_ATTRIBUTES: "deployment.environment=dev"
OTEL_EXPORTER_OTLP_ENDPOINT: "http://otel-collector.elastic-system.svc:4317"
OTEL_LOGS_EXPORTER: none
OTEL_TRACES_SAMPLER: "always_on"
SERVICE_NAME: "pagopa-gpd-payments"
envSecret:
# required
APPLICATIONINSIGHTS_CONNECTION_STRING: 'ai-d-connection-string'
Expand All @@ -97,7 +93,6 @@ microservice-chart:
GPS_SUBSCRIPTION_KEY: "gpd-d-gps-subscription-key"
AZURE_TABLES_CONNECTION_STRING: "gpd-payments-d-cosmos-connection-string"
QUEUE_CONNECTION_STRING: "gpd-payments-d-queue-connection-string"
OTEL_EXPORTER_OTLP_HEADERS: elastic-apm-secret-token
keyvault:
name: "pagopa-d-gps-kv"
tenantId: "7788edaf-0346-4068-9d79-c868aed15b3d"
Expand Down
11 changes: 3 additions & 8 deletions helm/values-prod.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ microservice-chart:
fullnameOverride: ""
image:
repository: ghcr.io/pagopa/pagopa-gpd-payments
tag: "0.12.29"
tag: "0.12.30"
pullPolicy: Always
livenessProbe:
httpGet:
Expand Down Expand Up @@ -45,7 +45,7 @@ microservice-chart:
resources:
requests:
memory: "512Mi"
cpu: "0.25"
cpu: "0.3"
limits:
memory: "768Mi"
cpu: "0.5"
Expand Down Expand Up @@ -84,11 +84,7 @@ microservice-chart:
QUEUE_RECEIVE_INVISIBILITY_TIME: "300"
CRON_JOB_SCHEDULE_RETRY_ENABLED: "true"
CRON_JOB_SCHEDULE_RETRY_TRIGGER: "0 0 0,6,12,18 * * *"
OTEL_SERVICE_NAME: "pagopa-gpd-payments"
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"
SERVICE_NAME: "pagopa-gpd-payments"
envSecret:
# required
APPLICATIONINSIGHTS_CONNECTION_STRING: 'ai-p-connection-string'
Expand All @@ -97,7 +93,6 @@ microservice-chart:
GPS_SUBSCRIPTION_KEY: "gpd-p-gps-subscription-key"
AZURE_TABLES_CONNECTION_STRING: "gpd-payments-p-cosmos-connection-string"
QUEUE_CONNECTION_STRING: "gpd-payments-p-queue-connection-string"
OTEL_EXPORTER_OTLP_HEADERS: elastic-apm-secret-token
keyvault:
name: "pagopa-p-gps-kv"
tenantId: "7788edaf-0346-4068-9d79-c868aed15b3d"
Expand Down
9 changes: 2 additions & 7 deletions helm/values-uat.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ microservice-chart:
fullnameOverride: ""
image:
repository: ghcr.io/pagopa/pagopa-gpd-payments
tag: "0.12.29"
tag: "0.12.30"
pullPolicy: Always
livenessProbe:
httpGet:
Expand Down Expand Up @@ -84,11 +84,7 @@ microservice-chart:
QUEUE_RECEIVE_INVISIBILITY_TIME: "300"
CRON_JOB_SCHEDULE_RETRY_ENABLED: "true"
CRON_JOB_SCHEDULE_RETRY_TRIGGER: "0 0 0,6,12,18 * * *"
OTEL_SERVICE_NAME: "pagopa-gpd-payments"
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"
SERVICE_NAME: "pagopa-gpd-payments"
envSecret:
# required
APPLICATIONINSIGHTS_CONNECTION_STRING: 'ai-u-connection-string'
Expand All @@ -97,7 +93,6 @@ microservice-chart:
GPS_SUBSCRIPTION_KEY: "gpd-u-gps-subscription-key"
AZURE_TABLES_CONNECTION_STRING: "gpd-payments-u-cosmos-connection-string"
QUEUE_CONNECTION_STRING: "gpd-payments-u-queue-connection-string"
OTEL_EXPORTER_OTLP_HEADERS: elastic-apm-secret-token
keyvault:
name: "pagopa-u-gps-kv"
tenantId: "7788edaf-0346-4068-9d79-c868aed15b3d"
Expand Down
2 changes: 1 addition & 1 deletion openapi/openapi.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"title": "PagoPA API Payments",
"description": "Payments",
"termsOfService": "https://www.pagopa.gov.it/",
"version": "0.12.29"
"version": "0.12.30"
},
"servers": [
{
Expand Down
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@

<groupId>it.gov.pagopa</groupId>
<artifactId>payments</artifactId>
<version>0.12.29</version>
<version>0.12.30</version>
<name>Payments</name>
<description>Payments</description>

Expand Down
25 changes: 16 additions & 9 deletions src/main/java/it/gov/pagopa/payments/config/LoggingAspect.java
Original file line number Diff line number Diff line change
Expand Up @@ -91,13 +91,7 @@ private static Map<String, String> getParams(ProceedingJoinPoint joinPoint) {
for (var parameter : method.getParameters()) {
var paramName = parameter.getName();
var arg = joinPoint.getArgs()[i++];
if (arg instanceof JAXBElement<?>) {
try {
arg = new ObjectMapper().writer().writeValueAsString(arg);
} catch (JsonProcessingException e) {
arg = "unreadable!";
}
}
arg = jaxToString(arg);
params.put(paramName, deNull(arg));
}
return params;
Expand Down Expand Up @@ -141,15 +135,17 @@ public Object logApiInvocation(ProceedingJoinPoint joinPoint) throws Throwable {
Map<String, String> params = getParams(joinPoint);
MDC.put(ARGS, params.toString());

log.info("Invoking API operation {} - args: {}", joinPoint.getSignature().getName(), params);
log.debug("Invoking API operation {} - args: {}", joinPoint.getSignature().getName(), params);

Object result = joinPoint.proceed();

MDC.put(STATUS, "OK");
MDC.put(CODE, String.valueOf(httpResponse.getStatus()));
MDC.put(RESPONSE_TIME, getExecutionTime());
log.info(
"Successful API operation {} - result: {}", joinPoint.getSignature().getName(), result);
"Successful API operation {} - result: {}",
joinPoint.getSignature().getName(),
jaxToString(result));
MDC.remove(STATUS);
MDC.remove(CODE);
MDC.remove(RESPONSE_TIME);
Expand All @@ -176,4 +172,15 @@ public Object logTrace(ProceedingJoinPoint joinPoint) throws Throwable {
log.debug("Return method {} - result: {}", joinPoint.getSignature().toShortString(), result);
return result;
}

private static Object jaxToString(Object arg) {
if (arg instanceof JAXBElement<?>) {
try {
arg = new ObjectMapper().writer().writeValueAsString(arg);
} catch (JsonProcessingException e) {
arg = "unreadable!";
}
}
return arg;
}
}
2 changes: 1 addition & 1 deletion src/main/resources/logback-spring.xml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
<springProperty name="ECS_SERVICE_VERSION" source="info.application.version"/>
<appender name="ECS_JSON_CONSOLE" class="ch.qos.logback.core.ConsoleAppender">
<encoder class="co.elastic.logging.logback.EcsEncoder">
<serviceName>${OTEL_SERVICE_NAME}</serviceName>
<serviceName>${SERVICE_NAME}</serviceName>
<serviceVersion>${ECS_SERVICE_VERSION}</serviceVersion>
<serviceEnvironment>${ENV}</serviceEnvironment>
</encoder>
Expand Down

0 comments on commit 74845e7

Please sign in to comment.