aboutsummaryrefslogtreecommitdiffstats
path: root/sources/hv-collector-main/src/main
diff options
context:
space:
mode:
authorkjaniak <kornel.janiak@nokia.com>2020-04-21 12:44:53 +0200
committerKornel Janiak <kornel.janiak@nokia.com>2020-04-22 11:19:54 +0000
commitda498bfc1f006a17f1d8174b10bc33acbd4b2fa0 (patch)
tree3711f4b175ce046feceaab482a9d786a2f152a55 /sources/hv-collector-main/src/main
parentc61dcc75290d24ec0f0188b32e0ab0a7f15ea420 (diff)
Add of message travel time metric
Message travel time: Producer -> HV-VES input introduced. Tests for new metric added. Change-Id: I36347ff53abb3f274e4358af26db49fe8bac95ed Issue-ID: DCAEGEN2-1576 Signed-off-by: kjaniak <kornel.janiak@nokia.com>
Diffstat (limited to 'sources/hv-collector-main/src/main')
-rw-r--r--sources/hv-collector-main/src/main/kotlin/org/onap/dcae/collectors/veshv/main/metrics/MicrometerMetrics.kt19
1 files changed, 16 insertions, 3 deletions
diff --git a/sources/hv-collector-main/src/main/kotlin/org/onap/dcae/collectors/veshv/main/metrics/MicrometerMetrics.kt b/sources/hv-collector-main/src/main/kotlin/org/onap/dcae/collectors/veshv/main/metrics/MicrometerMetrics.kt
index 2f3470a4..e0d99fc6 100644
--- a/sources/hv-collector-main/src/main/kotlin/org/onap/dcae/collectors/veshv/main/metrics/MicrometerMetrics.kt
+++ b/sources/hv-collector-main/src/main/kotlin/org/onap/dcae/collectors/veshv/main/metrics/MicrometerMetrics.kt
@@ -2,7 +2,7 @@
* ============LICENSE_START=======================================================
* dcaegen2-collectors-veshv
* ================================================================================
- * Copyright (C) 2018-2019 NOKIA
+ * Copyright (C) 2018-2020 NOKIA
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -30,11 +30,11 @@ import io.micrometer.core.instrument.binder.system.ProcessorMetrics
import io.micrometer.prometheus.PrometheusConfig
import io.micrometer.prometheus.PrometheusMeterRegistry
import org.onap.dcae.collectors.veshv.boundary.Metrics
+import org.onap.dcae.collectors.veshv.domain.RoutedMessage
+import org.onap.dcae.collectors.veshv.domain.VesMessage
import org.onap.dcae.collectors.veshv.domain.WireFrameMessage
import org.onap.dcae.collectors.veshv.model.ClientRejectionCause
import org.onap.dcae.collectors.veshv.model.MessageDropCause
-import org.onap.dcae.collectors.veshv.domain.RoutedMessage
-import org.onap.dcae.collectors.veshv.domain.VesMessage
import org.onap.dcae.collectors.veshv.utils.TimeUtils.epochMicroToInstant
import java.time.Duration
import java.time.Instant
@@ -54,6 +54,10 @@ class MicrometerMetrics internal constructor(
private val totalConnections = registry.counter(name(CONNECTIONS))
private val disconnections = registry.counter(name(DISCONNECTIONS))
+ private val travelTimeToCollector = Timer.builder(name(MESSAGES, TO, COLLECTOR, TRAVEL, TIME))
+ .maximumExpectedValue(MAX_BUCKET_DURATION)
+ .publishPercentileHistogram(true)
+ .register(registry)
private val processingTime = Timer.builder(name(MESSAGES, PROCESSING, TIME))
.maximumExpectedValue(MAX_BUCKET_DURATION)
.publishPercentileHistogram(true)
@@ -108,6 +112,12 @@ class MicrometerMetrics internal constructor(
receivedMessagesPayloadBytes.increment(msg.payloadSize.toDouble())
}
+ override fun notifyMessageReceived(msg: VesMessage) {
+ travelTimeToCollector.record(
+ Duration.between(epochMicroToInstant(msg.header.lastEpochMicrosec), msg.wtpFrame.receivedAt)
+ )
+ }
+
override fun notifyMessageSent(msg: RoutedMessage) {
val now = Instant.now()
sentMessages.increment()
@@ -157,6 +167,9 @@ class MicrometerMetrics internal constructor(
internal const val PAYLOAD = "payload"
internal const val WITHOUT = "without"
internal const val ROUTING = "routing"
+ internal const val TRAVEL = "travel"
+ internal const val TO = "to"
+ internal const val COLLECTOR = "collector"
internal val MAX_BUCKET_DURATION = Duration.ofSeconds(300L)
internal fun name(vararg name: String) = "$PREFIX.${name.joinToString(".")}"
}