From 3d3eff47f0f94176f351d05f7dca39957a0c3c8b Mon Sep 17 00:00:00 2001 From: kjaniak Date: Thu, 27 Dec 2018 09:01:47 +0100 Subject: Rename of metrics Names of metrics were a bit misleading e.g. total and count addition to name of metrics. Clean up in unit tests. Change-Id: I339c8824f31a226bdbe648027b114321e3fd9858 Issue-ID: DCAEGEN2-1046 Signed-off-by: kjaniak --- .../veshv/main/metrics/MicrometerMetrics.kt | 58 ++++++++++------------ 1 file changed, 27 insertions(+), 31 deletions(-) (limited to 'sources/hv-collector-main/src/main') 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 f3bcf381..b832bc9f 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 @@ -47,37 +47,34 @@ class MicrometerMetrics internal constructor( ) : Metrics { private val receivedBytes = registry.counter(name(DATA, RECEIVED, BYTES)) - private val receivedMsgCount = registry.counter(name(MESSAGES, RECEIVED, COUNT)) - private val receivedMsgBytes = registry.counter(name(MESSAGES, RECEIVED, BYTES)) + private val receivedMessages = registry.counter(name(MESSAGES, RECEIVED)) + private val receivedMessagesPayloadBytes = registry.counter(name(MESSAGES, RECEIVED, PAYLOAD, BYTES)) - private val connectionsTotalCount = registry.counter(name(CONNECTIONS, TOTAL, COUNT)) - private val disconnectionsCount = registry.counter(name(DISCONNECTIONS, COUNT)) + private val totalConnections = registry.counter(name(CONNECTIONS)) + private val disconnections = registry.counter(name(DISCONNECTIONS)) private val processingTime = registry.timer(name(MESSAGES, PROCESSING, TIME)) - private val totalLatency = registry.timer(name(MESSAGES, LATENCY, TIME)) + private val totalLatency = registry.timer(name(MESSAGES, LATENCY)) - private val sentCount = registry.counter(name(MESSAGES, SENT, COUNT)) - private val sentToTopicCount = { topic: String -> - registry.counter(name(MESSAGES, SENT, TOPIC, COUNT), TOPIC, topic) + private val sentMessages = registry.counter(name(MESSAGES, SENT)) + private val sentMessagesByTopic = { topic: String -> + registry.counter(name(MESSAGES, SENT, TOPIC), TOPIC, topic) }.memoize() - private val droppedCount = registry.counter(name(MESSAGES, DROPPED, COUNT)) - private val droppedCauseCount = { cause: String -> - registry.counter(name(MESSAGES, DROPPED, CAUSE, COUNT), CAUSE, cause) + private val droppedMessages = registry.counter(name(MESSAGES, DROPPED)) + private val messagesDroppedByCause = { cause: String -> + registry.counter(name(MESSAGES, DROPPED, CAUSE), CAUSE, cause) }.memoize() - private val clientsRejectedCount = registry.counter(name(CLIENTS, REJECTED, COUNT)) - private val clientsRejectedCauseCount = { cause: String -> - registry.counter(name(CLIENTS, REJECTED, CAUSE, COUNT), CAUSE, cause) + private val clientsRejected = registry.counter(name(CLIENTS, REJECTED)) + private val clientsRejectedByCause = { cause: String -> + registry.counter(name(CLIENTS, REJECTED, CAUSE), CAUSE, cause) }.memoize() init { - registry.gauge(name(MESSAGES, PROCESSING, COUNT), this) { - (receivedMsgCount.count() - sentCount.count() - droppedCount.count()).coerceAtLeast(0.0) - } - registry.gauge(name(CONNECTIONS, ACTIVE, COUNT), this) { - (connectionsTotalCount.count() - disconnectionsCount.count()).coerceAtLeast(0.0) + registry.gauge(name(CONNECTIONS, ACTIVE), this) { + (totalConnections.count() - disconnections.count()).coerceAtLeast(0.0) } ClassLoaderMetrics().bindTo(registry) @@ -94,35 +91,35 @@ class MicrometerMetrics internal constructor( } override fun notifyMessageReceived(msg: WireFrameMessage) { - receivedMsgCount.increment() - receivedMsgBytes.increment(msg.payloadSize.toDouble()) + receivedMessages.increment() + receivedMessagesPayloadBytes.increment(msg.payloadSize.toDouble()) } override fun notifyMessageSent(msg: RoutedMessage) { val now = Instant.now() - sentCount.increment() - sentToTopicCount(msg.topic).increment() + sentMessages.increment() + sentMessagesByTopic(msg.topic).increment() processingTime.record(Duration.between(msg.message.wtpFrame.receivedAt, now)) totalLatency.record(Duration.between(epochMicroToInstant(msg.message.header.lastEpochMicrosec), now)) } override fun notifyMessageDropped(cause: MessageDropCause) { - droppedCount.increment() - droppedCauseCount(cause.tag).increment() + droppedMessages.increment() + messagesDroppedByCause(cause.tag).increment() } override fun notifyClientRejected(cause: ClientRejectionCause) { - clientsRejectedCount.increment() - clientsRejectedCauseCount(cause.tag).increment() + clientsRejected.increment() + clientsRejectedByCause(cause.tag).increment() } override fun notifyClientConnected() { - connectionsTotalCount.increment() + totalConnections.increment() } override fun notifyClientDisconnected() { - disconnectionsCount.increment() + disconnections.increment() } companion object { @@ -134,7 +131,6 @@ class MicrometerMetrics internal constructor( internal const val CONNECTIONS = "connections" internal const val ACTIVE = "active" internal const val BYTES = "bytes" - internal const val COUNT = "count" internal const val DATA = "data" internal const val SENT = "sent" internal const val PROCESSING = "processing" @@ -143,9 +139,9 @@ class MicrometerMetrics internal constructor( internal const val REJECTED = "rejected" internal const val TOPIC = "topic" internal const val DROPPED = "dropped" - internal const val TOTAL = "total" internal const val TIME = "time" internal const val LATENCY = "latency" + internal const val PAYLOAD = "payload" internal fun name(vararg name: String) = "$PREFIX.${name.joinToString(".")}" } } -- cgit 1.2.3-korg