[P2] `QueryClient` distributed-tracing observability in `BaseDataService`
メンテナーはふだん 1 日以内に返信
@MajorLift がすでに取り組んでいます。
2026年9月21日 から。
評価
- 難易度
- 4/5
- 見積もり時間
- 3〜5日
- 初心者へのやさしさ
- 50/100
- issue の種類
- 機能追加
- 明瞭さ
- おおむね明確
- 活発さ
- 静か
- 技術スタック
- typescript
調査の方向性
packages/base-data-service/src/BaseDataService.ts から始め、内部の QueryClient がどのように作成され、使用されているかを追跡します。getter と constructor-hook のオプションを評価し、そのうえで、下流の queryCache.subscribe の配線によって、UI サーフェス、OmitKeyof の動作、messenger のコントラクト、または proxy queryFn のセマンティクスを変更せずに、キャッシュとリクエストのライフサイクルを監視できることを検証します。
索引モデルが issue の本文から書いたものです。
説明
Parent Epic: None (standalone)
File: packages/base-data-service/src/BaseDataService.ts
Size: S | Hours: 2–4
Problem
Option A's proxy model (TanStack Query QueryClient in the background process, proxy queryFn in the UI) intentionally hides the cache, dedupe, retry, fetch, and sync chain from UI-perceived latency tracing. The distributed-tracing wrappers in metamask-extension#39891 give us the call boundaries (useQuery → submitRequestToBackground → messenger → BaseDataService action → response). Inside the opaque region, every interesting decision is invisible:
- Cache hit vs. miss. Most data service calls don't make a network request. Auto-instrumented fetch spans see zero. The query looks "slow" with no attribution.
- In-flight dedupe. N concurrent observers collapse to one fetch. The fetch span doesn't know N.
- Cockatiel retry sequences. A single logical "fetch this" can produce 0, 1, or many HTTP requests. Auto-spans see them as unrelated. Backoff intervals are invisible.
- Circuit breaker state. When open, no fetch happens. The query fails or returns cached data with no auto-span at all.
- Cache sync to UI.
setData → cacheUpdated event → Port.postMessage → UI hydrateis the post-fetch synchronization cost. None of it surfaces as a span. - Trigger attribution. Poll interval, user invalidation, observer subscribe, and WebSocket invalidation are all identical from the network's view.
Three Option A tradeoffs documented in decisions#131 currently depend on observability that doesn't exist:
- Per-screen
staleTime. Validating that the service-side workarounds hold in production requires distinguishing fetches from cache serves. refetchOnMount/refetchOnWindowFocuscollapse. Measuring whether concurrent queries amplify messenger volume or are absorbed by backgroundstaleTime.- Split-process staleness indirection. Correlating UI proxy calls with background fetches.
Without this visibility, the tradeoffs are theoretical. With it, they're verifiable.
Solution
Add a sanctioned extension point to BaseDataService that exposes the internal QueryClient for read-only observability subscriptions. Two variants; preference is maintainer's call:
- Public getter.
get queryClient(): QueryClient - Constructor callback.
onCreate?: (qc: QueryClient) => void
Either is ~3 lines in core. Downstream clients attach their own instrumentation externally (e.g. qc.getQueryCache().subscribe(emitSpan) plus Cockatiel onRetry / onBreak handlers in extension's Sentry init, ~50 lines). The full span chain becomes stitchable end-to-end:
useQuery → submitRequestToBackground (span) → messenger (span) →
[BaseDataService.fetchQuery — cache miss, observerAdded → fetching →
Cockatiel attempt 1 → fetch (auto, child of rpc.handler) → 503 →
backoff 200ms → fetch (auto) → 200 → setData → success] →
cacheUpdated → port → UI hydrate
Acceptance Criteria
-
BaseDataServiceexposes either a publicqueryClientgetter or anonCreateconstructor hook (maintainer's choice). - Downstream
queryCache.subscribe(...)wiring composes cleanly from a client-side Sentry init file. A prototype in the extension repo demonstrates the full stack trace fromuseQuerythrough retry through success. - No new UI-facing surface.
- No change to
OmitKeyoftype erasure. - No change to messenger contract.
- No change to proxy
queryFnsemantics.
Labels
area-data-service, area-observability
Dependencies
Related: #8530, #8531 (orthogonal — same epic scope but different surface; not blocking).
Depends on: none.
Dependents: none.
- 主要言語
- TypeScript
- スター
- 424
- フォーク
- 311
- 平均マージ
- 1日 8時間
- マージ済み PR(30日)
- 446
環境構築
- Dockerfile・Docker Compose ファイルなし
- プルリクエストのテンプレートあり
- コントリビューションガイドなし
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
MetaMask/core のほかの issue
-
EIP-1898 object selectors fail before downstream RPC in eth-json-rpc-middleware 26.0.0対応中かも @debojyoti10CC が 5 日前に担当しました。 オープン
難易度 2/5 1〜3時間 初心者へのやさしさ 62/100
メンテナーはふだん 1 日以内に返信
-
CI: "Validate changelog diffs" job fails on every fork-sourced pull request対応中かも @Roxen-AS が 37 日前に担当しました。 オープン
難易度 2/5 1〜3時間 初心者へのやさしさ 84/100
メンテナーはふだん 1 日以内に返信
-
platform-api-docs: `scan` strategy misses ESM-only packages, which ship `.d.ts` rather than `.d.cts`対応中かも @gaohan1994 が 38 日前に担当しました。 オープン
難易度 2/5 1〜3時間 初心者へのやさしさ 76/100
メンテナーはふだん 1 日以内に返信
-
[utils] Replace the `uuid` dependency with `crypto.randomUUID()`対応中かも @avantikonde が 51 日前に担当しました。 オープン
難易度 2/5 1〜3時間 初心者へのやさしさ 82/100
MetaMask/core#10210 · リアクション 1 件 ·
メンテナーはふだん 1 日以内に返信
-
[utils] `toWei` accepts fractional wei and returns wrong values対応中かも @Roxen-AS が 37 日前に担当しました。 オープン
難易度 2/5 1〜3時間 初心者へのやさしさ 88/100
メンテナーはふだん 1 日以内に返信
似ている issue
-
Flaky test: selecting a portion just after inserting it can also match its Change and Delete buttonsオープンready-for-agent
難易度 2/5 1〜3時間 初心者へのやさしさ 84/100
linagora/dcs-onlyoffice#172 ·
-
bug follow-up
難易度 2/5 1〜3時間 初心者へのやさしさ 68/100
メンテナーはふだん 1 日以内に返信
-
nightly-tests
難易度 2/5 1〜3時間 初心者へのやさしさ 68/100
BlackBeltTechnology/pi-agent-dashboard#1226 ·
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 72/100
danielmiessler/LifeOS#3028 ·
メンテナーはふだん 5 日以内に返信
-
execute_sql cannot create a SQLite trigger or a PostgreSQL BEGIN ATOMIC function: the statement is cut at the semicolons inside its body対応中かも @goranai が今日担当しました。 オープン
難易度 2/5 1〜3時間 初心者へのやさしさ 85/100
メンテナーはふだん 1 日以内に返信