Skip to content
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
2 changes: 1 addition & 1 deletion console-framework-client-api/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
<parent>
<groupId>io.axoniq.console</groupId>
<artifactId>console-framework-client-parent</artifactId>
<version>1.9.0-SNAPSHOT</version>
<version>1.9.1-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,8 @@ object Routes {
const val STOP_REPORTS = "client-reporting-stop"
// Request to start sending reports again.
const val START_REPORTS = "client-reporting-start"
// Request to send a thread dump
const val THREAD_DUMP = "client-thread-dump"
}

object EventProcessor {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,8 @@ data class SupportedFeatures(
val logDirect: Boolean? = false,
/* Whether the client supports pause/resume of reports.*/
val pauseReports: Boolean? = false,
/* Whether the client supports thread dumps.*/
val threadDump: Boolean? = false
)

data class Versions(
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
package io.axoniq.console.framework.api

data class ThreadDumpEntry(
val instance: String,
val thread: String,
val trace: String,
)

data class ThreadDumpResult(
val timestamp: Long,
val threadDumpEntries: List<ThreadDumpEntry>
)

data class ThreadDumpQuery(
val instance: String
)
2 changes: 1 addition & 1 deletion console-framework-client-spring-boot-starter/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
<parent>
<groupId>io.axoniq.console</groupId>
<artifactId>console-framework-client-parent</artifactId>
<version>1.9.0-SNAPSHOT</version>
<version>1.9.1-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>

Expand Down
2 changes: 1 addition & 1 deletion console-framework-client/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
<parent>
<groupId>io.axoniq.console</groupId>
<artifactId>console-framework-client-parent</artifactId>
<version>1.9.0-SNAPSHOT</version>
<version>1.9.1-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@
import io.axoniq.console.framework.application.ApplicationMetricRegistry;
import io.axoniq.console.framework.application.ApplicationMetricReporter;
import io.axoniq.console.framework.application.ApplicationReportCreator;
import io.axoniq.console.framework.application.ApplicationThreadDumpProvider;
import io.axoniq.console.framework.application.RSocketThreadDumpResponder;
import io.axoniq.console.framework.client.AxoniqConsoleRSocketClient;
import io.axoniq.console.framework.client.ClientSettingsService;
import io.axoniq.console.framework.client.RSocketHandlerRegistrar;
Expand Down Expand Up @@ -218,11 +220,19 @@ public void configureModule(@NotNull Configurer configurer) {
dlqDiagnosticsWhitelist,
managementTaskExecutor
))
.registerComponent(ApplicationThreadDumpProvider.class,
c -> new ApplicationThreadDumpProvider()
)
.registerComponent(RSocketDlqResponder.class,
c -> new RSocketDlqResponder(
c.getComponent(DeadLetterManager.class),
c.getComponent(RSocketHandlerRegistrar.class)
))
.registerComponent(RSocketThreadDumpResponder.class,
c -> new RSocketThreadDumpResponder(
c.getComponent(ApplicationThreadDumpProvider.class),
c.getComponent(RSocketHandlerRegistrar.class)
))
.eventProcessing()
.registerDefaultHandlerInterceptor((
c, name) -> new AxoniqConsoleProcessorInterceptor(
Expand All @@ -248,6 +258,7 @@ public void configureModule(@NotNull Configurer configurer) {
c.getComponent(RSocketProcessorResponder.class);
c.getComponent(RSocketDlqResponder.class);
c.getComponent(HandlerMetricsRegistry.class);
c.getComponent(RSocketThreadDumpResponder.class);
});

configurer.onStart(() -> {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
package io.axoniq.console.framework.application
import io.axoniq.console.framework.api.ThreadDumpEntry
import io.axoniq.console.framework.api.ThreadDumpResult
import java.lang.management.ManagementFactory

class ApplicationThreadDumpProvider() {
private val threadBean = ManagementFactory.getThreadMXBean()

fun collectThreadDumps(instance: String): ThreadDumpResult {
val threadDumpEntries = threadBean.dumpAllThreads(true, true).map { threadInfo ->
ThreadDumpEntry(
instance = instance,
thread = threadInfo.threadName,
trace = threadInfo.toString()
)
}
return ThreadDumpResult(timestamp = System.currentTimeMillis(), threadDumpEntries = threadDumpEntries)
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
package io.axoniq.console.framework.application

import io.axoniq.console.framework.api.*
import io.axoniq.console.framework.client.RSocketHandlerRegistrar
import org.axonframework.lifecycle.Lifecycle
import org.axonframework.lifecycle.Phase
import org.slf4j.LoggerFactory

open class RSocketThreadDumpResponder (
private val applicationThreadDumpProvider: ApplicationThreadDumpProvider,
private val registrar: RSocketHandlerRegistrar
) : Lifecycle {
private val logger = LoggerFactory.getLogger(this::class.java)

override fun registerLifecycleHandlers(registry: Lifecycle.LifecycleRegistry) {
registry.onStart(Phase.EXTERNAL_CONNECTIONS, this::start)
}

fun start() {
registrar.registerHandlerWithPayload(
Routes.Management.THREAD_DUMP,
ThreadDumpQuery::class.java,
this::handleThreadDumpQuery
)
}

private fun handleThreadDumpQuery(query: ThreadDumpQuery): ThreadDumpResult {
logger.debug("Handling AxonIQ Console THREAD_DUMP query for request [{}]", query)
return applicationThreadDumpProvider.collectThreadDumps(query.instance)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,8 @@ class SetupPayloadCreator(
versions = versionInformation(),
upcasters = upcasters(),
features = SupportedFeatures(
heartbeat = true
heartbeat = true,
threadDump = true,
)
)
}
Expand Down
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@

<groupId>io.axoniq.console</groupId>
<artifactId>console-framework-client-parent</artifactId>
<version>1.9.0-SNAPSHOT</version>
<version>1.9.1-SNAPSHOT</version>

<modules>
<module>console-framework-client-api</module>
Expand Down
Loading