Skip to content

fix(observability): export bounded cache counters through PromExporter - #345

Merged
voidvec merged 1 commit into
masterfrom
fix/cache-counter-export-s07
Nov 19, 2026
Merged

voidvec merged 1 commit into
masterfrom
fix/cache-counter-export-s07

Conversation

@voidvec

@voidvec voidvec commented Nov 15, 2026 •

Copy link
Copy Markdown
Owner

Summary

Cache repositories emit fulla_cache_total through IMetrics, but the default adapter only logged it and the official PromExporter configurations registered no collector. Connect this one bounded family to the existing exporter so cache hit/miss/error behavior is observable even at WARN log level.

Register the collector in the four official profiles. Export only repo={token,client,owner_status} and outcome={hit,miss,error}, with finite nonnegative increments and matching label schema. Missing/misconfigured exporters remain optional; preserve legacy logging independently. Avoid the templated plugin lookup's pre-start assertion and static pointer cache. No public SDK/API, authorization, cache, schema or transaction changes.

Correct the EN/ZH observability docs: legacy metric events are still INFO logs and require separate conversion/wiring. Custom configurations must explicitly register the cache collector. Regenerate both LLM documentation artifacts.

Refs #343

Type of change

  • Bug fix (non-breaking)

Validation

  • Independent plan and implementation review passed.
  • Complete adapter gtest: 12 tests passed, including six new bounded-label, optional/malformed collector, 8-thread exact-total, actual pre-start adapter and official-configuration tests.
  • Complete main binary: 746 cases / 62,288 assertions, exit 0.
  • Out-of-process endpoint wrapper passed without skipping: OAuth2 script prints 62/63 passed and 0 failed (existing count limitation); Admin 61/61.
  • An independent real server's /metrics showed increasing cache counters after six seconds of successful client-credentials traffic. This verifies the production bridge; it is not a capacity result or proof of timestamp/introspection semantics.
  • All six repository gates passed, plus architecture/macro checks, doc links, formatting and deterministic LLM regeneration. Release C++17 / WERROR.
  • The explicitly unmerged combination with fix(storage): preserve access-token timestamps and reject future introspection nbf #344 and perf: add S07 capacity harness with cache and telemetry fixes #343 passed all 18 default/tuned protocol smoke rows, the complete 756-case main binary (62,444 assertions), all 12 adapter tests and the endpoint wrapper. Both profiles used the existing --smoke-seconds 6 option (4 VU, 0.2-second warmup) to cross the pinned exporter's five-second HTTP snapshot cache. Actual cache reuse and cold-path ratios both passed the unchanged gates with zero cache errors. Counter deltas are not one-to-one measurement-request counts.

Checklist

  • Tests added and complete relevant library/main/endpoint suites passed
  • CHANGELOG and EN/ZH operational documentation updated
  • Generated LLM documentation synchronized
  • No public API/schema/SDK baseline updates needed

Functional smoke does not imply clean shutdown: abnormal server-stop outcomes are retained separately under the #300 exclusion. This is separate from #344. Registry/counter lookup adds bounded synchronization work; capacity impact remains for S07. Formal capacity, soak and fault acceptance remain blocked on persistent-space provisioning. Private fixture credentials and raw archives stay local. No merge/deployment is requested.

@voidvec

voidvec commented Nov 17, 2026

Copy link
Copy Markdown
Owner Author

必须处理项

评审基于 1269a4993047bb89ebb6504afefd3e0b6b088658。

本轮未发现需要阻断合并的新增缺陷。

已核对生产调用点、导出 helper、四份官方配置、测试和文档:指标名及 repo/outcome 白名单与实际调用一致,最多九组标签;非法数值、额外标签、错误 collector 类型/顺序不会创建导出序列;日志和导出分别隔离失败;启动前不进行会触发断言的模板插件查询。新增测试通过现有 gtest 源码收集与发现机制接入。

当前 head 的三平台、ASan+UBSan、SDK smoke 及文档构建均成功。缺少自定义 collector 时不导出但不影响认证是明确设计,并已在文档说明,未将其当成静默错误要求改变。严格 coverage gate/nightly TSan 未运行,本轮也未本地重编或重跑真实服务。

@voidvec

voidvec commented Nov 17, 2026

Copy link
Copy Markdown
Owner Author

建议处理项

评审基于 1269a4993047bb89ebb6504afefd3e0b6b088658。

1. 将真实 adapter → PromExporter → HTTP 的验证固化为自动化回归

位置:DrogonMetrics.cc:51–62、CacheCounterTest.cc:98–129。

现有并发/标签测试直接调用私有 helper;唯一调用生产 DrogonMetrics 的用例明确处于 server 尚未启动状态,因此跳过本次新增的插件查找及导出分支。PR 中已有真实 /metrics 手工验证记录,建议将其固化为独立进程的集成用例:运行官方配置、设置 WARN 日志等级,产生已知缓存事件,跨过 exporter 的快照缓存窗口后抓取 /metrics 并检查计数增长与标签集合。

此测试应放在服务端集成测试层,不要在约定无事件循环的 adapter gtest 进程内启动服务。现有手工证据使其可作为非阻断覆盖建议。

wangrh0909
wangrh0909 previously approved these changes Nov 18, 2026
@wangrh0909
wangrh0909 force-pushed the fix/cache-counter-export-s07 branch from 1269a49 to 4f83771 Compare November 18, 2026 04:03
Register the cache counter in the four official profiles, keep export failures separate from legacy INFO logging, and bound labels and values. Preserve optional exporter behavior and pre-start adapter safety; clarify the log-only legacy metric events and custom collector configuration.

Refs #343
@voidvec
voidvec force-pushed the fix/cache-counter-export-s07 branch from 4f83771 to e998a04 Compare November 19, 2026 05:06
@voidvec
voidvec marked this pull request as ready for review November 19, 2026 05:06
@voidvec
voidvec merged commit c420950 into master Nov 19, 2026
@chatgpt-codex-connector

Copy link
Copy Markdown
Codex Review Summary: ❌ Failed

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ❌ Failed 2026-11-19T05:06:13.660847Z
We couldn’t complete this review. Comment @codex review to try again.
e998a04 Draft marked ready
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@chatgpt-codex-connector

Copy link
Copy Markdown

You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard.

voidvec added a commit that referenced this pull request Nov 20, 2026
Prevent optional cache collectors from being dynamically registered or modified as Gauge families. Add a running-adapter regression for bounded routing and generic metric export, with missing and malformed collector profiles.

Refs #345
voidvec added a commit that referenced this pull request Nov 23, 2026
Prevent optional cache collectors from being dynamically registered or modified as Gauge families. Add a running-adapter regression for bounded routing and generic metric export, with missing and malformed collector profiles.

Refs #345
voidvec added a commit that referenced this pull request Nov 24, 2026
Prevent optional cache collectors from being dynamically registered or modified as Gauge families. Add a running-adapter regression for bounded routing and generic metric export, with missing and malformed collector profiles.

Refs #345
voidvec added a commit that referenced this pull request Nov 24, 2026
…uge (#367)

* fix(observability): reserve cache counter name in gauge API

Prevent optional cache collectors from being dynamically registered or modified as Gauge families. Add a running-adapter regression for bounded routing and generic metric export, with missing and malformed collector profiles.

Refs #345

* fix(observability): reject the reserved cache family in the Gauge API

setGauge() previously created a Gauge collector on first use, so a
deployment missing the configured fulla_cache_total Counter would get a
Gauge family with arbitrary labels under the same name, and the
prometheus scrape would silently change shape.

Move the gauge apply path into detail::setGaugeSample(), which rejects
the reserved name before any lookup: missing collectors are never
registered and an existing collector of any type is never mutated. The
label-name/value helpers move next to the cache whitelist so both paths
share one implementation.

* test(observability): pin gauge-API rejection for the reserved family

Cover the three collector states the reserved family can be in (missing,
counter, misconfigured gauge) plus the generic-gauge and wrong-type
paths. The missing-collector case is the regression pin: with the
reserved-name check removed, the test registers a Gauge and fails.

* test(integration): exercise cache routing against the live exporter

Drive the running-adapter fixture only against the configured profile:
assert the real Counter schema, whitelist rejections, no-op Gauge calls
for the reserved family, and fulla_test_peer counter/gauge registration,
then observe the values through an actual /metrics scrape. The previous
env-gated missing/reversed/gauge branches were unreachable in CI; those
states are covered as unit tests instead.

* docs(observability): document the reserved-family Gauge no-op

State in the metric reference that setGauge() is a no-op for
fulla_cache_total in every collector state, and align the changelog
bullet with the coverage the tests now prove.

* docs(observability): regenerate llms-full.txt for the gauge note
@voidvec
voidvec deleted the fix/cache-counter-export-s07 branch December 2, 2026 04:43
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.

2 participants