diff options
author | Julien Fontaine <julien.fontaine@bell.ca> | 2021-06-23 08:44:00 -0400 |
---|---|---|
committer | Julien Fontaine <julien.fontaine@bell.ca> | 2021-06-23 12:34:20 -0400 |
commit | cc7b12386f6ada2cabead94da33cf3ed68ac8cf7 (patch) | |
tree | c3ff09688d1a8b12f28a91815bcd15cc9309b753 /ms/blueprintsprocessor/modules/commons/message-lib | |
parent | 5ae1f987e90bc27cf404e0a308ea93f7059299ab (diff) |
Add Request ID and Sub Request ID to CDS kafka logs
Improved log message when a message is published or consumed by CDS Kafka to specify the RequestID and SubRequestID.
Issue-ID: CCSDK-3348
Signed-off-by: Julien Fontaine <julien.fontaine@bell.ca>
Change-Id: I50e068d9aa36df8fe4ee5f0f6a8e9bd7a1209467
Diffstat (limited to 'ms/blueprintsprocessor/modules/commons/message-lib')
2 files changed, 15 insertions, 10 deletions
diff --git a/ms/blueprintsprocessor/modules/commons/message-lib/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/message/utils/BlueprintMessageUtils.kt b/ms/blueprintsprocessor/modules/commons/message-lib/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/message/utils/BlueprintMessageUtils.kt index b4817cd8a..644bd7ba1 100644 --- a/ms/blueprintsprocessor/modules/commons/message-lib/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/message/utils/BlueprintMessageUtils.kt +++ b/ms/blueprintsprocessor/modules/commons/message-lib/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/message/utils/BlueprintMessageUtils.kt @@ -17,8 +17,7 @@ package org.onap.ccsdk.cds.blueprintsprocessor.message.utils import io.micrometer.core.instrument.Tag -import org.onap.ccsdk.cds.blueprintsprocessor.core.api.data.ExecutionServiceInput -import org.onap.ccsdk.cds.blueprintsprocessor.core.api.data.ExecutionServiceOutput +import org.onap.ccsdk.cds.blueprintsprocessor.core.api.data.CommonExecutionServiceData import org.onap.ccsdk.cds.controllerblueprints.core.BlueprintConstants import org.onap.ccsdk.cds.controllerblueprints.core.defaultToUUID import kotlin.math.max @@ -41,13 +40,11 @@ class BlueprintMessageUtils { fun getMessageLogData(message: Any): String = when (message) { - is ExecutionServiceInput -> { + is CommonExecutionServiceData -> { val actionIdentifiers = message.actionIdentifiers - "CBA(${actionIdentifiers.blueprintName}/${actionIdentifiers.blueprintVersion}/${actionIdentifiers.actionName})" - } - is ExecutionServiceOutput -> { - val actionIdentifiers = message.actionIdentifiers - "CBA(${actionIdentifiers.blueprintName}/${actionIdentifiers.blueprintVersion}/${actionIdentifiers.actionName})" + val commonHeaders = message.commonHeader + "requestID(${commonHeaders.requestId}), subrequestID(${commonHeaders.subRequestId}) " + + "CBA(${actionIdentifiers.blueprintName}/${actionIdentifiers.blueprintVersion}/${actionIdentifiers.actionName})" } else -> "message($message)" } diff --git a/ms/blueprintsprocessor/modules/commons/message-lib/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/message/utils/BlueprintMessageUtilsTest.kt b/ms/blueprintsprocessor/modules/commons/message-lib/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/message/utils/BlueprintMessageUtilsTest.kt index de9ca2c44..9b5ca62f6 100644 --- a/ms/blueprintsprocessor/modules/commons/message-lib/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/message/utils/BlueprintMessageUtilsTest.kt +++ b/ms/blueprintsprocessor/modules/commons/message-lib/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/message/utils/BlueprintMessageUtilsTest.kt @@ -21,6 +21,7 @@ import io.mockk.every import io.mockk.mockkStatic import org.junit.Test import org.onap.ccsdk.cds.blueprintsprocessor.core.api.data.ActionIdentifiers +import org.onap.ccsdk.cds.blueprintsprocessor.core.api.data.CommonHeader import org.onap.ccsdk.cds.blueprintsprocessor.core.api.data.ExecutionServiceInput import org.onap.ccsdk.cds.controllerblueprints.core.BlueprintConstants @@ -54,14 +55,20 @@ class BlueprintMessageUtilsTest { @Test fun testGetMessageLogData() { + var header = CommonHeader().apply { + requestId = "myrequestid" + subRequestId = "mysubrequestid" + } + val input = ExecutionServiceInput().apply { actionIdentifiers = ActionIdentifiers().apply { blueprintName = "bpInput" blueprintVersion = "1.0.0-input" actionName = "bpActionInput" } + commonHeader = header } - val expectedOnInput = "CBA(bpInput/1.0.0-input/bpActionInput)" + val expectedOnInput = "requestID(myrequestid), subrequestID(mysubrequestid) CBA(bpInput/1.0.0-input/bpActionInput)" val output = ExecutionServiceInput().apply { actionIdentifiers = ActionIdentifiers().apply { @@ -69,8 +76,9 @@ class BlueprintMessageUtilsTest { blueprintVersion = "1.0.0-output" actionName = "bpActionOutput" } + commonHeader = header } - val expectedOnOutput = "CBA(bpOutput/1.0.0-output/bpActionOutput)" + val expectedOnOutput = "requestID(myrequestid), subrequestID(mysubrequestid) CBA(bpOutput/1.0.0-output/bpActionOutput)" val otherMessage = "some other message" val expectedOnOtherMessage = "message(some other message)" |