Skip to content

Commit

Permalink
Merge pull request #85 from AxonIQ/fix/demo-fixes
Browse files Browse the repository at this point in the history
Demo fixes
  • Loading branch information
CodeDrivenMitch authored Aug 29, 2024
2 parents 0ec08e1 + 044d80c commit be1199c
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
* 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.
Expand All @@ -21,21 +21,26 @@ import io.axoniq.console.framework.application.BusType
import io.axoniq.console.framework.application.MeasuringExecutorServiceDecorator
import io.axoniq.console.framework.messaging.SpanMatcherPredicateMap
import io.axoniq.console.framework.util.PostProcessHelper
import org.axonframework.commandhandling.CommandBus
import org.axonframework.common.ReflectionUtils
import org.axonframework.config.Configurer
import org.axonframework.config.ConfigurerModule
import org.axonframework.queryhandling.QueryBus
import java.lang.reflect.Field
import java.util.concurrent.ExecutorService

class AxoniqConsoleEnhancingConfigurerModule(private val spanMatcherPredicateMap: SpanMatcherPredicateMap) : ConfigurerModule {
override fun configureModule(configurer: Configurer) {
configurer.onInitialize { configuration ->
configuration.onStart {
enhance(configuration.spanFactory())
enhance(configuration.eventStore())
enhance(configuration.commandBus())
enhanceExecutorService(configuration.commandBus(), BusType.COMMAND, configuration.getComponent(ApplicationMetricRegistry::class.java))
val commandBus = configuration.commandBus().unwrapPossiblyDecoratedClass(CommandBus::class.java)
enhanceExecutorService(commandBus, BusType.COMMAND, configuration.getComponent(ApplicationMetricRegistry::class.java))
enhance(configuration.queryBus())
enhanceExecutorService(configuration.queryBus(), BusType.QUERY, configuration.getComponent(ApplicationMetricRegistry::class.java))
val queryBus = configuration.queryBus().unwrapPossiblyDecoratedClass(QueryBus::class.java)
enhanceExecutorService(queryBus, BusType.QUERY, configuration.getComponent(ApplicationMetricRegistry::class.java))
enhance(configuration.queryUpdateEmitter())
enhance(configuration.snapshotter())
enhance(configuration.deadlineManager())
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
* 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.
Expand Down Expand Up @@ -57,11 +57,13 @@ fun String.toSimpleName() = split(".").last()

fun UnitOfWork<*>.extractHandler(declaringClassName: String, processingGroup: String?): HandlerStatisticsMetricIdentifier? = try {
val isAggregate = message is CommandMessage<*> && isAggregateLifecycleActive()
val isProcessor = processingGroup != null

val processorName = AxoniqConsoleSpanFactory.currentSpan()?.processorName
val isProcessor = processorName != null

val component = when {
isAggregate -> (AggregateLifecycle.describeCurrentScope() as AggregateScopeDescriptor).type
isProcessor -> processingGroup ?: AxoniqConsoleSpanFactory.currentSpan()?.processorName
isProcessor -> createCombinedProcessorAndGroupIdentifier(processorName!!, processingGroup)
else -> declaringClassName
}
val type = when {
Expand All @@ -79,6 +81,17 @@ fun UnitOfWork<*>.extractHandler(declaringClassName: String, processingGroup: St
null
}

/**
* If the processing group name differents from the processor, we can assume multiple groups are under the same one.
* Using the [::] operator to separate the processor name from the processing group, we can filter in the UI.
*/
fun createCombinedProcessorAndGroupIdentifier(processorName: String, processingGroup: String?): String {
if (processingGroup == null || processingGroup == processorName) {
return processorName
}
return "$processorName::$processingGroup"
}


fun isAggregateLifecycleActive(): Boolean {
return try {
Expand Down

0 comments on commit be1199c

Please sign in to comment.