aboutsummaryrefslogtreecommitdiffstats
path: root/sources/hv-collector-main/src/main
diff options
context:
space:
mode:
authorPiotr Jaszczyk <piotr.jaszczyk@nokia.com>2018-12-17 13:22:52 +0100
committerPiotr Jaszczyk <piotr.jaszczyk@nokia.com>2018-12-18 11:00:12 +0100
commit30488f1922f789c5b8e18934456968aa354c9671 (patch)
tree48716d0c7d48c55931828bdc056083da838e4796 /sources/hv-collector-main/src/main
parent8c180a2101f54d7cc0e3527c2bbe23390eea9cef (diff)
Metric: Message latency
Defined as a difference between now and vesHeader.lastEpochTime. Change-Id: I4aa97e8efc13cb0039fde38b4fd2aa6411c7b89a Issue-ID: DCAEGEN2-1036 Signed-off-by: Piotr Jaszczyk <piotr.jaszczyk@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.kt16
1 files changed, 11 insertions, 5 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 f060426d..d35e17d6 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
@@ -30,9 +30,10 @@ 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.WireFrameMessage
-import org.onap.dcae.collectors.veshv.model.MessageDropCause
import org.onap.dcae.collectors.veshv.model.ClientRejectionCause
+import org.onap.dcae.collectors.veshv.model.MessageDropCause
import org.onap.dcae.collectors.veshv.model.RoutedMessage
+import org.onap.dcae.collectors.veshv.utils.TimeUtils.epochMicroToInstant
import java.time.Duration
import java.time.Instant
@@ -49,6 +50,9 @@ class MicrometerMetrics internal constructor(
private val receivedMsgCount = registry.counter(name(MESSAGES, RECEIVED, COUNT))
private val receivedMsgBytes = registry.counter(name(MESSAGES, RECEIVED, BYTES))
+ private val processingTime = registry.timer(name(MESSAGES, PROCESSING, TIME))
+ private val totalLatency = registry.timer(name(MESSAGES, LATENCY, TIME))
+
private val sentCountTotal = registry.counter(name(MESSAGES, SENT, COUNT))
private val sentToTopicCount = { topic: String ->
registry.counter(name(MESSAGES, SENT, TOPIC, COUNT), TOPIC, topic)
@@ -59,8 +63,6 @@ class MicrometerMetrics internal constructor(
registry.counter(name(MESSAGES, DROPPED, CAUSE, COUNT), CAUSE, cause)
}.memoize<String, Counter>()
- private val processingTime = registry.timer(name(MESSAGES, PROCESSING, TIME))
-
private val clientsRejectedCount = registry.counter(name(CLIENTS, REJECTED, COUNT))
private val clientsRejectedCauseCount = { cause: String ->
registry.counter(name(CLIENTS, REJECTED, CAUSE, COUNT), CAUSE, cause)
@@ -90,9 +92,12 @@ class MicrometerMetrics internal constructor(
}
override fun notifyMessageSent(msg: RoutedMessage) {
+ val now = Instant.now()
sentCountTotal.increment()
sentToTopicCount(msg.topic).increment()
- processingTime.record(Duration.between(msg.message.wtpFrame.receivedAt, Instant.now()))
+
+ processingTime.record(Duration.between(msg.message.wtpFrame.receivedAt, now))
+ totalLatency.record(Duration.between(epochMicroToInstant(msg.message.header.lastEpochMicrosec), now))
}
override fun notifyMessageDropped(cause: MessageDropCause) {
@@ -121,6 +126,7 @@ class MicrometerMetrics internal constructor(
internal const val TOPIC = "topic"
internal const val DROPPED = "dropped"
internal const val TIME = "time"
- fun name(vararg name: String) = "$PREFIX.${name.joinToString(".")}"
+ internal const val LATENCY = "latency"
+ internal fun name(vararg name: String) = "$PREFIX.${name.joinToString(".")}"
}
}