Skip to content

refactor: 주문 프로세서 인라인 계측 제거 (#119)#120

Merged
ohhalim merged 3 commits into
developfrom
refactor/order-processor-readability
Jun 15, 2026
Merged

refactor: 주문 프로세서 인라인 계측 제거 (#119)#120
ohhalim merged 3 commits into
developfrom
refactor/order-processor-readability

Conversation

@ohhalim

@ohhalim ohhalim commented Jun 15, 2026

Copy link
Copy Markdown
Owner

작업 내용

성능 분석용 계측 코드(stageRecorder.record() 래핑)를 제거해 주문 처리 흐름이 직접 읽히도록 정리했다.

변경 파일

  • SyncOrderProcessor: 모든 stageRecorder 래핑 제거
  • AcceptedOrderProcessor: 모든 stageRecorder 래핑 제거
  • AcceptedOrderService: 모든 stageRecorder 래핑 제거
  • OrderTransactionLifecycleRecorder: 미사용 클래스 삭제

배경

stageRecorder#52~#78 병목 분석 과정에서 market_lock_wait, transaction_begin, command_queue_wait 등 구간별 지연을 측정하기 위해 추가됐다.
분석이 완료되어 역할이 끝났고, 현재는 비즈니스 로직을 람다로 감싸 흐름을 읽기 어렵게 만들고 있어 제거한다.

정리 후 흐름 (AcceptedOrderService)

Long sequence = marketSequenceAllocator.nextSequence(market.getId());
Wallet wallet = orderAssetLockService.lockTakerWallet(currentUserId, command);
Order order = Order.accepted(...);
orderRepository.save(order);
orderAssetLockService.saveOrderLockLedger(orderLockLedger, command);
eventRecorder.recordOrderAccepted(order);

테스트

  • ./gradlew test 전체 통과

Summary by CodeRabbit

  • Refactor
    • Simplified internal order processing by removing transaction lifecycle metrics recording infrastructure
    • Streamlined order acceptance and processing workflows through simplified method signatures
    • Eliminated legacy stage-recording mechanisms across service components to improve code maintainability

ohhalim added 3 commits June 15, 2026 11:20
stageRecorder.record(...) 람다 래핑과 transactionMetrics 호출을
프로세서에서 제거하여 핵심 흐름(sequence→wallet lock→save→
match→settle→orderbook)이 순차적으로 읽히도록 정리한다.
계측에만 쓰이던 createStartedAt, processor side 파라미터도 제거.
측정은 OrderAssetLockService/MarketOrderCommandQueue 경계에 유지.
8단계 트랜잭션 미세 계측은 README 분석에 사용되지 않으며
프로세서 정리 후 참조처가 없어 삭제한다.
stageRecorder.record() 래핑을 제거해 접수 트랜잭션 흐름을 직접 읽히게 함
@coderabbitai

coderabbitai Bot commented Jun 15, 2026

Copy link
Copy Markdown

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: f0180e12-f6dd-4f41-af47-ee670e2911b6

📥 Commits

Reviewing files that changed from the base of the PR and between 92d814d and 0c93e70.

📒 Files selected for processing (5)
  • src/main/java/com/coinflow/order/service/AcceptedOrderService.java
  • src/main/java/com/coinflow/order/service/OrderService.java
  • src/main/java/com/coinflow/order/service/metrics/OrderTransactionLifecycleRecorder.java
  • src/main/java/com/coinflow/order/service/processor/AcceptedOrderProcessor.java
  • src/main/java/com/coinflow/order/service/processor/SyncOrderProcessor.java
💤 Files with no reviewable changes (1)
  • src/main/java/com/coinflow/order/service/metrics/OrderTransactionLifecycleRecorder.java

📝 Walkthrough

Walkthrough

Removes OrderCreateStageRecorder and OrderTransactionLifecycleRecorder instrumentation from the order processing pipeline. The OrderTransactionLifecycleRecorder class is deleted entirely. SyncOrderProcessor, AcceptedOrderProcessor, and AcceptedOrderService drop the metrics dependencies from their constructors and replace stageRecorder.record(...) wrappers with direct operations. AcceptedOrderProcessor.processAcceptedOrder loses its OrderSide parameter.

Changes

Stage Metrics Removal from Order Processing Pipeline

Layer / File(s) Summary
Delete OrderTransactionLifecycleRecorder
src/main/java/com/coinflow/order/service/metrics/OrderTransactionLifecycleRecorder.java, src/main/java/com/coinflow/order/service/processor/SyncOrderProcessor.java
Entire OrderTransactionLifecycleRecorder Spring component and its nested Metrics class are deleted; corresponding imports are removed from SyncOrderProcessor.
Refactor SyncOrderProcessor
src/main/java/com/coinflow/order/service/processor/SyncOrderProcessor.java
Removes stageRecorder and transactionLifecycleRecorder fields, constructor parameters, and assignments. process/executeInTransaction drop metrics/side parameters. createAndSaveOrder, recordAcceptedOrderWithoutTrade, and registerOrderBookSynchronization operate directly without stage wrappers; afterCommit-only synchronization replaces multi-hook callbacks.
Refactor AcceptedOrderProcessor
src/main/java/com/coinflow/order/service/processor/AcceptedOrderProcessor.java
Removes OrderCreateStageRecorder field and constructor parameter. processAcceptedOrder signature changes from (Market, OrderSide, Long) to (Market, Long). Match plan and settlement run directly; a new private registerOrderBookSynchronization helper centralizes afterCommit logic.
Clean up AcceptedOrderService and OrderService
src/main/java/com/coinflow/order/service/AcceptedOrderService.java, src/main/java/com/coinflow/order/service/OrderService.java
Removes OrderCreateStageRecorder import, field, constructor parameter, and wrappers from AcceptedOrderService; updates enqueueAcceptedOrder to call processAcceptedOrder(market, orderId) without side. Removes createStartedAt timestamp from OrderService.createOrder and drops that argument from syncOrderProcessor.process.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Possibly related issues

Possibly related PRs

  • ohhalim/CoinFlow#118: Modifies the same core classes (AcceptedOrderService, AcceptedOrderProcessor, SyncOrderProcessor) by refactoring transaction/synchronization behavior, with overlapping changes to TransactionSynchronization handling and processor constructor signatures.

Poem

🐇 Hop hop, the timers are gone today,
No more wrappers to slow down the way!
Stage by stage, we watched the clock spin—
Now we just process and let the trades win.
Less code to read, more orders to fill,
A leaner pipeline down Coinflow Hill! 🌸

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title "refactor: 주문 프로세서 인라인 계측 제거" (remove inline instrumentation from order processor) accurately describes the main objective of the changeset—removing instrumentation/stageRecorder code from order processors to improve readability.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch refactor/order-processor-readability

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@ohhalim ohhalim merged commit 9757521 into develop Jun 15, 2026
2 checks passed
@ohhalim ohhalim deleted the refactor/order-processor-readability branch June 15, 2026 03:12
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.

1 participant