Skip to content

feat(observability): export opt-in business event Logs over OTLP - #1029

Merged
XiaoSeS merged 23 commits into
iflytek:mainfrom
xiaoyaner0201:feat/otlp-business-events-1009
Nov 6, 2026
Merged

XiaoSeS merged 23 commits into
iflytek:mainfrom
xiaoyaner0201:feat/otlp-business-events-1009

Conversation

@xiaoyaner0201

@xiaoyaner0201 xiaoyaner0201 commented Oct 28, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Closes #1009

业务写凭条,传输走标准:SkillHub 按需开启的 OTLP 业务日志

概念示意,不代表投递保证。

按维护者在 #1009 确定的范围实现:既有领域事件 → 独立 OpenTelemetry 业务 Logs → OTLP/HTTP → 部署方选择的接收端(可直连,也可经 Collector)。功能默认关闭,与现有 Trace 模式(none / otel-sdk / external-agent)相互独立;定位是有损、可能重复的分析信号,不用于审计、计费或通知。

  • 9 类事件(契约版本 1):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,表示已授权、下载结果已构建,不表示传输完成或已安装。
  • 领域层只加快照:领域事件新增不可变的生产点上下文(发生时间、操作者、命名空间、可见范围等),旧构造器和访问器保留,现有通知/搜索监听器的行为不变。领域层不依赖 OTel。
  • 独立的导出管线:独立的 SdkLoggerProvider,作用域为 com.iflytek.skillhub.business。不注册为 global OTel,不桥接应用日志,不改 Trace 采样;Spring Boot 3.2.3 / OTel 1.31.0 BOM 不变,没有新增第三方依赖。
  • 有界、不阻塞业务:受理计数涵盖排队和在途记录,满了就丢弃并计数;重试、超时、关闭等待都有上限。每次导出都有截止兜底,保证队列名额一定能收回。导出失败不会抛回业务调用。
  • 字段白名单:只有一个显式 mapper,最多 16 个属性,字符串长度有上限。正文、名称、拒绝原因、密钥、签名 URL、IP/UA、请求头、MDC 和 baggage 都不导出。私有技能和空间的 ID 默认导出(不含名称),也可以用命名空间白名单收窄。
  • 部署: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/** 仅超级管理员。
  • SDK 原始诊断不外泄:logback 里的 BusinessLogsDiagnosticsFilter 只在业务导出器的私有线程组上丢弃 OTel/OkHttp 原始诊断,io.opentelemetry.sdk.logs 默认 OFF;Trace 等其它 exporter 的诊断保持原样。网络回调线程的未捕获异常只计数并输出固定文本,不打印接收端回传的内容。操作者通过固定告警和 Micrometer 指标排障。

Validation

下方数字对应首发 head。返修后的结果(含第二轮部署闭环的真实 Docker 场景、组合测试 18/18、定向 312 项)见 PR 评论与新 head 的 Checks。

  • Applicable checks selected from .trellis/spec/testing/index.md; exclusions explained
  • Backend tests passed when backend behavior changed — 聚焦套件全绿;全量后端见下方说明
  • Frontend typecheck/build passed when frontend files changed — N/A,前端未修改
  • OpenAPI SDK regenerated or checked when API contracts changed — N/A,API 未修改
  • Smoke test run when relevant — 真实 OTel Collector 接收与查询

Commands run (JDK 21):

./server/mvnw -f server/pom.xml -B -ntp -pl skillhub-app -am test \
  '-Dtest=Business*Test,SkillPublishServiceTest,SkillReviewSubmitServiceTest,ReviewServiceTest,PromotionServiceTest,SkillGovernanceServiceTest,SkillVisibilityServiceTest,SkillDownloadServiceTest,NotificationEventListenerTest,SkillHubTracingConfigurationTest,TracingModeAutoConfigurationImportFilterTest' \
  -Dsurefire.failIfNoSpecifiedTests=false
python3 -m unittest discover -s scripts/tests -p test_business_logs_config.py -v
bash charts/skillhub/tests/configuration-contracts.sh
bash scripts/tests/validate-release-config-test.sh
make test-backend
  • 聚焦套件:307 项,0 失败、0 错误、0 跳过(domain 193 + app 114)。其中业务 Logs 81 项,包括真实 PostgreSQL 生产路径 43 项。
  • 提交/回滚矩阵:13 条生产路径在提交后各出一条记录,回滚时为零;同时逐项校验导出的 skill/version/namespace ID、来源、可见范围、新旧状态值。提升场景另覆盖“只保留来源空间”和“只保留目标空间”两种过滤,首次提升和更新提升都测了。
  • Trace 共存:tracing 关闭和 span 未采样时,业务记录照常导出;只关联已有的有效 span,不从 requestId/MDC 伪造 TraceId。
  • 真实接收:用 docs/examples/business-event-logs/(Collector 版本固定为 0.111.0,file exporter,资源限制 128 MiB / 0.5 CPU)运行真实应用管线,收到 27 条记录、9 类事件、27 个不同的 log.record.uid,文档里附了可直接运行的 jq 查询。
  • 故障场景(本机观测值,不是 SLO):Collector 暂停时,1000 次业务调用耗时 8 ms,丢弃 998 条;Collector 停掉时,调用耗时 0 ms,失败已计数;导出器阻塞时,循环耗时 12 ms,丢弃 999 条,关闭耗时 218 ms(SDK 等待预算 100 ms 加本地开销)。
  • 返修回归:接收端返回半截错误响应后断开,名额能收回,后续事件不用重启就能导出;接收端在 401 正文回显合成凭据、状态行畸形、chunked 编码畸形三种情况下,文本和 JSON 两种日志配置的 stdout/stderr 里都查不到凭据;与本导出器无关的同名线程,其未捕获异常仍交给原来的 handler 处理。
  • 部署契约:Python 4/4,Helm 和 release 契约脚本均 exit 0。
  • make test-backend:2762 项中有 3 个失败、11 个错误,全部在 Github* 同步集成测试里。基线 9ebb9922 在同一台机器上也有 2 个失败、2 个错误,但两边失败的用例并不完全相同。单独重跑这组测试时,两边都是 37/37 通过,疑似测试容器时钟偏差造成的不稳定。这里如实列出,不算作通过;以 CI 结果为准。
  • 文档站点构建:首发时本地未完成;返修轮已在本地构建通过。

Risk

  • User-facing impact: 默认关闭时不创建 OTel 对象,监听器也不注册。启用后,业务线程上只做 O(1) 的非阻塞入队。
  • Deployment or migration impact: 没有数据库迁移。SDK 原始诊断只在业务导出器自己的线程上过滤,Trace exporter 的诊断保持原样。私有 ThreadGroup 依赖 OTel 1.31 OkHttp 发送器“按构造线程所在的组创建 dispatcher 线程”这一实现细节,升级 SDK 时需要重新验证(design.md 有说明)。
  • Rollback approach: 把 SKILLHUB_BUSINESS_LOGS_ENABLED 设为 false 并重启即可;记录是增量分析数据,回滚后不需要清理。

Notes

  • 已知限制(文档和 OpenSpec 中都写明了):PROPAGATION_NESTED 保存点回滚不在抑制范围内,目前纳入的生产路径都没有用 NESTED;REQUIRES_NEW 按独立事务处理。1.31 把所有 2xx 视为整批成功,无法统计 partial success。截止兜底只限制本地名额的占用时长,不会取消已经在途的数据。关闭有等待上限,未发完的数据可能丢失。投递结果不确定时可能产生重复,接收端可以用 log.record.uid 去重。
  • 暂不纳入:没有现成决定事件的元数据/头像审核、隐藏/取消隐藏、提升撤销、提交/撤回审核、Suite 事件、搜索/浏览、传输完成/安装,以及持久重放(outbox)。
  • 前端被动标记在 feat(web): add passive semantic analytics attributes across frontend workflows #1010([Feature] 支持厂商中立的前端业务语义属性 #989)中单独提交,与本 PR 互不依赖。
  • 文档入口: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

Business receipts, standard post: opt-in OTLP business Logs from SkillHub

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-backend is not fully green locally: 3 failures + 11 errors, all in Github* 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) and make business-logs-demo-*; metrics exposure is opt-in via SKILLHUB_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仅证明本地接收结果,不代表真实邮箱送达;本地镜像验证不代表远程镜像、生产部署或供应商压测。

@XiaoSeS XiaoSeS left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

已对当前提交 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"/>

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[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 共存时的排障影响。

@xiaoyaner0201 xiaoyaner0201 Oct 29, 2026 •

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

已在 79f8248 修复,谢谢复现

  • 去掉全局 io.opentelemetry.exporter = OFF,改为 Logback TurboFilter BusinessLogsDiagnosticsFilter:只在业务 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 已同步更新

@XiaoSeS

XiaoSeS commented Oct 30, 2026

Copy link
Copy Markdown
Collaborator

返修已通过独立源码 Review 和本地复验:17 项定向测试、7/7 组返修场景通过。原 Trace 诊断丢失问题已修复,text/JSON、业务 Logs 关闭/开启时均能保留 Trace 错误;业务接收端回显的合成凭据仍被隔离,故障后无需重启即可恢复导出。

代码方面可以接受合并。现在请补齐 6d62c81 的 DCO Signed-off-by 签署,当前 DCO 检查仍为 action_required。

请保持代码内容不变;补签后我们会核对代码树一致性及最新 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]>
@xiaoyaner0201
xiaoyaner0201 force-pushed the feat/otlp-business-events-1009 branch from 6d62c81 to 79f8248 Compare October 30, 2026 07:13
@xiaoyaner0201

Copy link
Copy Markdown
Contributor Author

已补签 DCO:6d62c81 补上 Signed-off-by 后为 79f8248,代码内容未改

@XiaoSeS

XiaoSeS commented Nov 3, 2026

Copy link
Copy Markdown
Collaborator

这次对 PR 做了源码检查和真实部署验证,整体采集方案可以继续推进。正常发布审核、S3 下载、九类业务事件、过滤与故障恢复、三轮并发,以及 SDK/真实 Java Agent 共存均已验证。九类业务事实精确实收 19 条,另有 25 个运行子检查通过。

建议合并前调整以下几处:

1. 修复测试之间的状态污染

BusinessLogsDiagnosticsTest 会重新初始化进程全局日志系统,但清理后未完整恢复,导致后续 Trace MDC 测试失败。

实际结果是:Diagnostics+Trace 最小组合 18 项中有 1 项失败,Trace 单独运行 8 项全部通过。请修复日志状态恢复或测试隔离,保留原断言,并确认组合执行通过,不能只用单类通过代替。

2. 补齐部署入口,减少手工接线

建议采用“生产一键脚本+源码本地 Makefile”的方式,复用底层配置和 Compose 定义:

  • 生产环境:扩展现有 scripts/runtime.sh。默认关闭采集;开启时支持连接已有兼容接收端,可选启动 Collector。脚本负责获取对应版本文件、连接网络、配置 endpoint、重建服务,以及状态查看和停止操作。
  • 本地开发:通过 Makefile 启动演示 Collector,自动处理宿主 Java 进程或容器后端的接收地址,并提供记录查看、验证和停止入口。

目前独立 Collector 示例与 SkillHub 不在同一容器网络,按示例启动后无法直接互通;加入共享私网后已验证接收成功。文档虽然提到了网络处理,但仍缺完整可执行步骤。

生产可选 Collector 应明确下游接收目标;当前容器内输出 JSON 的方式仅用于本地体验,不应描述成完整生产存储方案。鉴权配置应保留在部署侧,不回显、不写入仓库。

3. 补齐指标启用与查询说明

实测在开启采集、已有事件、使用超级管理员会话的情况下,默认 /actuator/metrics 和 /actuator/prometheus 都返回 404。

显式启用后,超级管理员可查询,普通用户和匿名用户仍被拒绝,权限行为正常。请补齐 Compose/Helm 配置透传、重建步骤、管理员查询方式及计数含义,无需默认开放全部 Actuator 端点。

4. 完善站内操作文档与对应测试

建议分别提供“生产接入”和“本地体验”两条路径,覆盖文件获取、配置、生效、产生新事件、查询结果、故障排查和清理。Helm 补齐已有 endpoint/Secret 配置示例即可,本次不必新增 Collector 子 Chart。

部署调整后,请覆盖默认关闭、已有接收端、可选 Collector、本地宿主进程和容器后端等路径,以及配置更新后重新执行、停止后再启动的行为。另外,当前还有一处英文部署文档合并冲突,需要同步 main 后处理。

以上是基于本地验证给出的建议。如果你有更简单、维护成本更低的实现方式,也欢迎讨论;重点是让部署方通过配置和明确入口完成接入,不需要修改源码或手工处理容器接线。

@xiaoyaner0201

Copy link
Copy Markdown
Contributor Author

@XiaoSeS 谢谢你做真实部署验证,也谢谢这份清单。四点都已在本 PR 中补齐,按步骤拆成了 12 个提交。主干已同步,英文部署文档的冲突已解决,当前 head 是 b077a56a。

1. 测试状态污染

  • 原因:BusinessLogsDiagnosticsTest 先跑时,会先初始化 OTel 的 ContextStorage,晚于它安装的 Boot MDC 包装就不再生效。这个状态在同一进程里无法还原。
  • 处理:这个类加了标签,在单独的 Surefire 执行里跑,每次新开一个 JVM。普通 make test-backend 仍会完整跑它一次。原有断言一条没改。
  • 验证:Diagnostics+Trace 组合按字母顺序执行,修改前两次都是 18 项中 1 项失败,修改后两次都是 18 项全部通过。业务 Logs 定向套件 312 项、observability 包 117 项也都通过。

2. 部署入口

runtime.sh 新增 business-logs-* 命令。默认仍关闭,不需要克隆源码。

  • 已有接收端:执行 business-logs-enable --logs-endpoint <url>。接收端在私有网络里时,加上 --logs-network <name>。
  • 可选 Collector:执行 business-logs-up。Collector 是独立的 Compose 项目,下游地址和鉴权头只写在部署侧的 business-logs/.env 里,不回显。生产模板不对外开端口,也不在本地存文件;没有配置下游时会拒绝启动。
  • 其他命令:business-logs-disable 关闭采集、business-logs-down 停止 Collector、business-logs-ps 查看状态。重复执行不会覆盖密钥。停止和 clean 都不删配置。关闭再打开时,会自动接回原来的网络。
  • 本地开发:使用 make business-logs-demo-up/status/records/verify/down。本机 Java 进程和容器后端都会自动选择接收地址。这个演示存储只用于本地体验。
  • 版本匹配:文档统一写成 --ref <tag> --version <tag> 两个参数一起指定。--version 原有的含义没有改变。

3. 指标

  • 默认暴露的端点仍只有 health,info。
  • 需要时设置 SKILLHUB_ACTUATOR_EXPOSURE_INCLUDE=health,info,metrics,prometheus,Compose 和 Helm 都支持透传。
  • /actuator/metrics/** 只对超级管理员开放;Prometheus 端点沿用原有规则。
  • 文档补充了重建步骤、管理员查询方式(Helm 环境使用 Service 端口转发)以及每个计数的含义。

4. 文档与验收

docs/business-event-logs.md 拆成“生产接入”和“本地体验”两条路径,覆盖文件获取、配置、生效、产生事件、查询、排障和清理。Helm 部分补齐了 endpoint 和 Secret 的示例,没有新增 Collector 子 Chart。

以下场景都在本机 Docker 上用本分支构建的镜像实际跑过,事件都通过 API 真实发布和下载 skill 产生:

  • 默认关闭时,接收端收到 0 条请求,指标端点返回 404
  • 接入已有接收端
  • 修改配置后重新执行
  • 可选 Collector 转发到下游
  • 停止后再启动,数据、网络和密钥都保留
  • 关闭后业务正常,接收端不再收到新事件
  • 关闭后再次开启
  • 本机 Java 进程和容器后端两条本地演示路径
  • 开启指标后,超级管理员返回 200,普通用户返回 403,匿名访问返回 401

脚本生命周期测试已加入 pr-scripts.yml。

需要说明的几点

  • 新增的 compose.business-logs-collector.yml、compose.release.business-logs.yml、business-logs-collector.yaml 需要在发版时同步上传到 OSS 根目录,--aliyun 安装才能获取到。
  • Helm 做了模板契约检查和 strict lint,没有在真实集群里安装。
  • 从私有网络接收端换到公网接收端时,需要在 .env.release 里设置 SKILLHUB_BUSINESS_LOGS_NETWORK_ENABLED=false,再执行 enable,以断开原来的网络。这一步后续可以补成命令。

辛苦再看一下,有问题我再改 🙏

English

Thanks 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 b077a56a.

  1. Test pollution. When BusinessLogsDiagnosticsTest ran first, it initialized OTel ContextStorage before Boot installed its MDC wrapper. That state cannot be restored in-process. The class is now tagged and runs in a dedicated, non-reused Surefire JVM. Plain make test-backend still runs it exactly once, and its assertions are unchanged. In alphabetical order, the Diagnostics+Trace combination failed 1/18 twice before the change and passed 18/18 twice after it. The focused suite (312) and the observability package (117) also pass.
  2. Entry points. runtime.sh business-logs-* (default off):
    • business-logs-enable --logs-endpoint <url> [--logs-network <name>] connects an existing receiver.
    • business-logs-up starts an optional, independent Collector project. Its downstream and headers stay in a deployment-side env file. It has no host port and no local storage, and it refuses to start without a downstream.
    • The disable, down and ps commands, plus idempotent secrets: stop and clean keep config, and disable/enable reattaches the saved network.
    • For source checkouts, make business-logs-demo-* handles both host-process and containerized backends. It is local-trial only.
    • Docs pin --ref <tag> --version <tag> together. The meaning of --version is unchanged.
  3. Metrics. Exposure defaults to health,info. The opt-in SKILLHUB_ACTUATOR_EXPOSURE_INCLUDE=health,info,metrics,prometheus is passed through Compose and Helm. /actuator/metrics/** is limited to SUPER_ADMIN. The docs cover recreation steps, admin queries (Helm via Service port-forward) and the meaning of each counter.
  4. Docs and acceptance. The guide now has separate production and local-trial paths. The Helm section completes the endpoint/Secret example, with no Collector sub-chart. All listed scenarios were run on real Docker with a server image built from this branch, using real publish/download events: default off (0 requests, metrics 404), existing receiver, config update, Collector forwarding, stop/start retention, disable with zero new exports, re-enable, both local demo paths, and metrics returning 200 for super admin, 403 for a normal user and 401 for anonymous. The lifecycle test is registered in pr-scripts.yml.

Notes:

  • The three new root-level files must be uploaded to the OSS root at release time for --aliyun installs.
  • Helm was verified with contracts and strict lint, not a live cluster install.
  • To switch from a private receiver to a public one, set SKILLHUB_BUSINESS_LOGS_NETWORK_ENABLED=false in .env.release before running enable. This can become a command later.

@XiaoSeS XiaoSeS left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

此前阻断的关闭业务 Logs 后 Trace 诊断回归已修复,相关诊断隔离、Tracing 共存及本地组合验证已复验通过。长期生产压力、真实集群和供应商 TLS 验收仍保持原限制,不作为本次已验证结论。

@XiaoSeS XiaoSeS left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@dcoapp recheck

@XiaoSeS
XiaoSeS merged commit b4d849e into iflytek:main Nov 6, 2026
34 checks passed
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.

[Feature] RFC:默认关闭的厂商中立后端业务事件出口 / Opt-in backend business-event export

2 participants