Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Reduce logging to the minimum required for operation #76

Merged
merged 1 commit into from
Jul 31, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -39,12 +39,12 @@ class ApplicationMetricReporter(
}

override fun onConnectedWithSettings(settings: ClientSettingsV2) {
logger.info { "Sending application information every ${settings.applicationReportInterval}ms to AxonIQ console" }
logger.debug { "Sending application information every ${settings.applicationReportInterval}ms to AxonIQ console" }
this.reportTask = executor.scheduleWithFixedDelay({
try {
this.report()
} catch (e: Exception) {
logger.error("Was unable to report application metrics: {}", e.message, e)
logger.debug("Was unable to report application metrics: {}", e.message, e)
}
}, 0, settings.applicationReportInterval, TimeUnit.MILLISECONDS)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@ class AxoniqConsoleRSocketClient(
private var rsocket: RSocket? = null
private var lastConnectionTry = Instant.EPOCH
private var connectionRetryCount = 0
private var hasConnected = false

init {
clientSettingsService.subscribeToSettings(heartbeatOrchestrator)
Expand Down Expand Up @@ -131,7 +132,7 @@ class AxoniqConsoleRSocketClient(
}
connectionRetryCount += 1
lastConnectionTry = Instant.now()
logger.info("Connecting to AxonIQ Console...")
logger.debug("Connecting to AxonIQ Console...")
connectSafely()
}
}
Expand All @@ -146,8 +147,11 @@ class AxoniqConsoleRSocketClient(
logger.info("Connection to AxonIQ Console set up successfully! Settings: $settings")
connectionRetryCount = 0
} catch (e: Exception) {
if(connectionRetryCount == 5) {
logger.error("Failed to connect to AxonIQ Console. Error: ${e.message}. Will keep trying to connect...")
}
disposeCurrentConnection()
logger.info("Failed to connect to AxonIQ Console", e)
logger.debug("Failed to connect to AxonIQ Console", e)
}
}

Expand Down Expand Up @@ -255,15 +259,15 @@ class AxoniqConsoleRSocketClient(
}

override fun onDisconnected() {
logger.info("Disconnected, stopping heartbeat tasks")
logger.info("This application has lost it's connection to AxonIQ Console. Reconnection will be automatically attempted.")
this.heartbeatSendTask?.cancel(true)
this.heartbeatCheckTask?.cancel(true)
}


private fun checkHeartbeats(heartbeatTimeout: Long) {
if (lastReceivedHeartbeat < Instant.now().minusMillis(heartbeatTimeout)) {
logger.info("Haven't received a heartbeat for {} seconds from AxonIQ Console. Reconnecting...", ChronoUnit.SECONDS.between(lastReceivedHeartbeat, Instant.now()))
logger.debug("Haven't received a heartbeat for {} seconds from AxonIQ Console. Reconnecting...", ChronoUnit.SECONDS.between(lastReceivedHeartbeat, Instant.now()))
disposeCurrentConnection()
}
}
Expand All @@ -286,7 +290,7 @@ class AxoniqConsoleRSocketClient(
}
.doOnError {
if (it.message?.contains("Access Denied") == true) {
logger.info("Was unable to send call to AxonIQ Console since authentication was incorrect!")
logger.error("Was unable to send call to AxonIQ Console since authentication was incorrect!")
}
}
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2022-2023. AxonIQ B.V.
* Copyright (c) 2022-2024. AxonIQ B.V.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -32,12 +32,12 @@ class RSocketHandlerRegistrar(
private val handlers: MutableList<RegisteredRsocketMessageHandler> = mutableListOf()

fun registerHandlerWithoutPayload(route: String, handler: () -> Any) {
logger.info("Registered AxonIQ Console handler for route {}", route)
logger.debug("Registered AxonIQ Console handler for route {}", route)
handlers.add(PayloadlessRegisteredRsocketMessageHandler(route, handler))
}

fun <T> registerHandlerWithPayload(route: String, payloadType: Class<T>, handler: (T) -> Any) {
logger.info("Registered AxonIQ Console handler for route {}", route)
logger.debug("Registered AxonIQ Console handler for route {}", route)
handlers.add(PayloadRegisteredRsocketMessageHandler(route, payloadType, handler))
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,12 +37,12 @@ class ServerProcessorReporter(
}

override fun onConnectedWithSettings(settings: ClientSettingsV2) {
logger.info { "Sending processor information every ${settings.processorReportInterval}ms to AxonIQ console" }
logger.debug { "Sending processor information every ${settings.processorReportInterval}ms to AxonIQ console" }
this.reportTask = executor.scheduleWithFixedDelay({
try {
this.report()
} catch (e: Exception) {
logger.error("Was unable to report processor metrics: {}", e.message, e)
logger.debug("Was unable to report processor metrics: {}", e.message, e)
}
}, 0, settings.processorReportInterval, TimeUnit.MILLISECONDS)
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2022-2023. AxonIQ B.V.
* Copyright (c) 2022-2024. AxonIQ B.V.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -88,13 +88,13 @@ class EventProcessorManager(
while (loop < 300) {
Thread.sleep(100)
if (processor.processingStatus().containsKey(segmentId)) {
logger.info("Processor [${processor.name}] successfully claimed segment [$segmentId] in approx. [${loop * 100}ms].")
logger.debug("Processor [${processor.name}] successfully claimed segment [$segmentId] in approx. [${loop * 100}ms].")
return true
}
loop++
}

logger.info("Processor [${processor.name}] failed to claim [$segmentId] in approx. [${loop * 100}ms].")
logger.debug("Processor [${processor.name}] failed to claim [$segmentId] in approx. [${loop * 100}ms].")
return false
}

Expand All @@ -106,13 +106,13 @@ class EventProcessorManager(
while (loop < 300) {
Thread.sleep(100)
if (!processor.processingStatus().containsKey(segmentId) || processor.processingStatus().get(segmentId)!!.isErrorState) {
logger.info("Processor [${processor.name}] successfully unclaimed segment [$segmentId] in approx. [${loop * 100}ms].")
logger.debug("Processor [${processor.name}] successfully unclaimed segment [$segmentId] in approx. [${loop * 100}ms].")
return true
}
loop++
}

logger.info("Processor [${processor.name}] failed to unclaim [$segmentId] in approx. [${loop * 100}ms].")
logger.debug("Processor [${processor.name}] failed to unclaim [$segmentId] in approx. [${loop * 100}ms].")
return false
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2022-2023. AxonIQ B.V.
* Copyright (c) 2022-2024. AxonIQ B.V.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -61,36 +61,36 @@ open class RSocketDlqResponder(
}

private fun handleDeadLetterQuery(request: DeadLetterRequest): DeadLetterResponse {
logger.info("Handling AxonIQ Console DEAD_LETTERS query for request [{}]", request)
logger.debug("Handling AxonIQ Console DEAD_LETTERS query for request [{}]", request)
return DeadLetterResponse(deadLetterManager.deadLetters(request.processingGroup, request.offset, request.size))
}

private fun handleSequenceSizeQuery(request: DeadLetterSequenceSize): Long {
logger.info(
logger.debug(
"Handling AxonIQ Console DEAD_LETTER_SEQUENCE_SIZE query for processing group [{}]",
request.processingGroup
)
return deadLetterManager.sequenceSize(request.processingGroup, request.sequenceIdentifier)
}

private fun handleDeleteSequenceCommand(request: DeadLetterSequenceDeleteRequest) {
logger.info(
logger.debug(
"Handling AxonIQ Console DELETE_FULL_DEAD_LETTER_SEQUENCE command for processing group [{}]",
request.processingGroup
)
deadLetterManager.delete(request.processingGroup, request.sequenceIdentifier)
}

private fun handleDeleteLetterCommand(request: DeadLetterSingleDeleteRequest) {
logger.info(
logger.debug(
"Handling AxonIQ Console DELETE_DEAD_LETTER_IN_SEQUENCE command for processing group [{}]",
request.processingGroup
)
deadLetterManager.delete(request.processingGroup, request.sequenceIdentifier, request.messageIdentifier)
}

private fun handleProcessCommand(request: DeadLetterProcessRequest): Boolean {
logger.info("Handling AxonIQ Console DEAD LETTERS query for processing group [{}]", request.processingGroup)
logger.debug("Handling AxonIQ Console DEAD LETTERS query for processing group [{}]", request.processingGroup)
return deadLetterManager.process(request.processingGroup, request.messageIdentifier)
}
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2022-2023. AxonIQ B.V.
* Copyright (c) 2022-2024. AxonIQ B.V.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -69,12 +69,12 @@ open class RSocketProcessorResponder(
}

private fun handleStart(processorName: String) {
logger.info("Handling AxonIQ Console START command for processor [{}]", processorName)
logger.debug("Handling AxonIQ Console START command for processor [{}]", processorName)
eventProcessorManager.start(processorName)
}

private fun handleStop(processorName: String) {
logger.info("Handling AxonIQ Console STOP command for processor [{}]", processorName)
logger.debug("Handling AxonIQ Console STOP command for processor [{}]", processorName)
eventProcessorManager.stop(processorName)
}

Expand All @@ -89,7 +89,7 @@ open class RSocketProcessorResponder(
}

fun handleRelease(processorSegmentId: ProcessorSegmentId) {
logger.info(
logger.debug(
"Handling AxonIQ Console RELEASE command for processor [{}] and segment [{}]",
processorSegmentId.processorName,
processorSegmentId.segmentId
Expand All @@ -98,7 +98,7 @@ open class RSocketProcessorResponder(
}

private fun handleSplit(processorSegmentId: ProcessorSegmentId): Boolean {
logger.info(
logger.debug(
"Handling AxonIQ Console SPLIT command for processor [{}] and segment [{}]",
processorSegmentId.processorName,
processorSegmentId.segmentId
Expand All @@ -108,7 +108,7 @@ open class RSocketProcessorResponder(
}

private fun handleMerge(processorSegmentId: ProcessorSegmentId): Boolean {
logger.info(
logger.debug(
"Handling AxonIQ Console MERGE command for processor [{}] and segment [{}]",
processorSegmentId.processorName,
processorSegmentId.segmentId
Expand All @@ -118,12 +118,12 @@ open class RSocketProcessorResponder(
}

private fun handleReset(resetDecision: ResetDecision) {
logger.info("Handling AxonIQ Console RESET command for processor [{}]", resetDecision.processorName)
logger.debug("Handling AxonIQ Console RESET command for processor [{}]", resetDecision.processorName)
eventProcessorManager.resetTokens(resetDecision)
}

fun handleClaim(processorSegmentId: ProcessorSegmentId): Boolean {
logger.info(
logger.debug(
"Handling AxonIQ Console CLAIM command for processor [{}] and segment [{}]",
processorSegmentId.processorName,
processorSegmentId.segmentId
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2022-2023. AxonIQ B.V.
* Copyright (c) 2022-2024. AxonIQ B.V.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -63,7 +63,7 @@ class AxoniqConsoleProcessorInterceptor(
}
}
} catch (e: Exception) {
logger.info("AxonIQ Console could not register metrics for processor $processorName", e)
logger.debug("AxonIQ Console could not register metrics for processor $processorName", e)
}
return interceptorChain.proceed()
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2022-2023. AxonIQ B.V.
* Copyright (c) 2022-2024. AxonIQ B.V.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -41,7 +41,7 @@ class AxoniqConsoleSpanFactory(private val spanMatcherPredicateMap: SpanMatcherP
try {
block(it)
} catch (e: Exception) {
logger.info("Was unable to report AxonIQ Console metrics", e)
logger.debug("Was unable to report AxonIQ Console metrics", e)
}
}
}
Expand Down Expand Up @@ -137,7 +137,7 @@ class AxoniqConsoleSpanFactory(private val spanMatcherPredicateMap: SpanMatcherP
}
}
} catch (e: Exception) {
logger.info("Could not report metrics for message $handlerMetricIdentifier", e)
logger.debug("Could not report metrics for message $handlerMetricIdentifier", e)
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ class HandlerMetricsRegistry(
}

override fun onConnectedWithSettings(settings: ClientSettingsV2) {
logger.info { "Sending handler information every ${settings.handlerReportInterval}ms to AxonIQ console" }
logger.debug { "Sending handler information every ${settings.handlerReportInterval}ms to AxonIQ console" }
this.reportTask = executor.scheduleAtFixedRate({
try {
val stats = getStats()
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2022-2023. AxonIQ B.V.
* Copyright (c) 2022-2024. AxonIQ B.V.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -75,7 +75,7 @@ fun UnitOfWork<*>.extractHandler(declaringClassName: String, processingGroup: St
message = message.toInformation(),
)
} catch (e: Exception) {
logger.warn("Could not extract handler from AxonIQ Console invocation. Skipping registration of message.", e)
logger.debug("Could not extract handler from AxonIQ Console invocation. Skipping registration of message.", e)
null
}

Expand Down
Loading