summaryrefslogtreecommitdiffstats
path: root/reference
diff options
context:
space:
mode:
Diffstat (limited to 'reference')
-rw-r--r--reference/logging-filter/logging-filter-base/src/main/java/org/onap/logging/filter/base/MDCSetup.java38
1 files changed, 24 insertions, 14 deletions
diff --git a/reference/logging-filter/logging-filter-base/src/main/java/org/onap/logging/filter/base/MDCSetup.java b/reference/logging-filter/logging-filter-base/src/main/java/org/onap/logging/filter/base/MDCSetup.java
index 75fde49..c3391e9 100644
--- a/reference/logging-filter/logging-filter-base/src/main/java/org/onap/logging/filter/base/MDCSetup.java
+++ b/reference/logging-filter/logging-filter-base/src/main/java/org/onap/logging/filter/base/MDCSetup.java
@@ -166,23 +166,33 @@ public class MDCSetup {
}
public void setElapsedTime() {
- DateTimeFormatter timeFormatter = DateTimeFormatter.ISO_ZONED_DATE_TIME;
- ZonedDateTime entryTimestamp =
- ZonedDateTime.parse(MDC.get(ONAPLogConstants.MDCs.ENTRY_TIMESTAMP), timeFormatter);
- ZonedDateTime endTimestamp = ZonedDateTime.parse(MDC.get(ONAPLogConstants.MDCs.LOG_TIMESTAMP), timeFormatter);
-
- MDC.put(ONAPLogConstants.MDCs.ELAPSED_TIME,
- Long.toString(ChronoUnit.MILLIS.between(entryTimestamp, endTimestamp)));
+ try {
+ DateTimeFormatter timeFormatter = DateTimeFormatter.ISO_ZONED_DATE_TIME;
+ ZonedDateTime entryTimestamp =
+ ZonedDateTime.parse(MDC.get(ONAPLogConstants.MDCs.ENTRY_TIMESTAMP), timeFormatter);
+ ZonedDateTime endTimestamp =
+ ZonedDateTime.parse(MDC.get(ONAPLogConstants.MDCs.LOG_TIMESTAMP), timeFormatter);
+
+ MDC.put(ONAPLogConstants.MDCs.ELAPSED_TIME,
+ Long.toString(ChronoUnit.MILLIS.between(entryTimestamp, endTimestamp)));
+ } catch (Exception e) {
+ logger.warn("Unable to calculate elapsed time due to error: {}", e.getMessage());
+ }
}
public void setElapsedTimeInvokeTimestamp() {
- DateTimeFormatter timeFormatter = DateTimeFormatter.ISO_ZONED_DATE_TIME;
- ZonedDateTime entryTimestamp =
- ZonedDateTime.parse(MDC.get(ONAPLogConstants.MDCs.INVOKE_TIMESTAMP), timeFormatter);
- ZonedDateTime endTimestamp = ZonedDateTime.parse(MDC.get(ONAPLogConstants.MDCs.LOG_TIMESTAMP), timeFormatter);
-
- MDC.put(ONAPLogConstants.MDCs.ELAPSED_TIME,
- Long.toString(ChronoUnit.MILLIS.between(entryTimestamp, endTimestamp)));
+ try {
+ DateTimeFormatter timeFormatter = DateTimeFormatter.ISO_ZONED_DATE_TIME;
+ ZonedDateTime entryTimestamp =
+ ZonedDateTime.parse(MDC.get(ONAPLogConstants.MDCs.INVOKE_TIMESTAMP), timeFormatter);
+ ZonedDateTime endTimestamp =
+ ZonedDateTime.parse(MDC.get(ONAPLogConstants.MDCs.LOG_TIMESTAMP), timeFormatter);
+
+ MDC.put(ONAPLogConstants.MDCs.ELAPSED_TIME,
+ Long.toString(ChronoUnit.MILLIS.between(entryTimestamp, endTimestamp)));
+ } catch (Exception e) {
+ logger.warn("Unable to calculate elapsed time due to error: {}", e.getMessage());
+ }
}
public void setResponseStatusCode(int code) {