Skip to content

feat(P3): DI 点事件统一走 tracer 事件流;直接移除 LLM 诊断通道 - #62

Merged
kooksee merged 2 commits into
v2from
feat/p3-instrumentation-unification
Sep 4, 2026
Merged

feat(P3): DI 点事件统一走 tracer 事件流;直接移除 LLM 诊断通道#62
kooksee merged 2 commits into
v2from
feat/p3-instrumentation-unification

Conversation

@kooksee

@kooksee kooksee commented Sep 4, 2026

Copy link
Copy Markdown
Collaborator

概要

spec §5 实施 P3(计划:docs/superpowers/plans/2026-09-04-p3-instrumentation-unification.md):

  1. 点事件入流:dixinternal/di_event.go 新增 emitDIEvent——95 处 logDITrace 埋点全部改为向 tracer 事件流发布 Event{Operation:"di", Event:<名>, Attrs}(私有 tracer 或全局,EmitTo 路由)。
  2. 订阅者架构:consoleDISink(DIX_TRACE_DI 逐条 gating,输出 di_trace <event>,key 排序保证属性顺序稳定)+ diagTraceSink(写 kind:trace JSONL 记录);全局 tracer 由 init 挂载,WithTraceBuffer 私有 tracer 在创建时挂载。logDITrace 函数删除。
  3. LLM 通道直接删除(无过渡期,spec §5 决策):DIX_LLM_DIAG_MODE env、machine-only 丢弃人类日志的分支、emitLLMDiagnosticLine 的 stderr DIX_LLM_DIAG 行、diag kind:llm 记录类型与 llm_diag_mode 元数据、example/http 重复的 env 解析。error_type/root_cause/hint 结构化字段在 stderr slog 行、JSONL、/api/errors 全部保留——数据在,LLM 就能读。

锁测试口径(全部保持)

  • TestDITraceLogsInInjectFlow / TestDITraceLogsInProvideFlow:di_trace <event> 子串断言原样通过
  • TestDiagFileConfiguredCollectsTraceErrorAndLLM → 改写为 TestDiagFileConfiguredCollectsTraceAndError(trace+error 必须存在、"kind":"llm" 必须不存在)
  • TestShouldTraceDependencyFlow 等原样

验证

  • 全仓 -race 6 包 + example 19 包全绿;task lint 0 issues
  • 覆盖率:dixinternal 84.6%、dixtrace 70.3%、dixhttp 77.5%(均 ↑)
  • 文档:README 双语诊断表删 LLM 行、dixhttp README kind 枚举、design 双语、changelog

All 95 logDITrace sites now publish dix.emitDIEvent point events
(Operation=di) into the tracer stream; console (DIX_TRACE_DI) and the
diag file become subscribers attached per tracer, keeping the output
contract (di_trace <event> messages, kind:trace/error JSONL records).

The dedicated LLM channel is removed outright per spec: DIX_LLM_DIAG_MODE
env, the stderr DIX_LLM_DIAG line, emitDiagFileLLMRecord and the
kind:llm record type. error_type/root_cause/hint structured fields stay
on every export (stderr slog attrs, JSONL, /api/errors) — LLMs read the
human logs fine; what matters is that the data is present.

Also fixes GetFnName-free console sink ordering (kvArgs sorts keys) and
drops the duplicate io/os/json imports that lost their users.
@coderabbitai

coderabbitai Bot commented Sep 4, 2026

Copy link
Copy Markdown

Important

  • 🔍 Trigger review

This repository does not receive automatic reviews because it has fewer than 10 stars.

⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Team

Run ID: ea71898b-3c55-43e2-8716-b44dec7e845b


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.

@kooksee
kooksee merged commit bd5b251 into v2 Sep 4, 2026
3 checks passed
@kooksee
kooksee deleted the feat/p3-instrumentation-unification branch September 4, 2026 14:22
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