summaryrefslogtreecommitdiffstats
path: root/ms/blueprintsprocessor/modules/inbounds/selfservice-api/src/main
diff options
context:
space:
mode:
authorJulien Fontaine <julien.fontaine@bell.ca>2020-10-27 17:45:39 -0400
committerJulien Fontaine <julien.fontaine@bell.ca>2020-10-28 10:14:09 -0400
commit3d97f873d014bd39dc743dd4d5b76c998123b65f (patch)
tree49a33b3b788cb8dd3b2cb1ee3f94b92d96cc04e2 /ms/blueprintsprocessor/modules/inbounds/selfservice-api/src/main
parent3cf2196942c6a5378bb8b2483d7bdd9c0e76ab10 (diff)
Blueprints Processor Metrics
Add counter and timer for Blueprints Processor process to get success/failure and execution time for each blueprint execution using blueprint name, version and action. Issue-ID: CCSDK-2950 Change-Id: I38e8997de26effe69ec2ee9e2b6ed0da14de4a43 Signed-off-by: Julien Fontaine <julien.fontaine@bell.ca> Signed-off-by: Jozsef Csongvai <jozsef.csongvai@bell.ca>
Diffstat (limited to 'ms/blueprintsprocessor/modules/inbounds/selfservice-api/src/main')
-rw-r--r--ms/blueprintsprocessor/modules/inbounds/selfservice-api/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/selfservice/api/ExecutionServiceHandler.kt15
-rw-r--r--ms/blueprintsprocessor/modules/inbounds/selfservice-api/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/selfservice/api/SelfServiceMetricConstants.kt21
-rw-r--r--ms/blueprintsprocessor/modules/inbounds/selfservice-api/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/selfservice/api/utils/Utils.kt24
3 files changed, 59 insertions, 1 deletions
diff --git a/ms/blueprintsprocessor/modules/inbounds/selfservice-api/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/selfservice/api/ExecutionServiceHandler.kt b/ms/blueprintsprocessor/modules/inbounds/selfservice-api/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/selfservice/api/ExecutionServiceHandler.kt
index 4a7171ceb..89a963727 100644
--- a/ms/blueprintsprocessor/modules/inbounds/selfservice-api/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/selfservice/api/ExecutionServiceHandler.kt
+++ b/ms/blueprintsprocessor/modules/inbounds/selfservice-api/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/selfservice/api/ExecutionServiceHandler.kt
@@ -18,6 +18,8 @@
package org.onap.ccsdk.cds.blueprintsprocessor.selfservice.api
import io.grpc.stub.StreamObserver
+import io.micrometer.core.instrument.MeterRegistry
+import io.micrometer.core.instrument.Timer
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.GlobalScope
import kotlinx.coroutines.launch
@@ -27,6 +29,9 @@ import org.onap.ccsdk.cds.blueprintsprocessor.core.api.data.ExecutionServiceInpu
import org.onap.ccsdk.cds.blueprintsprocessor.core.api.data.ExecutionServiceOutput
import org.onap.ccsdk.cds.blueprintsprocessor.core.api.data.Status
import org.onap.ccsdk.cds.blueprintsprocessor.core.utils.toProto
+import org.onap.ccsdk.cds.blueprintsprocessor.selfservice.api.SelfServiceMetricConstants.COUNTER_PROCESS
+import org.onap.ccsdk.cds.blueprintsprocessor.selfservice.api.SelfServiceMetricConstants.TIMER_PROCESS
+import org.onap.ccsdk.cds.blueprintsprocessor.selfservice.api.utils.cbaMetricTags
import org.onap.ccsdk.cds.blueprintsprocessor.services.execution.AbstractServiceFunction
import org.onap.ccsdk.cds.controllerblueprints.common.api.EventType
import org.onap.ccsdk.cds.controllerblueprints.core.BluePrintConstants
@@ -45,7 +50,8 @@ class ExecutionServiceHandler(
private val blueprintsProcessorCatalogService: BluePrintCatalogService,
private val bluePrintWorkflowExecutionService:
BluePrintWorkflowExecutionService<ExecutionServiceInput, ExecutionServiceOutput>,
- private val publishAuditService: PublishAuditService
+ private val publishAuditService: PublishAuditService,
+ private val meterRegistry: MeterRegistry
) {
private val log = LoggerFactory.getLogger(ExecutionServiceHandler::class.toString())
@@ -75,6 +81,7 @@ class ExecutionServiceHandler(
"Failed to process request, 'actionIdentifiers.mode' not specified. Valid value are: 'sync' or 'async'.",
true
)
+ meterRegistry.counter(COUNTER_PROCESS, cbaMetricTags(executionServiceOutput)).increment()
publishAuditService.publishExecutionOutput(executionServiceInput.correlationUUID, executionServiceOutput)
responseObserver.onNext(
executionServiceOutput.toProto()
@@ -93,8 +100,10 @@ class ExecutionServiceHandler(
log.info("processing request id $requestId")
+ // Audit input
publishAuditService.publishExecutionInput(executionServiceInput)
+ val sample = Timer.start()
try {
/** Check Blueprint is needed for this request */
if (checkServiceFunction(executionServiceInput)) {
@@ -120,7 +129,11 @@ class ExecutionServiceHandler(
log.error("fail processing request id $requestId", e)
executionServiceOutput = response(executionServiceInput, e.localizedMessage ?: e.message ?: e.toString(), true)
}
+ // Update process metrics
+ sample.stop(meterRegistry.timer(TIMER_PROCESS, cbaMetricTags(executionServiceInput)))
+ meterRegistry.counter(COUNTER_PROCESS, cbaMetricTags(executionServiceOutput)).increment()
+ // Audit output
publishAuditService.publishExecutionOutput(executionServiceInput.correlationUUID, executionServiceOutput)
return executionServiceOutput
}
diff --git a/ms/blueprintsprocessor/modules/inbounds/selfservice-api/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/selfservice/api/SelfServiceMetricConstants.kt b/ms/blueprintsprocessor/modules/inbounds/selfservice-api/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/selfservice/api/SelfServiceMetricConstants.kt
new file mode 100644
index 000000000..97c73243d
--- /dev/null
+++ b/ms/blueprintsprocessor/modules/inbounds/selfservice-api/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/selfservice/api/SelfServiceMetricConstants.kt
@@ -0,0 +1,21 @@
+package org.onap.ccsdk.cds.blueprintsprocessor.selfservice.api
+
+object SelfServiceMetricConstants {
+
+ private const val METRICS_PREFIX = "cds.cba"
+
+ private const val PROCESS_PREFIX = "$METRICS_PREFIX.process"
+
+ // TAGS
+ const val TAG_BP_NAME = "blueprint_name"
+ const val TAG_BP_VERSION = "blueprint_version"
+ const val TAG_BP_ACTION = "blueprint_action"
+ const val TAG_BP_STATUS = "status"
+ const val TAG_BP_OUTCOME = "outcome"
+
+ // COUNTERS
+ const val COUNTER_PROCESS = "$PROCESS_PREFIX.counter"
+
+ // TIMERS
+ const val TIMER_PROCESS = "$PROCESS_PREFIX.timer"
+}
diff --git a/ms/blueprintsprocessor/modules/inbounds/selfservice-api/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/selfservice/api/utils/Utils.kt b/ms/blueprintsprocessor/modules/inbounds/selfservice-api/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/selfservice/api/utils/Utils.kt
index 66cdbef3e..08cae09b3 100644
--- a/ms/blueprintsprocessor/modules/inbounds/selfservice-api/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/selfservice/api/utils/Utils.kt
+++ b/ms/blueprintsprocessor/modules/inbounds/selfservice-api/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/selfservice/api/utils/Utils.kt
@@ -15,6 +15,10 @@
*/
package org.onap.ccsdk.cds.blueprintsprocessor.selfservice.api.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.selfservice.api.SelfServiceMetricConstants
import org.onap.ccsdk.cds.controllerblueprints.core.BluePrintException
import org.springframework.http.HttpStatus
import org.springframework.http.codec.multipart.FilePart
@@ -60,3 +64,23 @@ fun determineHttpStatusCode(statusCode: Int): HttpStatus {
return HttpStatus.valueOf(INTERNAL_SERVER_ERROR_HTTP_STATUS_CODE)
}
}
+
+fun cbaMetricTags(executionServiceInput: ExecutionServiceInput): MutableList<Tag> =
+ executionServiceInput.actionIdentifiers.let {
+ mutableListOf(
+ Tag.of(SelfServiceMetricConstants.TAG_BP_NAME, it.blueprintName),
+ Tag.of(SelfServiceMetricConstants.TAG_BP_VERSION, it.blueprintVersion),
+ Tag.of(SelfServiceMetricConstants.TAG_BP_ACTION, it.actionName)
+ )
+ }
+
+fun cbaMetricTags(executionServiceOutput: ExecutionServiceOutput): MutableList<Tag> =
+ executionServiceOutput.let {
+ mutableListOf(
+ Tag.of(SelfServiceMetricConstants.TAG_BP_NAME, it.actionIdentifiers.blueprintName),
+ Tag.of(SelfServiceMetricConstants.TAG_BP_VERSION, it.actionIdentifiers.blueprintVersion),
+ Tag.of(SelfServiceMetricConstants.TAG_BP_ACTION, it.actionIdentifiers.actionName),
+ Tag.of(SelfServiceMetricConstants.TAG_BP_STATUS, it.status.code.toString()),
+ Tag.of(SelfServiceMetricConstants.TAG_BP_OUTCOME, it.status.message)
+ )
+ }