Repository navigation
feat(observability): export opt-in business event Logs over OTLP - #1029
Conversation
Signed-off-by: 千乘妍 (Xiaoyaner) <[email protected]>
Signed-off-by: 千乘妍 (Xiaoyaner) <[email protected]>
Signed-off-by: 千乘妍 (Xiaoyaner) <[email protected]>
…ence Signed-off-by: 千乘妍 (Xiaoyaner) <[email protected]>
…K diagnostics Signed-off-by: 千乘妍 (Xiaoyaner) <[email protected]>
…orted identities Signed-off-by: 千乘妍 (Xiaoyaner) <[email protected]>
XiaoSeS
left a comment
There was a problem hiding this comment.
已对当前提交 bd30ac1 完成源码 Review 和真实 Compose 部署验收。验证使用该提交与当时 main 的本地集成版本;后端及部署相关代码与 PR head 一致。
整体方案和主要链路可用:通过真实业务 API、PostgreSQL、对象存储和 OpenTelemetry Collector,对 9 类、19 条业务事件逐条核对;开关、空间过滤、故障恢复、积压退出,以及 Trace 采样 0/1 和实际 Java Agent v2.33.1 共存均完成验证。另执行了 51 项真实 PostgreSQL 服务层测试和 16 项 Mapper/配置测试,均通过。
合并前需要修复一处已复现的兼容性回归:关闭业务 Logs 后,现有 Trace 导出错误仍被全局日志配置屏蔽。 具体位置、对照结果及验收建议见行内意见。请保留业务 Logs 的敏感信息防护,同时避免影响原有 Trace 排障能力,不建议直接把 SDK 原始日志全部打开。
本轮 17 组验收场景结果为 15 组通过、1 组失败、1 组证据不足:
- 失败项即上述 Trace 诊断回归。
- 证据不足项是长期资源稳定性:慢接收端下 20 次并发下载均成功,耗时约 54–128ms;但短时资源观测不能证明长期稳定上界,也不足以认定存在内存泄漏。本轮未进行生产 TLS/mTLS、实际 Kubernetes 安装或长期压力验收。
- 已实测
partial_success返回拒收时exported仍增加;现有文档已明确这一 SDK 局限,本轮不另列为缺陷。该指标不能作为最终落库数量,超时也不保证记录最终未送达。
请优先修复这处日志兼容性问题,并补充同时覆盖“关闭时不影响既有 Trace 诊断”和“开启时不泄漏业务 Logs 接收端响应/凭据”的回归测试;更新后可针对相关场景复验,无需重做全部业务用例。
| <!-- SDK diagnostics may echo receiver bodies / transport exceptions containing credentials. | ||
| Keep raw details OFF; the business adapter supplies fixed-text warnings and metrics. | ||
| Explicit logging.level overrides are an operator opt-in to this disclosure risk. --> | ||
| <logger name="io.opentelemetry.exporter" level="OFF"/> |
There was a problem hiding this comment.
[P2] 不要无条件关闭既有 Trace 的 exporter 诊断
这里的 io.opentelemetry.exporter = OFF 是全局配置,并不受业务 Logs 开关控制,也覆盖现有 Trace exporter。真实对照已确认:同一应用镜像、业务 Logs 关闭、Trace otel-sdk 且采样率为 1,令接收端对 /v1/traces 返回 401;本配置下接收端实际收到 2 次请求,但应用输出 0 条导出错误。仅替换回原 main 的 logback 配置后,同样的 2 次 401 会输出 2 条 Failed to export spans。
因此,即使部署方没有启用这个新功能,原有 Trace 因鉴权失败而停止上报时也会失去原有错误提示。这不符合默认关闭应保持既有行为的兼容边界。
请收窄敏感日志防护的作用范围,避免全局屏蔽 Trace 诊断,同时保留业务 Logs 对响应正文、异常文本及凭据回显的防泄漏能力。至少增加关闭业务 Logs + Trace 导出失败的回归验证;仅将当前两行按开关启停仍需评估开启 Logs 与 Trace 共存时的排障影响。
There was a problem hiding this comment.
已在 79f8248 修复,谢谢复现
- 去掉全局
io.opentelemetry.exporter = OFF,改为 Logback TurboFilterBusinessLogsDiagnosticsFilter:只在业务 exporter 私有线程组(BusinessLogsExporterBoundary)的线程上丢弃io.opentelemetry.*/okhttp3.*诊断;Trace 等其它 exporter 走自己的线程,日志级别和输出保持 main 原样 io.opentelemetry.sdk.logs仍为 OFF,它只被业务 Logs 管线使用
新增回归(text / JSON 两种日志格式各跑一遍):
- 业务 Logs 关闭 + Trace
otel-sdk导出遇 401:输出包含Failed to export spans、401 和接收端消息。换回bd30ac1的 logback 配置后该用例失败(等待超时,0 条) - 业务 Logs 开启 + Trace 同时 401:Trace 错误照常输出;业务接收端回显的合成凭据和
Failed to export logs均不出现,固定告警仍在 - 敏感性对照:只去掉全局 OFF、不加过滤器时,原有凭据泄漏用例失败 6 项,说明防护由过滤器提供而非日志级别
定向套件(JDK 21,同 PR 描述命令):311 项,0 失败 0 错误 0 跳过。本轮未改部署配置,未重跑全量后端与部署契约。文档、design/spec/acceptance 已同步更新
|
返修已通过独立源码 Review 和本地复验:17 项定向测试、7/7 组返修场景通过。原 Trace 诊断丢失问题已修复,text/JSON、业务 Logs 关闭/开启时均能保留 Trace 错误;业务接收端回显的合成凭据仍被隔离,故障后无需重启即可恢复导出。 代码方面可以接受合并。现在请补齐 请保持代码内容不变;补签后我们会核对代码树一致性及最新 CI,更新原“请求修改”Review,然后合并。长期资源稳定性保留为已披露限制,本次不作为新增阻塞项。 |
…exporter Replace the global io.opentelemetry.exporter OFF rule with a Logback TurboFilter that drops OTel/OkHttp diagnostics only on threads of the business exporter's private ThreadGroup. Existing Trace exporter errors (e.g. 401) keep their original diagnostics whether business Logs are disabled or enabled; business receiver responses and credentials stay out of application output. Adds Trace 401 regression cases for Logs disabled and Logs+Trace coexistence in text and JSON formats. Signed-off-by: 千乘妍 (Xiaoyaner) <[email protected]>
6d62c81 to
79f8248
Compare
|
已补签 DCO:
|
|
这次对 PR 做了源码检查和真实部署验证,整体采集方案可以继续推进。正常发布审核、S3 下载、九类业务事件、过滤与故障恢复、三轮并发,以及 SDK/真实 Java Agent 共存均已验证。九类业务事实精确实收 19 条,另有 25 个运行子检查通过。 建议合并前调整以下几处: 1. 修复测试之间的状态污染
实际结果是:Diagnostics+Trace 最小组合 18 项中有 1 项失败,Trace 单独运行 8 项全部通过。请修复日志状态恢复或测试隔离,保留原断言,并确认组合执行通过,不能只用单类通过代替。 2. 补齐部署入口,减少手工接线 建议采用“生产一键脚本+源码本地 Makefile”的方式,复用底层配置和 Compose 定义:
目前独立 Collector 示例与 SkillHub 不在同一容器网络,按示例启动后无法直接互通;加入共享私网后已验证接收成功。文档虽然提到了网络处理,但仍缺完整可执行步骤。 生产可选 Collector 应明确下游接收目标;当前容器内输出 JSON 的方式仅用于本地体验,不应描述成完整生产存储方案。鉴权配置应保留在部署侧,不回显、不写入仓库。 3. 补齐指标启用与查询说明 实测在开启采集、已有事件、使用超级管理员会话的情况下,默认 显式启用后,超级管理员可查询,普通用户和匿名用户仍被拒绝,权限行为正常。请补齐 Compose/Helm 配置透传、重建步骤、管理员查询方式及计数含义,无需默认开放全部 Actuator 端点。 4. 完善站内操作文档与对应测试 建议分别提供“生产接入”和“本地体验”两条路径,覆盖文件获取、配置、生效、产生新事件、查询结果、故障排查和清理。Helm 补齐已有 endpoint/Secret 配置示例即可,本次不必新增 Collector 子 Chart。 部署调整后,请覆盖默认关闭、已有接收端、可选 Collector、本地宿主进程和容器后端等路径,以及配置更新后重新执行、停止后再启动的行为。另外,当前还有一处英文部署文档合并冲突,需要同步 main 后处理。 以上是基于本地验证给出的建议。如果你有更简单、维护成本更低的实现方式,也欢迎讨论;重点是让部署方通过配置和明确入口完成接入,不需要修改源码或手工处理容器接线。 |
Refs iflytek#1009 Signed-off-by: 千乘妍 (Xiaoyaner) <[email protected]>
Signed-off-by: 千乘妍 (Xiaoyaner) <[email protected]>
Signed-off-by: 千乘妍 (Xiaoyaner) <[email protected]>
Signed-off-by: 千乘妍 (Xiaoyaner) <[email protected]>
Signed-off-by: 千乘妍 (Xiaoyaner) <[email protected]>
Signed-off-by: 千乘妍 (Xiaoyaner) <[email protected]>
Signed-off-by: 千乘妍 (Xiaoyaner) <[email protected]>
Signed-off-by: 千乘妍 (Xiaoyaner) <[email protected]>
Signed-off-by: 千乘妍 (Xiaoyaner) <[email protected]>
Signed-off-by: 千乘妍 (Xiaoyaner) <[email protected]>
Signed-off-by: 千乘妍 (Xiaoyaner) <[email protected]>
Signed-off-by: 千乘妍 (Xiaoyaner) <[email protected]>
Signed-off-by: 千乘妍 (Xiaoyaner) <[email protected]>
|
@XiaoSeS 谢谢你做真实部署验证,也谢谢这份清单。四点都已在本 PR 中补齐,按步骤拆成了 12 个提交。主干已同步,英文部署文档的冲突已解决,当前 head 是 1. 测试状态污染
2. 部署入口
3. 指标
4. 文档与验收
以下场景都在本机 Docker 上用本分支构建的镜像实际跑过,事件都通过 API 真实发布和下载 skill 产生:
脚本生命周期测试已加入 需要说明的几点
辛苦再看一下,有问题我再改 🙏 EnglishThanks for the real deployment test and the checklist. All four items are addressed in 12 commits. Main is merged, the en deployment doc conflict is resolved, and the head is
Notes:
|
Signed-off-by: XiaoSeS <[email protected]>
Signed-off-by: XiaoSeS <[email protected]>
…stence Signed-off-by: XiaoSeS <[email protected]>
XiaoSeS
left a comment
There was a problem hiding this comment.
此前阻断的关闭业务 Logs 后 Trace 诊断回归已修复,相关诊断隔离、Tracing 共存及本地组合验证已复验通过。长期生产压力、真实集群和供应商 TLS 验收仍保持原限制,不作为本次已验证结论。
Summary
Closes #1009
概念示意,不代表投递保证。
按维护者在 #1009 确定的范围实现:既有领域事件 → 独立 OpenTelemetry 业务 Logs → OTLP/HTTP → 部署方选择的接收端(可直连,也可经 Collector)。功能默认关闭,与现有 Trace 模式(
none/otel-sdk/external-agent)相互独立;定位是有损、可能重复的分析信号,不用于审计、计费或通知。skill.publication.effective、skill.download.prepared、skill.review.approved/rejected、skill.promotion.approved/rejected、skill.status.changed(归档/取消归档)、skill.visibility.changed、skill.version.yanked。每类事件的触发时机、字段和操作者含义见docs/business-event-logs.md。download.prepared,表示已授权、下载结果已构建,不表示传输完成或已安装。SdkLoggerProvider,作用域为com.iflytek.skillhub.business。不注册为 global OTel,不桥接应用日志,不改 Trace 采样;Spring Boot 3.2.3 / OTel 1.31.0 BOM 不变,没有新增第三方依赖。application.yml、compose.release.yml、Helm chart、.env.release.example和发布校验器都已接入,默认关闭;启用但没配 endpoint 时启动即失败。鉴权头通过部署侧 Secret 注入,只用于传输,不进入记录属性。runtime.sh business-logs-enable/up/disable/down/ps一键接入已有接收端或可选 Collector(独立 Compose 项目,生产模板只做转发、需配置下游);源码本地用make business-logs-demo-*;指标端点通过SKILLHUB_ACTUATOR_EXPOSURE_INCLUDE显式开启,/actuator/metrics/**仅超级管理员。BusinessLogsDiagnosticsFilter只在业务导出器的私有线程组上丢弃 OTel/OkHttp 原始诊断,io.opentelemetry.sdk.logs默认 OFF;Trace 等其它 exporter 的诊断保持原样。网络回调线程的未捕获异常只计数并输出固定文本,不打印接收端回传的内容。操作者通过固定告警和 Micrometer 指标排障。Validation
.trellis/spec/testing/index.md; exclusions explainedCommands run (JDK 21):
docs/examples/business-event-logs/(Collector 版本固定为 0.111.0,fileexporter,资源限制 128 MiB / 0.5 CPU)运行真实应用管线,收到 27 条记录、9 类事件、27 个不同的log.record.uid,文档里附了可直接运行的jq查询。make test-backend:2762 项中有 3 个失败、11 个错误,全部在Github*同步集成测试里。基线9ebb9922在同一台机器上也有 2 个失败、2 个错误,但两边失败的用例并不完全相同。单独重跑这组测试时,两边都是 37/37 通过,疑似测试容器时钟偏差造成的不稳定。这里如实列出,不算作通过;以 CI 结果为准。Risk
design.md有说明)。SKILLHUB_BUSINESS_LOGS_ENABLED设为 false 并重启即可;记录是增量分析数据,回滚后不需要清理。Notes
PROPAGATION_NESTED保存点回滚不在抑制范围内,目前纳入的生产路径都没有用 NESTED;REQUIRES_NEW按独立事务处理。1.31 把所有 2xx 视为整批成功,无法统计 partial success。截止兜底只限制本地名额的占用时长,不会取消已经在途的数据。关闭有等待上限,未发完的数据可能丢失。投递结果不确定时可能产生重复,接收端可以用log.record.uid去重。docs/business-event-logs.md(生产接入与本地体验两条路径)、docs/examples/business-event-logs/、openspec/changes/add-otlp-business-event-logs/(proposal / design / spec / tasks / acceptance)、docs/09-deployment.md观测章节中的链接。English
Conceptual illustration, not a delivery guarantee.
Implements the scope agreed in #1009: existing domain events → a dedicated, default-off OpenTelemetry business Logs pipeline → OTLP/HTTP → a deployer-chosen receiver (direct or via Collector). It is independent of the existing tracing modes and is a lossy, possibly duplicated analytics signal, not audit, billing or notification.
Nine contract-v1 events cover effective publication (all four producers, actual approver as actor), download prepared (not delivered/installed), review and promotion decisions, archive/unarchive status changes, effective visibility changes and version yanks. Transactional producers are admitted only after physical commit and suppressed on rollback; the non-transactional download path is admitted immediately. Domain events gain an immutable producer snapshot while keeping existing constructors; the domain module does not depend on OTel. A single explicit mapper enforces an attribute allowlist (no names, content, reasons, secrets, signed URLs, IP/UA, headers, MDC or baggage). Boot 3.2.3 / OTel 1.31.0 are unchanged and no third-party dependency is added. Admission is bounded across queued and in-flight records, every export has a deadline guard so permits are always recovered, and exporter failures never reach the business call. Raw SDK diagnostics are filtered only on the business exporter's own threads (Trace diagnostics unchanged), and the business exporter's callback threads run in a private thread group so receiver-supplied text is not printed; operators use fixed warnings and Micrometer counters.
Validation: focused suite 307 tests, 0 failures/errors/skips, including 43 real PostgreSQL producer cases (commit/rollback matrix with exported identity assertions and promotion namespace filters), tracing coexistence, outage/queue-full/blocked-exporter scenarios and credential-containment regressions. A real pinned Collector 0.111.0 received and queried 27 records / 9 event names / 27 unique UIDs. Deployment contracts pass.
make test-backendis not fully green locally: 3 failures + 11 errors, all inGithub*sync integration tests. The base also fails some of them locally, but not exactly the same set; that suite passes 37/37 in isolation on both. These are disclosed, not counted as passing; CI is authoritative. These numbers are for the first published head; later rework results (including the deployment round's real Docker scenarios, the 18/18 combined run and the 312-test focused suite) are in the PR comments and the new head's Checks. Deployment entry points:runtime.sh business-logs-*(existing receiver or optional forwarding Collector) andmake business-logs-demo-*; metrics exposure is opt-in viaSKILLHUB_ACTUATOR_EXPOSURE_INCLUDE.Known limitations: NESTED savepoint rollback is excluded; 1.31 cannot report partial success; deadline cleanup bounds local permit lifetime and does not cancel data in transit; shutdown is bounded and may drop; ambiguous delivery may duplicate (dedupe by
log.record.uid). The thread-group containment must be revalidated on SDK upgrades.2026-11-06 验证补充
当前 head
89066c698:补充主线整合,修复 raw OTel 上下文测试顺序污染,独立进程验证业务日志与 Trace MDC 共存。已完成独立代码复审。正式矩阵分别9/9、12/12、14/14通过;组合真实接口场景25项、Windows Chrome156浏览器检查44项通过。组合本地验证覆盖真实技能/套件提审发布、当前版本通知、验邮与邮件通道独立、账户合并证明/偏好/待发队列隔离、撤权后的详情屏蔽和投递抑制、SMTP451/550/UNKNOWN、实际运行脚本日志关闭/复开、指标授权,以及四语/窄屏/注销换号。分页500缺陷在修复后按原400预期通过真实接口复测。
前端全量1741项通过;组合Java21定向及兼容测试604项通过(与全量有重叠,不相加)。完整后端回归共3015项:2985通过、30项既有可选集成跳过、0断言失败/0错误;首轮缺少Go导致的两项环境错误补齐Go1.27.3后定向重跑通过,独立OTel执行亦完成,已与Surefire XML交叉核对。初始失败及修正重跑均保留,不以部分单测替代完整业务场景或用户人工验收。
当前未合并。#1029和#1004的DCO检查仍指向已存在于main的历史签署问题,重新请求应用检查的API返回404;未改写历史或替他人签署。三项PR保持独立范围;六类领域事件快照与邮件稳定身份的组合兼容解析已在本地验证,将在前序PR合入后带回#1004并重查提交和CI。
SMTP仅证明本地接收结果,不代表真实邮箱送达;本地镜像验证不代表远程镜像、生产部署或供应商压测。