aboutsummaryrefslogtreecommitdiffstats
path: root/sources/hv-collector-main/src/main
diff options
context:
space:
mode:
authorJakub Dudycz <jakub.dudycz@nokia.com>2018-12-17 16:03:10 +0100
committerJakub Dudycz <jakub.dudycz@nokia.com>2018-12-18 12:27:09 +0100
commit4ab95420e42f6df59bd4851eee41be6579bdbbe1 (patch)
tree09b81b772a4050d92c90bf6a6e09ecdf6c6db402 /sources/hv-collector-main/src/main
parent30488f1922f789c5b8e18934456968aa354c9671 (diff)
Add metrics for active connections count
* Fix and refactor gauges tests in MicrometerMetricsTests as they were not executing * Fix client disconnection handler in NettyTcpServer * Add metrics gauge and counters required to measure active connections Change-Id: I5620d398525c6859679cd5a49dc55a9fefd8b592 Signed-off-by: Jakub Dudycz <jakub.dudycz@nokia.com> Issue-ID: DCAEGEN2-1041
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.kt27
-rw-r--r--sources/hv-collector-main/src/main/kotlin/org/onap/dcae/collectors/veshv/main/servers/VesServer.kt2
2 files changed, 24 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 d35e17d6..288145aa 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
@@ -50,10 +50,13 @@ class MicrometerMetrics internal constructor(
private val receivedMsgCount = registry.counter(name(MESSAGES, RECEIVED, COUNT))
private val receivedMsgBytes = registry.counter(name(MESSAGES, RECEIVED, BYTES))
+ private val connectionsTotalCount = registry.counter(name(CONNECTIONS, TOTAL, COUNT))
+ private val disconnectionsCount = registry.counter(name(DISCONNECTIONS, COUNT))
+
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 sentCount = registry.counter(name(MESSAGES, SENT, COUNT))
private val sentToTopicCount = { topic: String ->
registry.counter(name(MESSAGES, SENT, TOPIC, COUNT), TOPIC, topic)
}.memoize<String, Counter>()
@@ -70,8 +73,13 @@ class MicrometerMetrics internal constructor(
init {
registry.gauge(name(MESSAGES, PROCESSING, COUNT), this) {
- (receivedMsgCount.count() - sentCountTotal.count()).coerceAtLeast(0.0)
+ (receivedMsgCount.count() - sentCount.count()).coerceAtLeast(0.0)
+ }
+
+ registry.gauge(name(CONNECTIONS, ACTIVE, COUNT), this) {
+ (connectionsTotalCount.count() - disconnectionsCount.count()).coerceAtLeast(0.0)
}
+
ClassLoaderMetrics().bindTo(registry)
JvmMemoryMetrics().bindTo(registry)
JvmGcMetrics().bindTo(registry)
@@ -79,7 +87,6 @@ class MicrometerMetrics internal constructor(
JvmThreadMetrics().bindTo(registry)
}
-
val metricsProvider = MicrometerPrometheusMetricsProvider(registry)
override fun notifyBytesReceived(size: Int) {
@@ -93,7 +100,7 @@ class MicrometerMetrics internal constructor(
override fun notifyMessageSent(msg: RoutedMessage) {
val now = Instant.now()
- sentCountTotal.increment()
+ sentCount.increment()
sentToTopicCount(msg.topic).increment()
processingTime.record(Duration.between(msg.message.wtpFrame.receivedAt, now))
@@ -110,11 +117,22 @@ class MicrometerMetrics internal constructor(
clientsRejectedCauseCount(cause.tag).increment()
}
+ override fun notifyClientConnected() {
+ connectionsTotalCount.increment()
+ }
+
+ override fun notifyClientDisconnected() {
+ disconnectionsCount.increment()
+ }
+
companion object {
val INSTANCE = MicrometerMetrics()
internal const val PREFIX = "hvves"
internal const val MESSAGES = "messages"
internal const val RECEIVED = "received"
+ internal const val DISCONNECTIONS = "disconnections"
+ 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"
@@ -125,6 +143,7 @@ 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 fun name(vararg name: String) = "$PREFIX.${name.joinToString(".")}"
diff --git a/sources/hv-collector-main/src/main/kotlin/org/onap/dcae/collectors/veshv/main/servers/VesServer.kt b/sources/hv-collector-main/src/main/kotlin/org/onap/dcae/collectors/veshv/main/servers/VesServer.kt
index b35dc53d..f9be546a 100644
--- a/sources/hv-collector-main/src/main/kotlin/org/onap/dcae/collectors/veshv/main/servers/VesServer.kt
+++ b/sources/hv-collector-main/src/main/kotlin/org/onap/dcae/collectors/veshv/main/servers/VesServer.kt
@@ -44,7 +44,7 @@ object VesServer : ServerStarter() {
config.maximumPayloadSizeBytes
).createVesHvCollectorProvider()
- return ServerFactory.createNettyTcpServer(config, collectorProvider)
+ return ServerFactory.createNettyTcpServer(config, collectorProvider, MicrometerMetrics.INSTANCE)
}
override fun serverStartedMessage(handle: ServerHandle) =