aboutsummaryrefslogtreecommitdiffstats
path: root/prh-aai-client/src/main
diff options
context:
space:
mode:
authormicdzied <michal.1.dziedzic@nokia.com>2018-08-30 10:25:19 +0200
committermicdzied <michal.1.dziedzic@nokia.com>2018-08-30 14:53:20 +0200
commit6fd8c7770fbea30ad2ec6e3f7645b8baab5a49a1 (patch)
tree78d572b5df8c88047d74edf3c75b28fcab3d0dc6 /prh-aai-client/src/main
parent82a6fc31d1905f380fbbae1d0b4a34b67d8258e3 (diff)
add MDC's
Change-Id: Ie4fe86791f46b790ae42088a5d2b93f491e4549d Issue-ID: DCAEGEN2-730 Signed-off-by: micdzied <michal.1.dziedzic@nokia.com>
Diffstat (limited to 'prh-aai-client/src/main')
-rw-r--r--prh-aai-client/src/main/java/org/onap/dcaegen2/services/prh/config/AaiClientConfiguration.java2
-rw-r--r--prh-aai-client/src/main/java/org/onap/dcaegen2/services/prh/service/AaiReactiveWebClient.java5
-rw-r--r--prh-aai-client/src/main/java/org/onap/dcaegen2/services/prh/service/producer/AaiProducerReactiveHttpClient.java11
3 files changed, 14 insertions, 4 deletions
diff --git a/prh-aai-client/src/main/java/org/onap/dcaegen2/services/prh/config/AaiClientConfiguration.java b/prh-aai-client/src/main/java/org/onap/dcaegen2/services/prh/config/AaiClientConfiguration.java
index 50259bae..4727f4bd 100644
--- a/prh-aai-client/src/main/java/org/onap/dcaegen2/services/prh/config/AaiClientConfiguration.java
+++ b/prh-aai-client/src/main/java/org/onap/dcaegen2/services/prh/config/AaiClientConfiguration.java
@@ -21,9 +21,7 @@
package org.onap.dcaegen2.services.prh.config;
import java.io.Serializable;
-
import java.util.Map;
-
import org.immutables.gson.Gson;
import org.immutables.value.Value;
import org.springframework.stereotype.Component;
diff --git a/prh-aai-client/src/main/java/org/onap/dcaegen2/services/prh/service/AaiReactiveWebClient.java b/prh-aai-client/src/main/java/org/onap/dcaegen2/services/prh/service/AaiReactiveWebClient.java
index d79e245a..6daf54a1 100644
--- a/prh-aai-client/src/main/java/org/onap/dcaegen2/services/prh/service/AaiReactiveWebClient.java
+++ b/prh-aai-client/src/main/java/org/onap/dcaegen2/services/prh/service/AaiReactiveWebClient.java
@@ -20,12 +20,15 @@
package org.onap.dcaegen2.services.prh.service;
+import static org.onap.dcaegen2.services.prh.model.logging.MDCVariables.RESPONSE_CODE;
+import static org.onap.dcaegen2.services.prh.model.logging.MDCVariables.SERVICE_NAME;
import static org.springframework.web.reactive.function.client.ExchangeFilterFunctions.basicAuthentication;
import java.util.Map;
import org.onap.dcaegen2.services.prh.config.AaiClientConfiguration;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
+import org.slf4j.MDC;
import org.springframework.web.reactive.function.client.ExchangeFilterFunction;
import org.springframework.web.reactive.function.client.WebClient;
import reactor.core.publisher.Mono;
@@ -68,6 +71,7 @@ public class AaiReactiveWebClient {
private ExchangeFilterFunction logRequest() {
return ExchangeFilterFunction.ofRequestProcessor(clientRequest -> {
+ MDC.put(SERVICE_NAME, String.valueOf(clientRequest.url()));
logger.info("Request: {} {}", clientRequest.method(), clientRequest.url());
clientRequest.headers()
.forEach((name, values) -> values.forEach(value -> logger.info("{}={}", name, value)));
@@ -77,6 +81,7 @@ public class AaiReactiveWebClient {
private ExchangeFilterFunction logResponse() {
return ExchangeFilterFunction.ofResponseProcessor(clientResponse -> {
+ MDC.put(RESPONSE_CODE, String.valueOf(clientResponse.statusCode()));
logger.info("Response Status {}", clientResponse.statusCode());
return Mono.just(clientResponse);
});
diff --git a/prh-aai-client/src/main/java/org/onap/dcaegen2/services/prh/service/producer/AaiProducerReactiveHttpClient.java b/prh-aai-client/src/main/java/org/onap/dcaegen2/services/prh/service/producer/AaiProducerReactiveHttpClient.java
index 0a6c9926..be6c63e0 100644
--- a/prh-aai-client/src/main/java/org/onap/dcaegen2/services/prh/service/producer/AaiProducerReactiveHttpClient.java
+++ b/prh-aai-client/src/main/java/org/onap/dcaegen2/services/prh/service/producer/AaiProducerReactiveHttpClient.java
@@ -20,15 +20,20 @@
package org.onap.dcaegen2.services.prh.service.producer;
+import static org.onap.dcaegen2.services.prh.model.logging.MDCVariables.REQUEST_ID;
+import static org.onap.dcaegen2.services.prh.model.logging.MDCVariables.X_INVOCATION_ID;
+import static org.onap.dcaegen2.services.prh.model.logging.MDCVariables.X_ONAP_REQUEST_ID;
+
import java.net.URI;
import java.net.URISyntaxException;
-
+import java.util.UUID;
import org.apache.http.client.utils.URIBuilder;
import org.onap.dcaegen2.services.prh.config.AaiClientConfiguration;
import org.onap.dcaegen2.services.prh.exceptions.AaiRequestException;
import org.onap.dcaegen2.services.prh.model.ConsumerDmaapModel;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
+import org.slf4j.MDC;
import org.springframework.http.HttpStatus;
import org.springframework.web.reactive.function.BodyInserters;
import org.springframework.web.reactive.function.client.WebClient;
@@ -37,12 +42,12 @@ import reactor.core.publisher.Mono;
public class AaiProducerReactiveHttpClient {
- private WebClient webClient;
private final String aaiHost;
private final String aaiProtocol;
private final Integer aaiHostPortNumber;
private final String aaiBasePath;
private final Logger logger = LoggerFactory.getLogger(this.getClass());
+ private WebClient webClient;
/**
@@ -78,6 +83,8 @@ public class AaiProducerReactiveHttpClient {
try {
return webClient.patch()
.uri(getUri(dmaapModel.getSourceName()))
+ .header(X_ONAP_REQUEST_ID, MDC.get(REQUEST_ID))
+ .header(X_INVOCATION_ID, UUID.randomUUID().toString())
.body(BodyInserters.fromObject(dmaapModel))
.retrieve()
.onStatus(