Repository navigation
feat(mindrecord): 실패 계측을 세우고 세 지점을 승격한다 (#964 1차) #1109
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
835c5a2
feat(mindrecord): 실패 계측을 세우고 두 지점을 승격한다 (#964 일부)
Sadturtleman 3cdd23e
Merge branch 'develop' into feat/964-mindrecord-error-reporting
1hyok ae337e0
Merge remote-tracking branch 'origin/develop' into feat/964-mindrecor…
Sadturtleman 82c6ea5
fix(mindrecord): 전달 조건 미충족은 텔레메트리로 올리지 않는다 (#964 리뷰)
Sadturtleman 9d79b3f
Merge remote-tracking branch 'origin/feat/964-mindrecord-error-report…
Sadturtleman File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
56 changes: 56 additions & 0 deletions
56
...lin/com/afternote/feature/mindrecord/presentation/reporting/MindRecordFailureReporting.kt
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,56 @@ | ||
| package com.afternote.feature.mindrecord.presentation.reporting | ||
|
|
||
| import com.afternote.core.common.reporting.ErrorReporter | ||
|
|
||
| /** | ||
| * 마음의 기록 흐름에서 실패가 발생한 지점 (#964). | ||
| * | ||
| * 이 모듈은 종전에 `Log.e` 도 `ErrorReporter` 도 0건이었다 — 실패가 UI 상태로만 흡수돼 | ||
| * 릴리즈에서 무슨 일이 있었는지 알 방법이 없었다. | ||
| * | ||
| * [reportingName] 은 리포팅 콘솔의 필터 값이다. 바꾸면 그 시점 이후 기록이 기존 이슈 그룹과 | ||
| * 끊겨 추이를 잃으므로, 단계 자체가 사라지지 않는 한 유지한다. | ||
| * | ||
| * 흐름마다 전용 enum 과 `<흐름>_stage` 키를 따로 둔다 — 키를 합치면 콘솔에서 한 키에 서로 | ||
| * 다른 값 목록이 섞인다(애프터노트·수신자·홈이 각각 자기 키를 쓰는 것과 같은 이유다). | ||
| */ | ||
| enum class MindRecordFailureStage( | ||
| val reportingName: String, | ||
| ) { | ||
| /** | ||
| * 임시저장 목록 조회. 사용자가 «쓰다 만 글» 을 찾으러 들어오는 화면이라, 실패하면 | ||
| * 작성물이 사라진 것처럼 보인다 — #519 가 실제로 그 형태의 결함이었다. | ||
| */ | ||
| DRAFT_LIST_LOAD("draft_list_load"), | ||
|
|
||
| /** | ||
| * 임시저장 삭제. 되돌릴 수 없는 동작이고, 부분 실패(일부만 지워짐)가 목록과 서버 상태를 | ||
| * 어긋나게 둔다. | ||
| */ | ||
| DRAFT_DELETE("draft_delete"), | ||
|
|
||
| /** | ||
| * 수신자가 받은 기록 열람. 유가족이 «지금 못 여는» 상황이라 읽기 실패지만 승격 가치가 | ||
| * 높다 — 재현할 계정도 조건도 우리 손에 없어 실기 QA 로 잡히지 않는다. | ||
| */ | ||
| RECEIVER_RECORD_LOAD("receiver_record_load"), | ||
| } | ||
|
|
||
| /** | ||
| * 마음의 기록 흐름의 handled 실패를 공통 키 규격으로 기록한다. | ||
| * | ||
| * 사용자 입력 오류·사용자 취소처럼 오류가 아닌 경로는 호출부에서 걸러 넘기지 않는다. | ||
| * 코루틴 취소는 [ErrorReporter] 가 창구에서 거르므로 호출부가 다시 막지 않아도 된다 — | ||
| * 이 모듈의 저장소는 `runCatching` 으로 취소까지 실패로 바꿔 돌려주는 자리가 있다. | ||
| */ | ||
| fun ErrorReporter.recordMindRecordFailure( | ||
| stage: MindRecordFailureStage, | ||
| throwable: Throwable, | ||
| ) { | ||
| recordFailure( | ||
| throwable = throwable, | ||
| attributes = mapOf(KEY_MIND_RECORD_STAGE to stage.reportingName), | ||
| ) | ||
| } | ||
|
|
||
| private const val KEY_MIND_RECORD_STAGE = "mind_record_stage" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
63 changes: 63 additions & 0 deletions
63
...com/afternote/feature/mindrecord/presentation/reporting/MindRecordFailureReportingTest.kt
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,63 @@ | ||
| package com.afternote.feature.mindrecord.presentation.reporting | ||
|
|
||
| import org.junit.Assert.assertEquals | ||
| import org.junit.Assert.assertTrue | ||
| import org.junit.Test | ||
| import java.io.IOException | ||
| import kotlin.coroutines.cancellation.CancellationException | ||
|
|
||
| /** | ||
| * 마음의 기록 계측 규격 (#964). | ||
| * | ||
| * 이 모듈은 종전에 `Log.e` 도 `ErrorReporter` 도 0건이라, 실패가 UI 상태로만 흡수되고 | ||
| * 릴리즈에서는 아무 흔적도 남지 않았다. | ||
| */ | ||
| class MindRecordFailureReportingTest { | ||
| private val reporter = RecordingErrorReporter() | ||
|
|
||
| @Test | ||
| fun `단계는 전용 키로 기록된다`() { | ||
| // 키를 다른 흐름과 합치면 콘솔에서 한 키에 서로 다른 값 목록이 섞인다. | ||
| reporter.recordMindRecordFailure(MindRecordFailureStage.DRAFT_LIST_LOAD, IOException("offline")) | ||
|
|
||
| val recorded = reporter.failures.single() | ||
| assertEquals("draft_list_load", recorded.attributes["mind_record_stage"]) | ||
| } | ||
|
|
||
| @Test | ||
| fun `예외 원문은 콘솔로 나가지 않는다`() { | ||
| // 서버 응답 본문이 message 에 그대로 담겨 오는 경우가 있어 창구가 redact 한다. | ||
| reporter.recordMindRecordFailure( | ||
| MindRecordFailureStage.RECEIVER_RECORD_LOAD, | ||
| IllegalStateException("user@example.com 의 열람 권한이 없습니다"), | ||
| ) | ||
|
|
||
| val recorded = reporter.failures.single() | ||
| assertTrue( | ||
| "예외 원문이 그대로 실렸다: ${recorded.throwable.message}", | ||
| recorded.throwable.message?.contains("user@example.com") != true, | ||
| ) | ||
| // 대신 타입은 남아야 어떤 실패인지 가릴 수 있다. | ||
| assertEquals( | ||
| "java.lang.IllegalStateException", | ||
| recorded.attributes.values.firstOrNull { it.startsWith("java.lang.IllegalStateException") }, | ||
| ) | ||
| } | ||
|
|
||
| @Test | ||
| fun `코루틴 취소는 기록하지 않는다`() { | ||
| // 이 모듈의 저장소는 runCatching 으로 취소까지 실패로 바꿔 돌려준다 — 화면 이탈이 | ||
| // 잦은 목록에서 그 취소가 전부 기록되면 보관 한도(최근 8건)를 잡음이 채운다. | ||
| reporter.recordMindRecordFailure(MindRecordFailureStage.DRAFT_LIST_LOAD, CancellationException("화면 이탈")) | ||
|
|
||
| assertTrue("취소가 기록됐다", reporter.failures.isEmpty()) | ||
| } | ||
|
|
||
| @Test | ||
| fun `단계 이름은 서로 겹치지 않는다`() { | ||
| // reportingName 은 콘솔 필터 값이라 겹치면 다른 화면의 실패가 한 그룹으로 묶인다. | ||
| val names = MindRecordFailureStage.entries.map { it.reportingName } | ||
|
|
||
| assertEquals(names.size, names.toSet().size) | ||
| } | ||
| } |
28 changes: 28 additions & 0 deletions
28
.../kotlin/com/afternote/feature/mindrecord/presentation/reporting/RecordingErrorReporter.kt
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,28 @@ | ||
| package com.afternote.feature.mindrecord.presentation.reporting | ||
|
|
||
| import com.afternote.core.common.reporting.ErrorReporter | ||
|
|
||
| /** | ||
| * 기록된 실패를 들여다보는 테스트용 [ErrorReporter]. | ||
| * | ||
| * `writeFailure` 를 구현한다 — `recordFailure` 는 인터페이스가 취소 제외·원문 redact 를 | ||
| * 처리한 뒤 이 함수를 부르므로, 그 정책까지 함께 태워야 실제 동작과 같아진다. | ||
| */ | ||
| class RecordingErrorReporter : ErrorReporter { | ||
| data class Failure( | ||
| val throwable: Throwable, | ||
| val attributes: Map<String, String>, | ||
| ) | ||
|
|
||
| val failures = mutableListOf<Failure>() | ||
|
|
||
| val stages: List<String> | ||
| get() = failures.mapNotNull { it.attributes["mind_record_stage"] } | ||
|
|
||
| override fun writeFailure( | ||
| throwable: Throwable, | ||
| attributes: Map<String, String>, | ||
| ) { | ||
| failures += Failure(throwable, attributes) | ||
| } | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[normal] 같은 이름·같은 역할의 클래스가 이미 세 벌 있다.
feature/home/presentation/.../HomeTabViewModelTest.kt:489—private class RecordingErrorReporterfeature/receiver/presentation/.../ReceiverHomeViewModelTest.kt:201— 같은 이름feature/receiver/presentation/.../ReceiverMemorialPlaylistViewModelTest.kt:90— 같은 이름여기에
FakeErrorReporter3벌 ·NoopErrorReporter4벌을 더하면ErrorReporter테스트 더블이 레포에 열 벌 넘게 흩어진다. 이 파일이 그중 처음으로 파일 단위로 분리된 공개 클래스라 오히려 공용화하기 좋은 자리다.core:common에testFixtures로 올리면 세 모듈이 같은 한 벌을 쓸 수 있다 — 마침 #1040 이 마음의 기록 fake 를testFixtures로 모으는 중이라 방향도 같다. 이 PR 에서 당장 하지 않더라도, 새 벌을 늘리는 대신 그 통합에 얹는 쪽을 권한다.(
writeFailure를 구현해 인터페이스 정책까지 태운 것은 위 세 벌보다 정확하다 — 공용화한다면 이 구현이 기준이 되는 편이 맞다.)