Skip to content

refactor(web): let hosts own metrics and tracing - #859

Merged
mnoah1 merged 1 commit into
mainfrom
mnoah1/web-host-instrumentation
Oct 14, 2026
Merged

mnoah1 merged 1 commit into
mainfrom
mnoah1/web-host-instrumentation

Conversation

@mnoah1

@mnoah1 mnoah1 commented Oct 14, 2026 •

Copy link
Copy Markdown
Contributor

Why

The reusable SubmitQueue and Stovepipe UI packages currently depend on OpenTelemetry and accept OTel meters and tracers. That couples both metrics and tracing to one telemetry stack.

A host using native M3 counters and histograms should not need an adapter to OTel's Meter API just to reuse the UI. The same applies to a host with another tracing stack. Let each host use its native metrics and tracing APIs without forcing either a meter adapter or a tracer bridge.

How it works

The reusable packages keep routing, authorization decisions, queue and request loading, page models, React UI, and request-scoped logging. They no longer import OTel or accept tracing and metrics options.

Hosts instrument the boundaries they own:

  • Wrap the normal web.handle() call to record page-load metrics, outcomes, and spans.
  • Instrument their concrete RPC client for backend-call metrics, tracing, and trace-context propagation.
  • Configure their own providers and exporters.

The reference hosts use native OTel APIs. An M3-backed host can emit the same measurements through native counters and histograms; no OTel-to-M3 bridge is required. Stovepipe's page-load measurements are:

  • stovepipe.web.page_loads: a counter tagged by outcome.
  • stovepipe.web.page_load_duration: a duration histogram in milliseconds, tagged by outcome.

Metric names and units are retained, while bucket configuration, providers, and exporters belong to the host. There is no replacement meter or tracer interface and no generic instrumentation callback in the reusable packages.

For Stovepipe, handled section failures get outcome=error even when the library returns a rendered page; unexpected exceptions get outcome=exception. Metric or trace delivery failures do not repeat reads or replace their results or errors.

Tradeoff

Host-boundary instrumentation measures whole page loads and injected calls, not arbitrary private-library steps. A host can wrap an injected dependency to add metrics or spans around an operation the library calls. Per-step counters, histograms, or spans entirely inside the library would require a separate, explicit instrumentation decision.

No route, UI, backend IDL, or browser API changes are included.

Test plan

  • ./tool/bazel test //web:check --test_output=errors: all 30 targets pass, including package-boundary and React 18 compatibility checks.
  • Tests cover handled section failures, telemetry failures, preserved results and errors, isolated request contexts, and RPC duration metrics.
  • make fmt lint check-tidy check-gazelle and git diff --check pass.

@mnoah1
mnoah1 added this pull request to stack #847 October 14, 2026 15:50
Base automatically changed from mnoah1/web-logging-cleanup to main October 14, 2026 16:00
@mnoah1
mnoah1 force-pushed the mnoah1/web-host-instrumentation branch 2 times, most recently from 9b299f2 to 7714187 Compare October 14, 2026 16:49
@mnoah1
mnoah1 force-pushed the mnoah1/web-host-instrumentation branch from 600bc4d to 52602ff Compare October 14, 2026 17:07
@mnoah1 mnoah1 changed the title refactor(web): let hosts instrument web operations refactor(web): move tracing and metrics out of reusable UI packages Oct 14, 2026
@mnoah1
mnoah1 marked this pull request as ready for review October 14, 2026 17:36
@mnoah1
mnoah1 requested review from a team, behinddwalls and sbalabanov as code owners October 14, 2026 17:36
@mnoah1 mnoah1 changed the title refactor(web): move tracing and metrics out of reusable UI packages refactor(web): let hosts own metrics and tracing Oct 14, 2026
@mnoah1
mnoah1 added this pull request to the merge queue Oct 14, 2026
Merged via the queue into main with commit c2f3cb1 Oct 14, 2026
35 checks passed
@mnoah1
mnoah1 deleted the mnoah1/web-host-instrumentation branch October 14, 2026 18:47
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