aboutsummaryrefslogtreecommitdiffstats
path: root/ms/blueprintsprocessor/modules/commons/grpc-lib/src
diff options
context:
space:
mode:
authorBrinda Santh <bs2796@att.com>2019-10-28 16:46:47 -0400
committerBrinda Santh <bs2796@att.com>2019-10-28 16:46:47 -0400
commit0d3a0223fd11d431497519f3f9da640aafe00460 (patch)
tree8f211b811e86ebf72d4873957624ded94206d7c9 /ms/blueprintsprocessor/modules/commons/grpc-lib/src
parent6885f5811c515d00c049c87de0797076dfc3686e (diff)
Add Message tracing logger service.
Issue-ID: CCSDK-1046 Signed-off-by: Brinda Santh <bs2796@att.com> Change-Id: I509df82ec558cd96934043a5b41ea53aa040cc81
Diffstat (limited to 'ms/blueprintsprocessor/modules/commons/grpc-lib/src')
-rw-r--r--ms/blueprintsprocessor/modules/commons/grpc-lib/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/grpc/service/GrpcLoggerService.kt9
1 files changed, 6 insertions, 3 deletions
diff --git a/ms/blueprintsprocessor/modules/commons/grpc-lib/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/grpc/service/GrpcLoggerService.kt b/ms/blueprintsprocessor/modules/commons/grpc-lib/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/grpc/service/GrpcLoggerService.kt
index 1b932480a..6d2ba43cc 100644
--- a/ms/blueprintsprocessor/modules/commons/grpc-lib/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/grpc/service/GrpcLoggerService.kt
+++ b/ms/blueprintsprocessor/modules/commons/grpc-lib/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/grpc/service/GrpcLoggerService.kt
@@ -31,6 +31,7 @@ import org.onap.ccsdk.cds.controllerblueprints.core.defaultToEmpty
import org.onap.ccsdk.cds.controllerblueprints.core.defaultToUUID
import org.onap.ccsdk.cds.controllerblueprints.core.logger
import org.slf4j.MDC
+import java.net.InetAddress
import java.net.InetSocketAddress
import java.time.ZoneOffset
import java.time.ZonedDateTime
@@ -46,7 +47,7 @@ class GrpcLoggerService {
headers: Metadata, next: ServerCallHandler<ReqT, RespT>) {
val requestID = headers.getStringKey(ONAP_REQUEST_ID).defaultToUUID()
val invocationID = headers.getStringKey(ONAP_INVOCATION_ID).defaultToUUID()
- val partnerName = headers.getStringKey(ONAP_PARTNER_NAME).defaultToUUID()
+ val partnerName = headers.getStringKey(ONAP_PARTNER_NAME) ?: "UNKNOWN"
grpcRequesting(requestID, invocationID, partnerName, call)
}
@@ -54,12 +55,14 @@ class GrpcLoggerService {
headers: CommonHeader, next: ServerCallHandler<ReqT, RespT>) {
val requestID = headers.requestId.defaultToUUID()
val invocationID = headers.subRequestId.defaultToUUID()
- val partnerName = headers.originatorId.defaultToUUID()
+ val partnerName = headers.originatorId ?: "UNKNOWN"
grpcRequesting(requestID, invocationID, partnerName, call)
}
fun <ReqT : Any, RespT : Any> grpcRequesting(requestID: String, invocationID: String, partnerName: String,
call: ServerCall<ReqT, RespT>) {
+ val localhost = InetAddress.getLocalHost()
+
val clientSocketAddress = call.attributes.get(Grpc.TRANSPORT_ATTR_REMOTE_ADDR) as? InetSocketAddress
?: throw BluePrintProcessorException("failed to get client address")
val serviceName = call.methodDescriptor.fullMethodName
@@ -69,7 +72,7 @@ class GrpcLoggerService {
MDC.put("InvocationID", invocationID)
MDC.put("PartnerName", partnerName)
MDC.put("ClientIPAddress", clientSocketAddress.address.defaultToEmpty())
- MDC.put("ServerFQDN", clientSocketAddress.address.hostName.defaultToEmpty())
+ MDC.put("ServerFQDN", localhost.hostName.defaultToEmpty())
MDC.put("ServiceName", serviceName)
log.trace("MDC Properties : ${MDC.getCopyOfContextMap()}")
}