summaryrefslogtreecommitdiffstats
path: root/openecomp-be/lib/openecomp-sdc-logging-lib/openecomp-sdc-logging-api/src/main/java
diff options
context:
space:
mode:
authorBen David, Elad (eb7504) <eb7504@intl.att.com>2019-11-03 17:22:48 +0200
committerBen David, Elad (eb7504) <eb7504@intl.att.com>2019-11-05 15:52:05 +0200
commit1e61754c29fc99636de692a0fb9d2ef1a4ba9e61 (patch)
tree90c20331d442c82dc955b0426d60b64a6ca353be /openecomp-be/lib/openecomp-sdc-logging-lib/openecomp-sdc-logging-api/src/main/java
parent4a6e592af14fd3941df6e56e5b75c9ac5d5eb01b (diff)
Align logging to Onap-ELS 2019.11
Change-Id: I1750493d5c9f2eab8c1395f0fbc9ae66cf74b0a6 Issue-ID: SDC-2639 Signed-off-by: Ben David, Elad (eb7504) <eb7504@intl.att.com>
Diffstat (limited to 'openecomp-be/lib/openecomp-sdc-logging-lib/openecomp-sdc-logging-api/src/main/java')
-rw-r--r--openecomp-be/lib/openecomp-sdc-logging-lib/openecomp-sdc-logging-api/src/main/java/org/openecomp/sdc/logging/api/AuditData.java64
-rw-r--r--openecomp-be/lib/openecomp-sdc-logging-lib/openecomp-sdc-logging-api/src/main/java/org/openecomp/sdc/logging/api/Logger.java4
-rw-r--r--openecomp-be/lib/openecomp-sdc-logging-lib/openecomp-sdc-logging-api/src/main/java/org/openecomp/sdc/logging/api/LoggerFactory.java7
-rw-r--r--openecomp-be/lib/openecomp-sdc-logging-lib/openecomp-sdc-logging-api/src/main/java/org/openecomp/sdc/logging/api/MetricsData.java82
-rw-r--r--openecomp-be/lib/openecomp-sdc-logging-lib/openecomp-sdc-logging-api/src/main/java/org/openecomp/sdc/logging/api/StatusCode.java27
-rw-r--r--openecomp-be/lib/openecomp-sdc-logging-lib/openecomp-sdc-logging-api/src/main/java/org/openecomp/sdc/logging/servlet/AuditTracker.java8
-rw-r--r--openecomp-be/lib/openecomp-sdc-logging-lib/openecomp-sdc-logging-api/src/main/java/org/openecomp/sdc/logging/servlet/ContextTracker.java3
-rw-r--r--openecomp-be/lib/openecomp-sdc-logging-lib/openecomp-sdc-logging-api/src/main/java/org/openecomp/sdc/logging/servlet/RequestProcessingResult.java4
-rw-r--r--openecomp-be/lib/openecomp-sdc-logging-lib/openecomp-sdc-logging-api/src/main/java/org/openecomp/sdc/logging/servlet/jaxrs/LoggingResponseFilter.java8
9 files changed, 38 insertions, 169 deletions
diff --git a/openecomp-be/lib/openecomp-sdc-logging-lib/openecomp-sdc-logging-api/src/main/java/org/openecomp/sdc/logging/api/AuditData.java b/openecomp-be/lib/openecomp-sdc-logging-lib/openecomp-sdc-logging-api/src/main/java/org/openecomp/sdc/logging/api/AuditData.java
index b7c4e0d78f..090f680aa7 100644
--- a/openecomp-be/lib/openecomp-sdc-logging-lib/openecomp-sdc-logging-api/src/main/java/org/openecomp/sdc/logging/api/AuditData.java
+++ b/openecomp-be/lib/openecomp-sdc-logging-lib/openecomp-sdc-logging-api/src/main/java/org/openecomp/sdc/logging/api/AuditData.java
@@ -16,6 +16,9 @@
package org.openecomp.sdc.logging.api;
+import org.onap.logging.ref.slf4j.ONAPLogConstants.ResponseStatus;
+import lombok.Getter;
+
/**
* Builder to populate <i>audit</i> data. This includes only data known to an application, and not otherwise available
* to the logging framework. As opposed, for example, to local runtime, host address, etc.
@@ -23,13 +26,14 @@ package org.openecomp.sdc.logging.api;
* @author KATYR, evitaliy
* @since February 15, 2018
*/
+@Getter
public class AuditData {
// don't inherit from MetricsData because it has a very different meaning
private final long startTime;
private final long endTime;
- private final StatusCode statusCode;
+ private final ResponseStatus statusCode;
private final String responseCode;
private final String responseDescription;
private final String clientIpAddress;
@@ -43,60 +47,6 @@ public class AuditData {
this.clientIpAddress = builder.clientIpAddress;
}
- /**
- * Begin timestamp of an API invocation.
- *
- * @return timestamp
- */
- public long getStartTime() {
- return startTime;
- }
-
- /**
- * End timestamp of an API invocation.
- *
- * @return timestamp
- */
- public long getEndTime() {
- return endTime;
- }
-
- /**
- * Result status of an API invocation.
- *
- * @return protocol and application agnostic status code
- */
- public StatusCode getStatusCode() {
- return statusCode;
- }
-
- /**
- * Application/protocol specific response status of an API invocation.
- *
- * @return response code
- */
- public String getResponseCode() {
- return responseCode;
- }
-
- /**
- * Application/protocol specific response in a human-friendly way.
- *
- * @return human-friendly response description
- */
- public String getResponseDescription() {
- return responseDescription;
- }
-
- /**
- * IP address of the invoking client when available.
- *
- * @return IP address
- */
- public String getClientIpAddress() {
- return clientIpAddress;
- }
-
@Override
public String toString() {
return "AuditData{startTime=" + startTime + ", endTime=" + endTime + ", statusCode=" + statusCode
@@ -115,7 +65,7 @@ public class AuditData {
private long startTime;
private long endTime;
- private StatusCode statusCode;
+ private ResponseStatus statusCode;
private String responseCode;
private String responseDescription;
private String clientIpAddress;
@@ -151,7 +101,7 @@ public class AuditData {
* @param statusCode invocation status success/failure
* @return this builder for fluent API
*/
- public AuditDataBuilder statusCode(final StatusCode statusCode) {
+ public AuditDataBuilder statusCode(final ResponseStatus statusCode) {
this.statusCode = statusCode;
return this;
}
diff --git a/openecomp-be/lib/openecomp-sdc-logging-lib/openecomp-sdc-logging-api/src/main/java/org/openecomp/sdc/logging/api/Logger.java b/openecomp-be/lib/openecomp-sdc-logging-lib/openecomp-sdc-logging-api/src/main/java/org/openecomp/sdc/logging/api/Logger.java
index ed028e34d5..6fbd25a134 100644
--- a/openecomp-be/lib/openecomp-sdc-logging-lib/openecomp-sdc-logging-api/src/main/java/org/openecomp/sdc/logging/api/Logger.java
+++ b/openecomp-be/lib/openecomp-sdc-logging-lib/openecomp-sdc-logging-api/src/main/java/org/openecomp/sdc/logging/api/Logger.java
@@ -43,7 +43,9 @@ public interface Logger {
boolean isAuditEnabled();
- void audit(AuditData data);
+ void auditEntry(AuditData data);
+
+ void auditExit(AuditData data);
boolean isDebugEnabled();
diff --git a/openecomp-be/lib/openecomp-sdc-logging-lib/openecomp-sdc-logging-api/src/main/java/org/openecomp/sdc/logging/api/LoggerFactory.java b/openecomp-be/lib/openecomp-sdc-logging-lib/openecomp-sdc-logging-api/src/main/java/org/openecomp/sdc/logging/api/LoggerFactory.java
index 96debb56b0..6ef57761d8 100644
--- a/openecomp-be/lib/openecomp-sdc-logging-lib/openecomp-sdc-logging-api/src/main/java/org/openecomp/sdc/logging/api/LoggerFactory.java
+++ b/openecomp-be/lib/openecomp-sdc-logging-lib/openecomp-sdc-logging-api/src/main/java/org/openecomp/sdc/logging/api/LoggerFactory.java
@@ -83,7 +83,12 @@ public class LoggerFactory {
}
@Override
- public void audit(AuditData data) {
+ public void auditEntry(AuditData data) {
+ // no-op
+ }
+
+ @Override
+ public void auditExit(AuditData data) {
// no-op
}
diff --git a/openecomp-be/lib/openecomp-sdc-logging-lib/openecomp-sdc-logging-api/src/main/java/org/openecomp/sdc/logging/api/MetricsData.java b/openecomp-be/lib/openecomp-sdc-logging-lib/openecomp-sdc-logging-api/src/main/java/org/openecomp/sdc/logging/api/MetricsData.java
index c44ab42efa..2fef96d2bb 100644
--- a/openecomp-be/lib/openecomp-sdc-logging-lib/openecomp-sdc-logging-api/src/main/java/org/openecomp/sdc/logging/api/MetricsData.java
+++ b/openecomp-be/lib/openecomp-sdc-logging-lib/openecomp-sdc-logging-api/src/main/java/org/openecomp/sdc/logging/api/MetricsData.java
@@ -16,6 +16,9 @@
package org.openecomp.sdc.logging.api;
+import org.onap.logging.ref.slf4j.ONAPLogConstants.ResponseStatus;
+import lombok.Getter;
+
/**
* Builder to populate <i>metrics</i> data. This includes only data known to an application, and not otherwise available
* to the logging framework.
@@ -23,13 +26,14 @@ package org.openecomp.sdc.logging.api;
* @author evitaliy
* @since 26 Mar 2018
*/
+@Getter
public class MetricsData {
// don't inherit from AuditData because it has a very different meaning
private final long startTime;
private final long endTime;
- private final StatusCode statusCode;
+ private final ResponseStatus statusCode;
private final String responseCode;
private final String responseDescription;
private final String clientIpAddress;
@@ -47,78 +51,6 @@ public class MetricsData {
this.targetVirtualEntity = builder.targetVirtualEntity;
}
- /**
- * Begin timestamp of an API invocation.
- *
- * @return timestamp
- */
- public long getStartTime() {
- return startTime;
- }
-
- /**
- * End timestamp of an API invocation.
- *
- * @return timestamp
- */
- public long getEndTime() {
- return endTime;
- }
-
- /**
- * Result status of an API invocation.
- *
- * @return protocol and application agnostic status code
- */
- public StatusCode getStatusCode() {
- return statusCode;
- }
-
- /**
- * Application/protocol specific response status of an API invocation.
- *
- * @return response code
- */
- public String getResponseCode() {
- return responseCode;
- }
-
- /**
- * Application/protocol specific response in a human-friendly way.
- *
- * @return human-friendly response description
- */
- public String getResponseDescription() {
- return responseDescription;
- }
-
- /**
- * IP address of the invoking client when available.
- *
- * @return IP address
- */
- public String getClientIpAddress() {
- return clientIpAddress;
- }
-
- /**
- * External entity invoked by the local system.
- *
- * @return identifier of an external entity (system, component, sub-component)
- */
- public String getTargetEntity() {
- return targetEntity;
- }
-
- /**
- * External API invoked by the local system.
- *
- * @return name of an external API
- */
- public String getTargetVirtualEntity() {
- return targetVirtualEntity;
- }
-
@Override
public String toString() {
return "AuditData{startTime=" + startTime + ", endTime=" + endTime + ", statusCode=" + statusCode
@@ -137,7 +69,7 @@ public class MetricsData {
private long startTime;
private long endTime;
- private StatusCode statusCode;
+ private ResponseStatus statusCode;
private String responseCode;
private String responseDescription;
private String clientIpAddress;
@@ -175,7 +107,7 @@ public class MetricsData {
* @param statusCode invocation status success/failure
* @return this builder for fluent API
*/
- public MetricsDataBuilder statusCode(final StatusCode statusCode) {
+ public MetricsDataBuilder statusCode(final ResponseStatus statusCode) {
this.statusCode = statusCode;
return this;
}
diff --git a/openecomp-be/lib/openecomp-sdc-logging-lib/openecomp-sdc-logging-api/src/main/java/org/openecomp/sdc/logging/api/StatusCode.java b/openecomp-be/lib/openecomp-sdc-logging-lib/openecomp-sdc-logging-api/src/main/java/org/openecomp/sdc/logging/api/StatusCode.java
deleted file mode 100644
index dd8bd57dcc..0000000000
--- a/openecomp-be/lib/openecomp-sdc-logging-lib/openecomp-sdc-logging-api/src/main/java/org/openecomp/sdc/logging/api/StatusCode.java
+++ /dev/null
@@ -1,27 +0,0 @@
-/*
- * Copyright © 2016-2018 European Support Limited
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.openecomp.sdc.logging.api;
-
-/**
- * Protocol-agnostic status codes to indicate the result status (success, failure) of an API invocation.
- *
- * @author EVITALIY
- * @since 04 Mar 18
- */
-public enum StatusCode {
- COMPLETE, ERROR
-}
diff --git a/openecomp-be/lib/openecomp-sdc-logging-lib/openecomp-sdc-logging-api/src/main/java/org/openecomp/sdc/logging/servlet/AuditTracker.java b/openecomp-be/lib/openecomp-sdc-logging-lib/openecomp-sdc-logging-api/src/main/java/org/openecomp/sdc/logging/servlet/AuditTracker.java
index af9b5061fd..2aeacf1ad5 100644
--- a/openecomp-be/lib/openecomp-sdc-logging-lib/openecomp-sdc-logging-api/src/main/java/org/openecomp/sdc/logging/servlet/AuditTracker.java
+++ b/openecomp-be/lib/openecomp-sdc-logging-lib/openecomp-sdc-logging-api/src/main/java/org/openecomp/sdc/logging/servlet/AuditTracker.java
@@ -22,6 +22,8 @@ import org.openecomp.sdc.logging.api.AuditData;
import org.openecomp.sdc.logging.api.Logger;
import org.openecomp.sdc.logging.api.LoggerFactory;
+import static org.onap.logging.ref.slf4j.ONAPLogConstants.ResponseStatus.COMPLETE;
+
/**
* Tracks and logs audit information when a request is being processed. An instance of this class cannot be reused, and
* the pre- and post-request methods must be called only once.
@@ -62,6 +64,10 @@ public class AuditTracker implements Tracker {
this.started = System.currentTimeMillis();
this.clientIpAddress = request.getRemoteAddr();
+ AuditData auditData = AuditData.builder().startTime(started).endTime(started).statusCode(COMPLETE)
+ .clientIpAddress(clientIpAddress)
+ .build();
+ logger.auditEntry(auditData);
}
@Override
@@ -80,6 +86,6 @@ public class AuditTracker implements Tracker {
.responseCode(Integer.toString(result.getStatus()))
.responseDescription(result.getStatusPhrase()).clientIpAddress(clientIpAddress)
.build();
- logger.audit(auditData);
+ logger.auditExit(auditData);
}
}
diff --git a/openecomp-be/lib/openecomp-sdc-logging-lib/openecomp-sdc-logging-api/src/main/java/org/openecomp/sdc/logging/servlet/ContextTracker.java b/openecomp-be/lib/openecomp-sdc-logging-lib/openecomp-sdc-logging-api/src/main/java/org/openecomp/sdc/logging/servlet/ContextTracker.java
index 2334f373bc..2aa5a83818 100644
--- a/openecomp-be/lib/openecomp-sdc-logging-lib/openecomp-sdc-logging-api/src/main/java/org/openecomp/sdc/logging/servlet/ContextTracker.java
+++ b/openecomp-be/lib/openecomp-sdc-logging-lib/openecomp-sdc-logging-api/src/main/java/org/openecomp/sdc/logging/servlet/ContextTracker.java
@@ -54,8 +54,9 @@ public class ContextTracker implements Tracker {
String requestId = requestIdHeaders.getAny(request::getHeader).orElse(UUID.randomUUID().toString());
ContextData.ContextDataBuilder contextBuilder =
ContextData.builder().serviceName(serviceName).requestId(requestId);
+ String partnerName = partnerNameHeaders.getAny(request::getHeader).orElse("UNKNOWN");
+ contextBuilder.partnerName(partnerName);
- partnerNameHeaders.getAny(request::getHeader).ifPresent(contextBuilder::partnerName);
LoggingContext.put(contextBuilder.build());
}
diff --git a/openecomp-be/lib/openecomp-sdc-logging-lib/openecomp-sdc-logging-api/src/main/java/org/openecomp/sdc/logging/servlet/RequestProcessingResult.java b/openecomp-be/lib/openecomp-sdc-logging-lib/openecomp-sdc-logging-api/src/main/java/org/openecomp/sdc/logging/servlet/RequestProcessingResult.java
index d3625ed303..ff77ef8a93 100644
--- a/openecomp-be/lib/openecomp-sdc-logging-lib/openecomp-sdc-logging-api/src/main/java/org/openecomp/sdc/logging/servlet/RequestProcessingResult.java
+++ b/openecomp-be/lib/openecomp-sdc-logging-lib/openecomp-sdc-logging-api/src/main/java/org/openecomp/sdc/logging/servlet/RequestProcessingResult.java
@@ -16,7 +16,7 @@
package org.openecomp.sdc.logging.servlet;
-import org.openecomp.sdc.logging.api.StatusCode;
+import org.onap.logging.ref.slf4j.ONAPLogConstants.ResponseStatus;
/**
* Interpretation of request processing results.
@@ -38,7 +38,7 @@ public interface RequestProcessingResult {
*
* @return on of pre-defined status codes
*/
- StatusCode getStatusCode();
+ ResponseStatus getStatusCode();
/**
* Human-friendly description of the numeric status.
diff --git a/openecomp-be/lib/openecomp-sdc-logging-lib/openecomp-sdc-logging-api/src/main/java/org/openecomp/sdc/logging/servlet/jaxrs/LoggingResponseFilter.java b/openecomp-be/lib/openecomp-sdc-logging-lib/openecomp-sdc-logging-api/src/main/java/org/openecomp/sdc/logging/servlet/jaxrs/LoggingResponseFilter.java
index fa9e815db8..b0ae88ccaa 100644
--- a/openecomp-be/lib/openecomp-sdc-logging-lib/openecomp-sdc-logging-api/src/main/java/org/openecomp/sdc/logging/servlet/jaxrs/LoggingResponseFilter.java
+++ b/openecomp-be/lib/openecomp-sdc-logging-lib/openecomp-sdc-logging-api/src/main/java/org/openecomp/sdc/logging/servlet/jaxrs/LoggingResponseFilter.java
@@ -18,8 +18,7 @@ package org.openecomp.sdc.logging.servlet.jaxrs;
import static javax.ws.rs.core.Response.Status.Family.REDIRECTION;
import static javax.ws.rs.core.Response.Status.Family.SUCCESSFUL;
-import static org.openecomp.sdc.logging.api.StatusCode.COMPLETE;
-import static org.openecomp.sdc.logging.api.StatusCode.ERROR;
+import static org.onap.logging.ref.slf4j.ONAPLogConstants.ResponseStatus.*;
import static org.openecomp.sdc.logging.servlet.jaxrs.LoggingRequestFilter.LOGGING_TRACKER_KEY;
import javax.ws.rs.container.ContainerRequestContext;
@@ -27,9 +26,10 @@ import javax.ws.rs.container.ContainerResponseContext;
import javax.ws.rs.container.ContainerResponseFilter;
import javax.ws.rs.core.Response;
import javax.ws.rs.ext.Provider;
+
+import org.onap.logging.ref.slf4j.ONAPLogConstants.ResponseStatus;
import org.openecomp.sdc.logging.api.Logger;
import org.openecomp.sdc.logging.api.LoggerFactory;
-import org.openecomp.sdc.logging.api.StatusCode;
import org.openecomp.sdc.logging.servlet.RequestProcessingResult;
import org.openecomp.sdc.logging.servlet.Tracker;
@@ -82,7 +82,7 @@ public class LoggingResponseFilter implements ContainerResponseFilter {
}
@Override
- public StatusCode getStatusCode() {
+ public ResponseStatus getStatusCode() {
Response.Status.Family family = statusInfo.getFamily();
return family.equals(SUCCESSFUL) || family.equals(REDIRECTION) ? COMPLETE : ERROR;
}