Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[PAGOPA-2686] opex: Add error-codes #11

Open
wants to merge 16 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 15 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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-fdr-to-event-hub
description: Microservice fdr to event hub
type: application
version: 0.50.0
appVersion: 1.0.0
version: 0.57.0
appVersion: 1.0.0-7-PAGOPA-2686
dependencies:
- name: microservice-chart
version: 7.1.1
Expand Down
2 changes: 1 addition & 1 deletion helm/values-dev.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ microservice-chart:
fullnameOverride: "pagopa-fdr-2-event-hub"
image:
repository: ghcr.io/pagopa/pagopa-fdr-2-event-hub
tag: "1.0.0"
tag: "1.0.0-7-PAGOPA-2686"
pullPolicy: Always
# https://github.com/Azure/azure-functions-host/blob/dev/src/WebJobs.Script.WebHost/Controllers/HostController.cs
# livenessProbe:
Expand Down
2 changes: 1 addition & 1 deletion helm/values-prod.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ microservice-chart:
fullnameOverride: "pagopa-fdr-2-event-hub"
image:
repository: ghcr.io/pagopa/pagopa-fdr-2-event-hub
tag: "1.0.0"
tag: "1.0.0-7-PAGOPA-2686"
pullPolicy: Always
# https://github.com/Azure/azure-functions-host/blob/dev/src/WebJobs.Script.WebHost/Controllers/HostController.cs
# livenessProbe:
Expand Down
2 changes: 1 addition & 1 deletion helm/values-uat.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ microservice-chart:
fullnameOverride: "pagopa-fdr-2-event-hub"
image:
repository: ghcr.io/pagopa/pagopa-fdr-2-event-hub
tag: "1.0.0"
tag: "1.0.0-7-PAGOPA-2686"
pullPolicy: Always
# https://github.com/Azure/azure-functions-host/blob/dev/src/WebJobs.Script.WebHost/Controllers/HostController.cs
# livenessProbe:
Expand Down
6 changes: 3 additions & 3 deletions host.json
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,9 @@
"logLevel": {
"default": "None",
"Host.Results": "Error",
"Function.ProcessFDR1BlobFiles": "Information",
"Function.ProcessFDR3BlobFiles": "Information",
"Function.HTTPBlobRecovery": "Information",
"Function.ProcessFDR1BlobFiles": "Warning",
"Function.ProcessFDR3BlobFiles": "Warning",
"Function.HTTPBlobRecovery": "Warning",
"Host.Aggregator": "Error"
},
"applicationInsights": {
Expand Down
5 changes: 2 additions & 3 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

<groupId>it.gov.pagopa.fdr.to.eventhub</groupId>
<artifactId>pagopa-fdr-to-event-hub</artifactId>
<version>1.0.0</version>
<version>1.0.0-7-PAGOPA-2686</version>
<packaging>jar</packaging>

<name>FDR To Event Hub</name>
Expand All @@ -22,8 +22,7 @@
<azure.messaging.eventhubs.version>5.20.0
</azure.messaging.eventhubs.version>
<azure.storage.blob.version>12.29.0</azure.storage.blob.version>
<functionAppName>com.microsoft.azure-20220215182005862
</functionAppName>
<functionAppName>com.microsoft.azure-20220215182005862</functionAppName>
<jackson.version>2.18.2</jackson.version>
<modelmapper.version>3.2.2</modelmapper.version>
<lombok.version>1.18.36</lombok.version>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@
import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter;
import java.util.Map;

import it.gov.pagopa.fdr.to.eventhub.util.ErrorCodes;
Comment on lines +16 to +17

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[google-java-format] reported by reviewdog 🐶

Suggested change
import it.gov.pagopa.fdr.to.eventhub.util.ErrorCodes;

import lombok.Getter;

public class BlobProcessingFunction {
Expand Down Expand Up @@ -74,7 +76,7 @@ public synchronized void processFDR1BlobFiles(

context
.getLogger()
.info(
.fine(
() ->
String.format(
"[FDR1] Triggered at: %s for Blob container: %s, name: %s, size in bytes: %d",
Expand Down Expand Up @@ -117,7 +119,7 @@ public synchronized void processFDR1BlobFiles(

context
.getLogger()
.info(
.fine(
() ->
String.format(
"[FDR1] Execution Finished at: %s for Blob container: %s, name: %s, size in"
Expand All @@ -134,8 +136,8 @@ public synchronized void processFDR1BlobFiles(
.severe(
() ->
String.format(
"[FDR1] Error processing Blob '%s/%s': %s",
fdr1Container, blobName, e.getMessage()));
"[%s][FDR1] Error processing Blob '%s/%s': %s",
ErrorCodes.FDR1_E1, fdr1Container, blobName, e.getMessage()));

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[google-java-format] reported by reviewdog 🐶

Suggested change
ErrorCodes.FDR1_E1, fdr1Container, blobName, e.getMessage()));
ErrorCodes.FDR1_E1, fdr1Container, blobName, e.getMessage()));

}
}

Expand All @@ -153,15 +155,15 @@ public void processFDR3BlobFiles(

context
.getLogger()
.info(
.fine(
() ->
String.format(
"[FDR3] Triggered for Blob container: %s, name: %s, size: %d bytes",
fdr3Container, blobName, content.length));

context
.getLogger()
.info(
.fine(
() ->
String.format(
"[FDR3] Execution Finished at: %s for Blob container: %s, name: %s, size: %d"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ public HttpResponseMessage run(

context
.getLogger()
.info(
.fine(
() ->
String.format(
"[HTTP FDR] Triggered at: %s for Blob container: %s, name: %s",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -164,8 +164,8 @@ public static boolean processXmlBlobAndSendToEventHub(
// Log the exception with context
String errorMessage =
String.format(
"Error processing or sending data to event hub: %s. Details: %s",
flussoRendicontazione.getIdentificativoFlusso(), e.getMessage());
"[%s] Error processing or sending data to event hub: %s. Details: %s",
ErrorCodes.COMMON_E2, flussoRendicontazione.getIdentificativoFlusso(), e.getMessage());

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[google-java-format] reported by reviewdog 🐶

Suggested change
ErrorCodes.COMMON_E2, flussoRendicontazione.getIdentificativoFlusso(), e.getMessage());
ErrorCodes.COMMON_E2,
flussoRendicontazione.getIdentificativoFlusso(),
e.getMessage());

context.getLogger().severe(() -> errorMessage);

return false;
Expand Down Expand Up @@ -241,11 +241,11 @@ private boolean sendEventToHub(
} catch (Exception e) {
context
.getLogger()
.warning(
.severe(
() ->
String.format(
"Failed to add event to batch for flow ID: %s. Details: %s",
flusso.getIdentificativoFlusso(), e.getMessage()));
"[%s] Failed to add event to batch for flow ID: %s. Details: %s",
ErrorCodes.COMMON_E1, flusso.getIdentificativoFlusso(), e.getMessage()));
return false;
}
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
package it.gov.pagopa.fdr.to.eventhub.util;

import lombok.Getter;

@Getter
public enum ErrorCodes {
// Common Errors
COMMON_E1("FDR-E1", "Error while sending to EventHub."),
COMMON_E2("FDR-E2", "Error while process XML Blob."),
// FDR1 Errors
FDR1_E1("FDR1-E1", "Error processing Blob in processFDR1BlobFiles function");
Comment on lines +7 to +11

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[google-java-format] reported by reviewdog 🐶

Suggested change
// Common Errors
COMMON_E1("FDR-E1", "Error while sending to EventHub."),
COMMON_E2("FDR-E2", "Error while process XML Blob."),
// FDR1 Errors
FDR1_E1("FDR1-E1", "Error processing Blob in processFDR1BlobFiles function");
// Common Errors
COMMON_E1("FDR-E1", "Error while sending to EventHub."),
COMMON_E2("FDR-E2", "Error while process XML Blob."),
// FDR1 Errors
FDR1_E1("FDR1-E1", "Error processing Blob in processFDR1BlobFiles function");



Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[google-java-format] reported by reviewdog 🐶

Suggested change
private final String code;
private final String message;

private final String code;
private final String message;

ErrorCodes(String code, String message) {
this.code = code;
this.message = message;
}

Comment on lines +14 to +21

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[google-java-format] reported by reviewdog 🐶

Suggested change
private final String code;
private final String message;
ErrorCodes(String code, String message) {
this.code = code;
this.message = message;
}
ErrorCodes(String code, String message) {
this.code = code;
this.message = message;
}

}
Loading