summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDan Timoney <dtimoney@att.com>2019-10-23 16:36:50 +0000
committerGerrit Code Review <gerrit@onap.org>2019-10-23 16:36:50 +0000
commit88b50b19b726cc13ced419902eff162791ac456d (patch)
tree554b44e5350046462f5f5432e19e0ae9c216ee6a
parent574363f5a29ac9237a377c4c0923b414a38fddec (diff)
parentb4974d740eb9960f4054ab3bc89037e16dfe7bf5 (diff)
Merge "Update metric logger"
-rwxr-xr-xsli/common/src/main/java/org/onap/ccsdk/sli/core/sli/MetricLogger.java4
-rwxr-xr-xsli/common/src/test/java/org/onap/ccsdk/sli/core/sli/TestMetricLogger.java5
2 files changed, 8 insertions, 1 deletions
diff --git a/sli/common/src/main/java/org/onap/ccsdk/sli/core/sli/MetricLogger.java b/sli/common/src/main/java/org/onap/ccsdk/sli/core/sli/MetricLogger.java
index c2670ec38..518316d56 100755
--- a/sli/common/src/main/java/org/onap/ccsdk/sli/core/sli/MetricLogger.java
+++ b/sli/common/src/main/java/org/onap/ccsdk/sli/core/sli/MetricLogger.java
@@ -92,6 +92,8 @@ public class MetricLogger {
MDC.put(ONAPLogConstants.MDCs.TARGET_ELEMENT, targetElement);
}
this.lastMsg = msg;
+ //During invoke status will always be INPROGRESS
+ MDC.put(ONAPLogConstants.MDCs.RESPONSE_STATUS_CODE, ONAPLogConstants.ResponseStatus.INPROGRESS.toString());
METRIC.info(INVOKE, "Invoke");
}
@@ -119,6 +121,8 @@ public class MetricLogger {
if (str != null) {
str = str.replaceAll("\\R", ""); // this will strip all new line characters
str = str.replaceAll("\\|", "%7C"); // log records should not contain a pipe, encode the pipe character
+ str = str.replaceAll("\t", " "); // tabs are not allowed, replace with spaces
+ str = str.replace(",", "\\,"); // comma must be escaped
}
return str;
}
diff --git a/sli/common/src/test/java/org/onap/ccsdk/sli/core/sli/TestMetricLogger.java b/sli/common/src/test/java/org/onap/ccsdk/sli/core/sli/TestMetricLogger.java
index ec3a31ea5..4b371cf8f 100755
--- a/sli/common/src/test/java/org/onap/ccsdk/sli/core/sli/TestMetricLogger.java
+++ b/sli/common/src/test/java/org/onap/ccsdk/sli/core/sli/TestMetricLogger.java
@@ -42,6 +42,9 @@ public class TestMetricLogger {
assertEquals("%7C",output);
output = logger.formatString(null);
assertEquals(null,output);
+ output = logger.formatString("\t");
+ assertEquals(" ", output);
+ output = logger.formatString("one,two,three,");
+ assertEquals("one\\,two\\,three\\,", output);
}
-
}