From 8c180a2101f54d7cc0e3527c2bbe23390eea9cef Mon Sep 17 00:00:00 2001 From: Filip Krzywka Date: Mon, 17 Dec 2018 14:25:56 +0100 Subject: 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 --- .../dcae/collectors/veshv/boundary/adapters.kt | 2 + .../dcae/collectors/veshv/impl/VesHvCollector.kt | 5 +- .../veshv/impl/wire/WireFrameException.kt | 2 +- .../collectors/veshv/model/MessageDropCause.kt | 29 ------------ .../veshv/model/stream_interruption_cause.kt | 53 ++++++++++++++++++++++ 5 files changed, 60 insertions(+), 31 deletions(-) delete mode 100644 sources/hv-collector-core/src/main/kotlin/org/onap/dcae/collectors/veshv/model/MessageDropCause.kt create mode 100644 sources/hv-collector-core/src/main/kotlin/org/onap/dcae/collectors/veshv/model/stream_interruption_cause.kt (limited to 'sources/hv-collector-core/src/main/kotlin') diff --git a/sources/hv-collector-core/src/main/kotlin/org/onap/dcae/collectors/veshv/boundary/adapters.kt b/sources/hv-collector-core/src/main/kotlin/org/onap/dcae/collectors/veshv/boundary/adapters.kt index 1334738a..61d28c2b 100644 --- a/sources/hv-collector-core/src/main/kotlin/org/onap/dcae/collectors/veshv/boundary/adapters.kt +++ b/sources/hv-collector-core/src/main/kotlin/org/onap/dcae/collectors/veshv/boundary/adapters.kt @@ -21,6 +21,7 @@ package org.onap.dcae.collectors.veshv.boundary import org.onap.dcae.collectors.veshv.domain.WireFrameMessage import org.onap.dcae.collectors.veshv.model.ClientContext +import org.onap.dcae.collectors.veshv.model.ClientRejectionCause import org.onap.dcae.collectors.veshv.model.CollectorConfiguration import org.onap.dcae.collectors.veshv.model.MessageDropCause import org.onap.dcae.collectors.veshv.model.RoutedMessage @@ -35,6 +36,7 @@ interface Metrics { fun notifyMessageReceived(msg: WireFrameMessage) fun notifyMessageSent(msg: RoutedMessage) fun notifyMessageDropped(cause: MessageDropCause) + fun notifyClientRejected(cause: ClientRejectionCause) } @FunctionalInterface diff --git a/sources/hv-collector-core/src/main/kotlin/org/onap/dcae/collectors/veshv/impl/VesHvCollector.kt b/sources/hv-collector-core/src/main/kotlin/org/onap/dcae/collectors/veshv/impl/VesHvCollector.kt index 51f894d3..5c3f339c 100644 --- a/sources/hv-collector-core/src/main/kotlin/org/onap/dcae/collectors/veshv/impl/VesHvCollector.kt +++ b/sources/hv-collector-core/src/main/kotlin/org/onap/dcae/collectors/veshv/impl/VesHvCollector.kt @@ -27,6 +27,7 @@ import org.onap.dcae.collectors.veshv.domain.WireFrameMessage import org.onap.dcae.collectors.veshv.impl.adapters.ClientContextLogging.handleReactiveStreamError import org.onap.dcae.collectors.veshv.impl.wire.WireChunkDecoder import org.onap.dcae.collectors.veshv.model.ClientContext +import org.onap.dcae.collectors.veshv.model.ClientRejectionCause 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 @@ -60,7 +61,9 @@ internal class VesHvCollector( .transform(::decodeProtobufPayload) .transform(::filterInvalidProtobufMessages) .transform(::routeMessage) - .onErrorResume { logger.handleReactiveStreamError(clientContext, it) } + .onErrorResume { + metrics.notifyClientRejected(ClientRejectionCause.fromThrowable(it)) + logger.handleReactiveStreamError(clientContext, it) } .doFinally { releaseBuffersMemory() } .then() diff --git a/sources/hv-collector-core/src/main/kotlin/org/onap/dcae/collectors/veshv/impl/wire/WireFrameException.kt b/sources/hv-collector-core/src/main/kotlin/org/onap/dcae/collectors/veshv/impl/wire/WireFrameException.kt index 83a7cd85..81845400 100644 --- a/sources/hv-collector-core/src/main/kotlin/org/onap/dcae/collectors/veshv/impl/wire/WireFrameException.kt +++ b/sources/hv-collector-core/src/main/kotlin/org/onap/dcae/collectors/veshv/impl/wire/WireFrameException.kt @@ -25,5 +25,5 @@ import org.onap.dcae.collectors.veshv.domain.WireFrameDecodingError * @author Piotr Jaszczyk * @since June 2018 */ -class WireFrameException(error: WireFrameDecodingError) +class WireFrameException(val error: WireFrameDecodingError) : Exception("${error::class.simpleName}: ${error.message}") diff --git a/sources/hv-collector-core/src/main/kotlin/org/onap/dcae/collectors/veshv/model/MessageDropCause.kt b/sources/hv-collector-core/src/main/kotlin/org/onap/dcae/collectors/veshv/model/MessageDropCause.kt deleted file mode 100644 index af43ae67..00000000 --- a/sources/hv-collector-core/src/main/kotlin/org/onap/dcae/collectors/veshv/model/MessageDropCause.kt +++ /dev/null @@ -1,29 +0,0 @@ -/* - * ============LICENSE_START======================================================= - * dcaegen2-collectors-veshv - * ================================================================================ - * Copyright (C) 2018 NOKIA - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= - */ -package org.onap.dcae.collectors.veshv.model - -/** - * @author Jakub Dudycz - * @since December 2018 - */ -enum class MessageDropCause(val tag: String) { - ROUTE_NOT_FOUND("routing"), - INVALID_MESSAGE("invalid") -} diff --git a/sources/hv-collector-core/src/main/kotlin/org/onap/dcae/collectors/veshv/model/stream_interruption_cause.kt b/sources/hv-collector-core/src/main/kotlin/org/onap/dcae/collectors/veshv/model/stream_interruption_cause.kt new file mode 100644 index 00000000..836eab53 --- /dev/null +++ b/sources/hv-collector-core/src/main/kotlin/org/onap/dcae/collectors/veshv/model/stream_interruption_cause.kt @@ -0,0 +1,53 @@ +/* + * ============LICENSE_START======================================================= + * dcaegen2-collectors-veshv + * ================================================================================ + * Copyright (C) 2018 NOKIA + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ +package org.onap.dcae.collectors.veshv.model + +import org.onap.dcae.collectors.veshv.domain.InvalidWireFrameMarker +import org.onap.dcae.collectors.veshv.domain.PayloadSizeExceeded +import org.onap.dcae.collectors.veshv.impl.wire.WireFrameException + +/** + * @author Jakub Dudycz + * @since December 2018 + */ +enum class MessageDropCause(val tag: String) { + ROUTE_NOT_FOUND("routing"), + INVALID_MESSAGE("invalid") +} + +enum class ClientRejectionCause(val tag: String) { + INVALID_WIRE_FRAME_MARKER("invalid_marker"), + PAYLOAD_SIZE_EXCEEDED_IN_MESSAGE("too_big_payload"), + UNEXPECTED_STREAM_ERROR("unexpected"); + + companion object { + fun fromThrowable(err: Throwable): ClientRejectionCause = + when (err) { + is WireFrameException -> fromWireFrameException(err) + else -> UNEXPECTED_STREAM_ERROR + } + + private fun fromWireFrameException(err: WireFrameException) = when (err.error) { + is InvalidWireFrameMarker -> INVALID_WIRE_FRAME_MARKER + is PayloadSizeExceeded -> PAYLOAD_SIZE_EXCEEDED_IN_MESSAGE + else -> UNEXPECTED_STREAM_ERROR + } + } +} -- cgit 1.2.3-korg