메트릭 태그 키셋 정합성 통일 및 등록 팩토리 도입 (ai.client.calls · async.task.failures) - #261
Merged
Conversation
ckdals4600
force-pushed
the
feature/#259-unify-aiclientcalls
branch
4 times, most recently
from
July 16, 2026 17:11
13ecb32 to
3415c75
Compare
📊 코드 커버리지 리포트
|
Goder-0
reviewed
Jul 21, 2026
ckdals4600
force-pushed
the
feature/#259-unify-aiclientcalls
branch
from
July 21, 2026 12:53
3415c75 to
89adb22
Compare
Goder-0
approved these changes
Jul 24, 2026
동일 메트릭 이름에 태그 키셋이 갈리는 문제를 교정하고 재발을 구조적으로 차단. - ai.client.calls: RagAnswerClient 에 operation=generate 추가로 4개 클라이언트 전부 client·operation·result 키셋으로 통일 - async.task.failures: task(계열)·action(동작) 2차원으로 정렬 (summary-generate → summary/GENERATE, summary-enqueue → summary/ENQUEUE) - 등록 팩토리 도입(AiClientMetrics, AsyncTaskMetrics): 태그 키셋을 메서드 시그니처로 고정해 컴파일 단계 강제, 값은 enum 으로 고정 - 관측 레이어 정합: AsyncTaskFinalFailure 의 action 조건분기 제거, 대시보드 패널4 sum by (task, action) 전환 - link-sync 는 void 반환이라 result=empty 미등록(의도적, 값 도메인은 도메인별) - MetricsTagConsistencyTest: 전 조합 키셋 수렴 검증
ckdals4600
force-pushed
the
feature/#259-unify-aiclientcalls
branch
from
July 27, 2026 13:48
89adb22 to
dbcbc46
Compare
ckdals4600
added a commit
that referenced
this pull request
Jul 27, 2026
Counter.builder 직접 호출을 global.metrics 패키지 외부에서 금지하는 ArchUnit 규칙 추가. 팩토리(#261)를 우회한 등록이 컴파일·기존 테스트를 통과하며 태그 키셋 불일치를 재발시키는 것을 구조적으로 차단. - archunit-junit5 의존성 추가 (testImplementation) - 규칙은 main 코드만 검사 (DoNotIncludeTests)
ckdals4600
added a commit
that referenced
this pull request
Jul 27, 2026
Counter.builder 직접 호출을 global.metrics 패키지 외부에서 금지하는 ArchUnit 규칙 추가. 팩토리(#261)를 우회한 등록이 컴파일·기존 테스트를 통과하며 태그 키셋 불일치를 재발시키는 것을 구조적으로 차단. - archunit-junit5 의존성 추가 (testImplementation) - 규칙은 main 코드만 검사 (DoNotIncludeTests)
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
관련 이슈
PR 설명
동일한 메트릭 이름을 여러 지점에서 등록하는데 태그 키셋이 일치하지 않는 문제를 교정하고, 재발을 구조적으로 차단하기 위해 메트릭 등록 전용 팩토리를 도입했습니다. (#256 PR 리뷰에서 도출)
배경
ai.client.calls:RagAnswerClient만operation태그 없이client·result로 등록되어, 같은 메트릭을 쓰는 나머지 클라이언트(client·operation·result)와 키셋이 갈렸습니다.async.task.failures:LinkSyncEventListener만task·action, 나머지(SummaryWorker,LinkEventListener)는task만 사용해 키셋이 갈렸습니다.async.task.failures는 이미 관측 레이어까지 오염된 상태였습니다 — 알림 룰 description 이{{ if $labels.action }}조건문으로 태그 유무를 방어하고 있었고, 대시보드의sum by (task, action)패널에서 action 없는 시계열은 빈 라벨로 표시됐습니다.변경 사항
1.
ai.client.calls— 키셋을client·operation·result로 통일RagAnswerClient에operation=generate추가 (나머지 클라이언트는 이미 정합)2.
async.task.failures— 키셋을task·action으로 통일task(작업 계열)와action(그 안의 동작)은 의미가 다른 차원이므로 문자열로 뭉치지 않고 2차원 라벨로 정렬했습니다.SummaryWorkertask=summary-generatetask=summary,action=GENERATELinkEventListenertask=summary-enqueuetask=summary,action=ENQUEUELinkSyncEventListenertask=link-sync,action=CREATE/UPDATE/DELETE3. 메트릭 등록 팩토리 도입 (재발 방지)
AiClientMetrics.counter(registry, Client, Operation, Result)/AsyncTaskMetrics.failureCounter(registry, Task, Action)를 추가하고, 7개 등록 지점 전부를 팩토리 경유로 전환했습니다.ExternalApiLogger)의client=/operation=값이 같은 enum 에서 나와 자동으로 일치합니다.4. 관측 레이어 정합
AsyncTaskFinalFailure: action 이 항상 존재하게 되어{{ if $labels.action }}조건 분기를 제거하고 summary/description 에 action 을 무조건 표기.sum by (task)→sum by (task, action), legend{{task}} / {{action}}로 변경 (패널 5는 기존 쿼리 유지).5. 값 도메인에 대한 의도적 결정 — link-sync 에
empty미추가RagLinkSyncClient는void반환이라 '빈 응답' 결과가 도메인에 존재하지 않으므로,result값은success/failure2종만 사용합니다(코드 주석으로 명시).success+failure로 정상 계산되므로 왜곡이 없습니다.6. 테스트
MetricsTagConsistencyTest추가: 두 팩토리의 모든 enum 조합을 등록해 태그 키셋이 단일 키셋으로 수렴하는지, 동일 태그 재등록 시 같은 미터가 반환되는지 검증합니다. 팩토리를 우회하지 않는 한 키셋 일탈이 테스트로 차단됩니다.참고
Counter.builder직접 호출 금지를 아키텍처 테스트(ArchUnit)로 강제하는 것은 후속 이슈로 분리합니다.async.task.failures의 기존task값이 변경되어 Prometheus 기존 시계열과 단절됩니다. 운영 초기이므로 지금 바로잡는 비용이 가장 낮다고 판단했습니다.