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
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
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)"
}
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
@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 {
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)"
* DATE : 8/15/2018
*/
-open class ExecutionServiceInput {
-
- @get:ApiModelProperty(required = false, hidden = true)
- var correlationUUID: String = UUID.randomUUID().toString()
-
+abstract class CommonExecutionServiceData {
@get:ApiModelProperty(required = true, value = "Headers providing request context.")
lateinit var commonHeader: CommonHeader
@get:ApiModelProperty(required = true, value = "Provide information about the action to execute.")
lateinit var actionIdentifiers: ActionIdentifiers
+}
+
+open class ExecutionServiceInput : CommonExecutionServiceData() {
+
+ @get:ApiModelProperty(required = false, hidden = true)
+ var correlationUUID: String = UUID.randomUUID().toString()
@get:ApiModelProperty(
required = true,
var stepData: StepData? = null
}
-open class ExecutionServiceOutput {
+open class ExecutionServiceOutput : CommonExecutionServiceData() {
@get:ApiModelProperty(required = false, hidden = true)
var correlationUUID: String? = null
- @get:ApiModelProperty(required = true, value = "Headers providing request context.")
- lateinit var commonHeader: CommonHeader
-
- @get:ApiModelProperty(required = true, value = "Provide information about the action to execute.")
- lateinit var actionIdentifiers: ActionIdentifiers
-
@get:ApiModelProperty(required = true, value = "Status of the request.")
lateinit var status: Status