Skip to content

Add trace logging to crypto-trading aggregate handlers#175

Merged
jwijgerd merged 2 commits into
mainfrom
copilot/add-info-logs-to-aggregates
Nov 16, 2025
Merged

Add trace logging to crypto-trading aggregate handlers#175
jwijgerd merged 2 commits into
mainfrom
copilot/add-info-logs-to-aggregates

Conversation

Copilot AI commented Nov 16, 2025

Copy link
Copy Markdown
Contributor

Add info-level logging to all @CommandHandler and @EventHandler methods in crypto-trading aggregates to enable message flow tracing.

Changes

  • Account.java: Added logger and logging to command handler
  • Wallet.java: Added logger and logging to 6 command handlers + 1 event handler (wallet lifecycle, balance operations, reservations)
  • CryptoMarket.java: Added logger and logging to 2 command handlers (market creation, order placement/execution)
  • OrderProcessManager.java: Added logger and logging to 3 command handlers + 6 event/bridge handlers (order process orchestration)

Example

@CommandHandler(produces = WalletCreditedEvent.class, errors = {...})
public Stream<DomainEvent> credit(@NotNull CreditWalletCommand cmd, @NotNull WalletStateV2 currentState) {
    log.info("CommandHandler: Crediting wallet for walletId={}, currency={}, amount={}", 
        cmd.id(), cmd.currency(), cmd.amount());
    // ... existing logic
}

@EventHandler(produces = BuyOrderPlacedEvent.class, errors = {})
public Stream<DomainEvent> handle(AmountReservedEvent event, OrderProcessManagerState state) {
    log.info("EventHandler: Amount reserved for userId={}, currency={}, amount={}, referenceId={}", 
        event.userId(), event.currency(), event.amount(), event.referenceId());
    // ... existing logic
}

Each log includes handler type prefix and relevant contextual data (IDs, amounts, currencies, references) for effective tracing. @EventSourcingHandler methods remain unchanged as they handle state reconstruction, not business flow.

Original prompt

in the crypto-trading test app, add info log statements in all the @eventhandler and @CommandHandler annotated methods of all the Aggregate (classes that implement the Aggregate interface). Add enough context to the log messages so it's easy to trace the message flow


✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.

…in all Aggregates

Co-authored-by: jwijgerd <914840+jwijgerd@users.noreply.github.com>
Copilot AI changed the title [WIP] Add info log statements to event and command handlers Add trace logging to crypto-trading aggregate handlers Nov 16, 2025
Copilot AI requested a review from jwijgerd November 16, 2025 18:39
@jwijgerd
jwijgerd marked this pull request as ready for review November 16, 2025 18:57
@jwijgerd
jwijgerd merged commit c9f5f52 into main Nov 16, 2025
5 of 7 checks passed
@jwijgerd
jwijgerd deleted the copilot/add-info-logs-to-aggregates branch November 16, 2025 19:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants