aboutsummaryrefslogtreecommitdiffstats
path: root/sources
diff options
context:
space:
mode:
authorkjaniak <kornel.janiak@nokia.com>2018-12-27 09:01:47 +0100
committerkjaniak <kornel.janiak@nokia.com>2018-12-27 11:13:38 +0100
commit3d3eff47f0f94176f351d05f7dca39957a0c3c8b (patch)
tree332c87126672d2ab33c4d29c797d090fcaabe67a /sources
parentbf7846b626c2e1267669da218a7dd32b328d87eb (diff)
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 <kornel.janiak@nokia.com>
Diffstat (limited to 'sources')
-rw-r--r--sources/hv-collector-main/src/main/kotlin/org/onap/dcae/collectors/veshv/main/metrics/MicrometerMetrics.kt58
-rw-r--r--sources/hv-collector-main/src/test/kotlin/org/onap/dcae/collectors/veshv/main/MicrometerMetricsTest.kt112
2 files changed, 65 insertions, 105 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 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<String, Counter>()
- 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<String, Counter>()
- 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<String, Counter>()
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(".")}"
}
}
diff --git a/sources/hv-collector-main/src/test/kotlin/org/onap/dcae/collectors/veshv/main/MicrometerMetricsTest.kt b/sources/hv-collector-main/src/test/kotlin/org/onap/dcae/collectors/veshv/main/MicrometerMetricsTest.kt
index 24355d5d..16d28326 100644
--- a/sources/hv-collector-main/src/test/kotlin/org/onap/dcae/collectors/veshv/main/MicrometerMetricsTest.kt
+++ b/sources/hv-collector-main/src/test/kotlin/org/onap/dcae/collectors/veshv/main/MicrometerMetricsTest.kt
@@ -22,6 +22,7 @@ package org.onap.dcae.collectors.veshv.main
import arrow.core.Try
import io.micrometer.core.instrument.Counter
import io.micrometer.core.instrument.Gauge
+import io.micrometer.core.instrument.Meter
import io.micrometer.core.instrument.Timer
import io.micrometer.core.instrument.search.RequiredSearch
import io.micrometer.prometheus.PrometheusConfig
@@ -34,19 +35,16 @@ import org.jetbrains.spek.api.dsl.it
import org.jetbrains.spek.api.dsl.on
import org.onap.dcae.collectors.veshv.main.metrics.MicrometerMetrics
import org.onap.dcae.collectors.veshv.main.metrics.MicrometerMetrics.Companion.PREFIX
-import org.onap.dcae.collectors.veshv.model.MessageDropCause.INVALID_MESSAGE
-import org.onap.dcae.collectors.veshv.model.MessageDropCause.ROUTE_NOT_FOUND
import org.onap.dcae.collectors.veshv.model.ClientRejectionCause.INVALID_WIRE_FRAME_MARKER
import org.onap.dcae.collectors.veshv.model.ClientRejectionCause.PAYLOAD_SIZE_EXCEEDED_IN_MESSAGE
+import org.onap.dcae.collectors.veshv.model.MessageDropCause.INVALID_MESSAGE
+import org.onap.dcae.collectors.veshv.model.MessageDropCause.ROUTE_NOT_FOUND
import org.onap.dcae.collectors.veshv.model.RoutedMessage
import org.onap.dcae.collectors.veshv.model.VesMessage
import org.onap.dcae.collectors.veshv.tests.utils.emptyWireProtocolFrame
import org.onap.dcae.collectors.veshv.tests.utils.vesEvent
import org.onap.dcae.collectors.veshv.tests.utils.wireProtocolFrame
-import org.onap.dcae.collectors.veshv.tests.utils.wireProtocolFrameWithPayloadSize
import java.time.Instant
-import io.micrometer.core.instrument.Meter
-
import java.time.temporal.Temporal
import java.util.concurrent.TimeUnit
import kotlin.reflect.KClass
@@ -133,8 +131,8 @@ object MicrometerMetricsTest : Spek({
}
describe("notifyMessageReceived") {
- on("$PREFIX.messages.received.count counter") {
- val counterName = "$PREFIX.messages.received.count"
+ on("$PREFIX.messages.received counter") {
+ val counterName = "$PREFIX.messages.received"
it("should increment counter") {
cut.notifyMessageReceived(emptyWireProtocolFrame())
@@ -145,8 +143,8 @@ object MicrometerMetricsTest : Spek({
}
}
- on("$PREFIX.messages.received.bytes counter") {
- val counterName = "$PREFIX.messages.received.bytes"
+ on("$PREFIX.messages.received.payload.bytes counter") {
+ val counterName = "$PREFIX.messages.received.payload.bytes"
it("should increment counter") {
val bytes = 888
@@ -161,8 +159,8 @@ object MicrometerMetricsTest : Spek({
it("should leave all other counters unchanged") {
cut.notifyMessageReceived(emptyWireProtocolFrame().copy(payloadSize = 128))
verifyCountersAndTimersAreUnchangedBut(
- "$PREFIX.messages.received.count",
- "$PREFIX.messages.received.bytes"
+ "$PREFIX.messages.received",
+ "$PREFIX.messages.received.payload.bytes"
)
}
}
@@ -171,8 +169,8 @@ object MicrometerMetricsTest : Spek({
val topicName1 = "PERF3GPP"
val topicName2 = "CALLTRACE"
- on("$PREFIX.messages.sent.count counter") {
- val counterName = "$PREFIX.messages.sent.count"
+ on("$PREFIX.messages.sent counter") {
+ val counterName = "$PREFIX.messages.sent"
it("should increment counter") {
cut.notifyMessageSent(routedMessage(topicName1))
@@ -182,14 +180,14 @@ object MicrometerMetricsTest : Spek({
}
verifyCountersAndTimersAreUnchangedBut(
counterName,
- "$PREFIX.messages.sent.topic.count",
+ "$PREFIX.messages.sent.topic",
"$PREFIX.messages.processing.time",
- "$PREFIX.messages.latency.time")
+ "$PREFIX.messages.latency")
}
}
- on("$PREFIX.messages.sent.topic.count counter") {
- val counterName = "$PREFIX.messages.sent.topic.count"
+ on("$PREFIX.messages.sent.topic counter") {
+ val counterName = "$PREFIX.messages.sent.topic"
it("should handle counters for different topics") {
cut.notifyMessageSent(routedMessage(topicName1))
@@ -219,14 +217,14 @@ object MicrometerMetricsTest : Spek({
}
verifyCountersAndTimersAreUnchangedBut(
counterName,
- "$PREFIX.messages.sent.topic.count",
- "$PREFIX.messages.sent.count",
- "$PREFIX.messages.latency.time")
+ "$PREFIX.messages.sent.topic",
+ "$PREFIX.messages.sent",
+ "$PREFIX.messages.latency")
}
}
- on("$PREFIX.messages.latency.time") {
- val counterName = "$PREFIX.messages.latency.time"
+ on("$PREFIX.messages.latency") {
+ val counterName = "$PREFIX.messages.latency"
val latencyMs = 1666L
it("should update timer") {
@@ -241,16 +239,16 @@ object MicrometerMetricsTest : Spek({
}
verifyCountersAndTimersAreUnchangedBut(
counterName,
- "$PREFIX.messages.sent.topic.count",
- "$PREFIX.messages.sent.count",
+ "$PREFIX.messages.sent.topic",
+ "$PREFIX.messages.sent",
"$PREFIX.messages.processing.time")
}
}
}
describe("notifyMessageDropped") {
- on("$PREFIX.messages.dropped.count counter") {
- val counterName = "$PREFIX.messages.dropped.count"
+ on("$PREFIX.messages.dropped counter") {
+ val counterName = "$PREFIX.messages.dropped"
it("should increment counter") {
cut.notifyMessageDropped(ROUTE_NOT_FOUND)
@@ -259,12 +257,12 @@ object MicrometerMetricsTest : Spek({
verifyCounter(counterName) {
assertThat(it.count()).isCloseTo(2.0, doublePrecision)
}
- verifyCountersAndTimersAreUnchangedBut(counterName, "$PREFIX.messages.dropped.cause.count")
+ verifyCountersAndTimersAreUnchangedBut(counterName, "$PREFIX.messages.dropped.cause")
}
}
- on("$PREFIX.messages.dropped.cause.count counter") {
- val counterName = "$PREFIX.messages.dropped.cause.count"
+ on("$PREFIX.messages.dropped.cause counter") {
+ val counterName = "$PREFIX.messages.dropped.cause"
it("should handle counters for different drop reasons") {
cut.notifyMessageDropped(ROUTE_NOT_FOUND)
@@ -283,8 +281,8 @@ object MicrometerMetricsTest : Spek({
}
describe("notifyClientConnected") {
- on("$PREFIX.connections.total.count counter") {
- val counterName = "$PREFIX.connections.total.count"
+ on("$PREFIX.connections counter") {
+ val counterName = "$PREFIX.connections"
it("should increment counter") {
cut.notifyClientConnected()
@@ -300,8 +298,8 @@ object MicrometerMetricsTest : Spek({
}
describe("notifyClientDisconnected") {
- on("$PREFIX.disconnections.count counter") {
- val counterName = "$PREFIX.disconnections.count"
+ on("$PREFIX.disconnections counter") {
+ val counterName = "$PREFIX.disconnections"
it("should increment counter") {
cut.notifyClientDisconnected()
@@ -318,8 +316,8 @@ object MicrometerMetricsTest : Spek({
describe("notifyClientRejected") {
- on("$PREFIX.clients.rejected.count") {
- val counterName = "$PREFIX.clients.rejected.count"
+ on("$PREFIX.clients.rejected") {
+ val counterName = "$PREFIX.clients.rejected"
it("should increment counter for each possible reason") {
cut.notifyClientRejected(INVALID_WIRE_FRAME_MARKER)
cut.notifyClientRejected(PAYLOAD_SIZE_EXCEEDED_IN_MESSAGE)
@@ -327,12 +325,12 @@ object MicrometerMetricsTest : Spek({
verifyCounter(counterName) {
assertThat(it.count()).isCloseTo(2.0, doublePrecision)
}
- verifyCountersAndTimersAreUnchangedBut(counterName, "$PREFIX.clients.rejected.cause.count")
+ verifyCountersAndTimersAreUnchangedBut(counterName, "$PREFIX.clients.rejected.cause")
}
}
- on("$PREFIX.clients.rejected.cause.count counter") {
- val counterName = "$PREFIX.clients.rejected.cause.count"
+ on("$PREFIX.clients.rejected.cause counter") {
+ val counterName = "$PREFIX.clients.rejected.cause"
it("should handle counters for different rejection reasons") {
cut.notifyClientRejected(INVALID_WIRE_FRAME_MARKER)
cut.notifyClientRejected(PAYLOAD_SIZE_EXCEEDED_IN_MESSAGE)
@@ -349,42 +347,8 @@ object MicrometerMetricsTest : Spek({
}
}
- describe("$PREFIX.messages.processing.count gauge") {
- val gaugeName = "$PREFIX.messages.processing.count"
-
- on("message traffic") {
- it("should calculate positive difference between sent and received messages") {
- cut.notifyMessageReceived(wireProtocolFrameWithPayloadSize(128))
- cut.notifyMessageReceived(wireProtocolFrameWithPayloadSize(256))
- cut.notifyMessageReceived(wireProtocolFrameWithPayloadSize(256))
- cut.notifyMessageSent(routedMessage("perf3gpp"))
-
- verifyGauge(gaugeName) {
- assertThat(it.value()).isCloseTo(2.0, doublePrecision)
- }
- }
-
- it("should calculate no difference between sent and received messages") {
- cut.notifyMessageSent(routedMessage("perf3gpp"))
- cut.notifyMessageSent(routedMessage("fault"))
-
- verifyGauge(gaugeName) {
- assertThat(it.value()).isCloseTo(0.0, doublePrecision)
- }
- }
-
- it("should calculate negative difference between sent and received messages") {
- cut.notifyMessageSent(routedMessage("fault"))
-
- verifyGauge(gaugeName) {
- assertThat(it.value()).isCloseTo(0.0, doublePrecision)
- }
- }
- }
- }
-
- describe("$PREFIX.connections.active.count gauge") {
- val gaugeName = "$PREFIX.connections.active.count"
+ describe("$PREFIX.connections.active gauge") {
+ val gaugeName = "$PREFIX.connections.active"
on("connection traffic") {
it("should calculate positive difference between connected and disconnected clients") {