diff options
author | Filip Krzywka <filip.krzywka@nokia.com> | 2018-12-17 14:25:56 +0100 |
---|---|---|
committer | Filip Krzywka <filip.krzywka@nokia.com> | 2018-12-18 09:15:59 +0100 |
commit | 8c180a2101f54d7cc0e3527c2bbe23390eea9cef (patch) | |
tree | fe6558ebd50df30f65094ac046d77725e50da361 /sources/hv-collector-main/src/main | |
parent | d55f5c0c3df4b2ea136100e61424810ede749778 (diff) |
Add metric for rejected clients count
- renamed few counters to be more verbose about what they count
- removed not needed 'total' suffix in metrics name
Change-Id: I6be0201e5f39f1298706c536b12410413d49df19
Issue-ID: DCAEGEN2-1043
Signed-off-by: Filip Krzywka <filip.krzywka@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.kt | 36 |
1 files changed, 25 insertions, 11 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 259fa037..f060426d 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 @@ -31,6 +31,7 @@ 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.RoutedMessage import java.time.Duration import java.time.Instant @@ -47,18 +48,24 @@ class MicrometerMetrics internal constructor( 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 sentCountTotal = registry.counter(name(MESSAGES, SENT, COUNT, TOTAL)) - private val droppedCountTotal = registry.counter(name(MESSAGES, DROPPED, COUNT, TOTAL)) - private val sentCount = { topic: String -> - registry.counter(name(MESSAGES, SENT, COUNT, TOPIC), TOPIC, topic) + private val sentCountTotal = registry.counter(name(MESSAGES, SENT, COUNT)) + private val sentToTopicCount = { topic: String -> + registry.counter(name(MESSAGES, SENT, TOPIC, COUNT), TOPIC, topic) }.memoize<String, Counter>() - private val droppedCount = { cause: String -> - registry.counter(name(MESSAGES, DROPPED, COUNT, CAUSE), CAUSE, cause) + private val droppedCount = registry.counter(name(MESSAGES, DROPPED, COUNT)) + private val droppedCauseCount = { cause: String -> + 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) + }.memoize<String, Counter>() + init { registry.gauge(name(MESSAGES, PROCESSING, COUNT), this) { (receivedMsgCount.count() - sentCountTotal.count()).coerceAtLeast(0.0) @@ -70,6 +77,7 @@ class MicrometerMetrics internal constructor( JvmThreadMetrics().bindTo(registry) } + val metricsProvider = MicrometerPrometheusMetricsProvider(registry) override fun notifyBytesReceived(size: Int) { @@ -83,13 +91,18 @@ class MicrometerMetrics internal constructor( override fun notifyMessageSent(msg: RoutedMessage) { sentCountTotal.increment() - sentCount(msg.topic).increment() + sentToTopicCount(msg.topic).increment() processingTime.record(Duration.between(msg.message.wtpFrame.receivedAt, Instant.now())) } override fun notifyMessageDropped(cause: MessageDropCause) { - droppedCountTotal.increment() - droppedCount(cause.tag).increment() + droppedCount.increment() + droppedCauseCount(cause.tag).increment() + } + + override fun notifyClientRejected(cause: ClientRejectionCause) { + clientsRejectedCount.increment() + clientsRejectedCauseCount(cause.tag).increment() } companion object { @@ -102,10 +115,11 @@ class MicrometerMetrics internal constructor( internal const val DATA = "data" internal const val SENT = "sent" internal const val PROCESSING = "processing" + internal const val CAUSE = "cause" + internal const val CLIENTS = "clients" + internal const val REJECTED = "rejected" internal const val TOPIC = "topic" internal const val DROPPED = "dropped" - internal const val CAUSE = "cause" - internal const val TOTAL = "total" internal const val TIME = "time" fun name(vararg name: String) = "$PREFIX.${name.joinToString(".")}" } |