티스토리 뷰

12.1 Reactor에서의 디버깅 방법

  • 비동기, 선언형 프로그래밍 방식의 Reactor는 디버깅이 쉽지 않음
12.1.1 Debug Mode를 사용한 디버깅
  • Hooks.onOperatorDebug()를 통해 디버그 모드 활성화 (Example12_1)
  • 체인상에서 에러가 시작된 지점부터 에러 전파 상태를 표시
  • 비용이 많이 드는 동작
    • 스택트레이스 캡처
    • 에러가 발생한 Assembly의 스택트레이스를 원본 스택트레이스 중간에 끼워 넣음
    • 운영 환경에서는 reactor.tools.agent.ReactorDebugAgent 이용
  • IntelliJ에서는 [Enable Reactor Debug mode]에서 Hooks.onOperatorDebug() 또는 ReactorDebugAgent.init() 중 택1 하여 활성화 가능
12.1.2 checkpoint( ) Operator를 사용한 디버깅
  • checkpoint() Operator를 사용하여 특정 Operator 체인 내의 스택트레이스를 캡처

    • 각 Operator 체인에 checkpoint()를 추가한 후, 범위를 좁혀 가면서 단계적으로 에러 발생 지점을 찾는다.
  • Traceback 출력 (Example12_2)

    .checkpoint()
  • Traceback 출력 없이 식별자를 포함한 Description 출력 (Example12_4)

    .checkpoint("Example12_4.zipWith.checkpoint")
  • Traceback과 Description 모두 출력 (Example12_5)

    • forceStackTrace=true로 지정
      .checkpoint("Example12_4.zipWith.checkpoint", true)
12.1.3 log( ) Operator를 사용한 디버깅 
  • log() Operator를 추가하여 Reactor Signal 출력 (Example12_7)

'공부 > 스프링으로 시작하는 리액티브 프로그래밍' 카테고리의 다른 글

Chapter 11 | Context  (0) 2023.07.21
Chapter 10 | Scheduler  (0) 2023.07.21
Chapter 09 | Sinks  (0) 2023.07.21
Chapter 08 | Backpressure  (0) 2023.07.21
Chapter 07 | Cold Sequence와 Hot Sequence  (0) 2023.07.21
댓글