feat(ollama): telemetry 3 events — unreachable/recovered/recheck_manual (#1 v0.2.3)

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
altair823
2026-05-02 01:30:26 +09:00
parent 12681e431c
commit a68ffe0aeb
6 changed files with 129 additions and 8 deletions

View File

@@ -20,6 +20,9 @@ interface DailyRow {
empty_trash: number;
expired_banner_shown: number;
expired_batch_trash: number;
ollama_unreachable: number;
ollama_recovered: number;
ollama_recheck_manual: number;
}
export interface StatsResult {
@@ -38,6 +41,9 @@ export function aggregateStats(events: TelemetryEvent[], generatedAt: Date): Sta
let restoreCount = 0;
let expiredBannerShownCandidatesSum = 0;
let expiredBatchTrashCountSum = 0;
let ollamaDowntimeSum = 0;
let ollamaRecoveredCount = 0;
let ollamaRecheckManualCount = 0;
for (const ev of events) {
const day = kstDate(ev.ts);
let row = byDay.get(day);
@@ -46,7 +52,8 @@ export function aggregateStats(events: TelemetryEvent[], generatedAt: Date): Sta
date: day,
capture: 0, ai_succeeded: 0, ai_failed: 0,
trash: 0, restore: 0, permanent_delete: 0, empty_trash: 0,
expired_banner_shown: 0, expired_batch_trash: 0
expired_banner_shown: 0, expired_batch_trash: 0,
ollama_unreachable: 0, ollama_recovered: 0, ollama_recheck_manual: 0
};
byDay.set(day, row);
}
@@ -75,6 +82,15 @@ export function aggregateStats(events: TelemetryEvent[], generatedAt: Date): Sta
} else if (ev.kind === 'expired_batch_trash') {
row.expired_batch_trash += 1;
expiredBatchTrashCountSum += ev.payload.count;
} else if (ev.kind === 'ollama_unreachable') {
row.ollama_unreachable += 1;
} else if (ev.kind === 'ollama_recovered') {
row.ollama_recovered += 1;
ollamaDowntimeSum += ev.payload.downtimeMs;
ollamaRecoveredCount += 1;
} else if (ev.kind === 'ollama_recheck_manual') {
row.ollama_recheck_manual += 1;
ollamaRecheckManualCount += 1;
}
}
const days = Array.from(byDay.values()).sort((a, b) => a.date.localeCompare(b.date));
@@ -87,6 +103,10 @@ export function aggregateStats(events: TelemetryEvent[], generatedAt: Date): Sta
const expiredTrashRatio = expiredBannerShownCandidatesSum === 0
? 'N/A'
: `${(expiredBatchTrashCountSum / expiredBannerShownCandidatesSum * 100).toFixed(1)}% (${expiredBatchTrashCountSum}/${expiredBannerShownCandidatesSum})`;
const avgDowntime = ollamaRecoveredCount === 0
? 'N/A'
: `${Math.round(ollamaDowntimeSum / ollamaRecoveredCount)}`;
const totalUnreachable = days.reduce((s, r) => s + r.ollama_unreachable, 0);
const lines: string[] = [];
lines.push('# Inkling Telemetry Stats');
lines.push('');
@@ -95,10 +115,10 @@ export function aggregateStats(events: TelemetryEvent[], generatedAt: Date): Sta
lines.push('');
lines.push('## 일자별 카운트');
lines.push('');
lines.push('| 일자 | capture | ai_succeeded | ai_failed | trash | restore | permanent_delete | empty_trash | expired_banner_shown | expired_batch_trash |');
lines.push('|------|---------|--------------|-----------|-------|---------|------------------|-------------|----------------------|---------------------|');
lines.push('| 일자 | capture | ai_succeeded | ai_failed | trash | restore | permanent_delete | empty_trash | expired_banner_shown | expired_batch_trash | ollama_unreachable | ollama_recovered | ollama_recheck_manual |');
lines.push('|------|---------|--------------|-----------|-------|---------|------------------|-------------|----------------------|---------------------|--------------------|------------------|----------------------|');
for (const row of days) {
lines.push(`| ${row.date} | ${row.capture} | ${row.ai_succeeded} | ${row.ai_failed} | ${row.trash} | ${row.restore} | ${row.permanent_delete} | ${row.empty_trash} | ${row.expired_banner_shown} | ${row.expired_batch_trash} |`);
lines.push(`| ${row.date} | ${row.capture} | ${row.ai_succeeded} | ${row.ai_failed} | ${row.trash} | ${row.restore} | ${row.permanent_delete} | ${row.empty_trash} | ${row.expired_banner_shown} | ${row.expired_batch_trash} | ${row.ollama_unreachable} | ${row.ollama_recovered} | ${row.ollama_recheck_manual} |`);
}
lines.push('');
lines.push('## 핵심 ratio');
@@ -107,6 +127,9 @@ export function aggregateStats(events: TelemetryEvent[], generatedAt: Date): Sta
lines.push(`- 평균 ai_succeeded durationMs: ${avgDuration}`);
lines.push(`- 휴지통 회수율: ${trashRecoveryRate}`);
lines.push(`- 만료 trash ratio: ${expiredTrashRatio}`);
lines.push(`- Ollama unreachable 빈도: ${totalUnreachable}`);
lines.push(`- 평균 downtimeMs (recovered): ${avgDowntime}`);
lines.push(`- 수동 recheck 사용량: ${ollamaRecheckManualCount}`);
lines.push('');
return { md: lines.join('\n'), eventCount };
}