Skip to content

feat(discover): per-HTTP instrument hook for consumer-facing telemetry - #4

Merged
BYK merged 2 commits into
mainfrom
feat/per-http-instrument
Jul 25, 2026
Merged

BYK merged 2 commits into
mainfrom
feat/per-http-instrument

Conversation

@BYK

@BYK BYK commented Jul 25, 2026

Copy link
Copy Markdown
Owner

Why

Consumers (notably getsentry/cli) want per-HTTP tracing spans around each registry/API call the library makes on their behalf. binpatch's 3 coarse telemetry hooks (onResolved/onOfflineMiss/onUnavailable) collapse the inner per-fetch timing into a single span — fine for Lore but loses observability for Sentry's own CLI, which currently wraps every HTTP step in withTracing('http.client', ...).

What

Add an optional instrument? field on GhcrSourceConfig and GitHubReleaseSourceConfig of type InstrumentHook = <T>(name, fn) => Promise<T>. The library wraps every HTTP step in config.instrument?.(name, fn) ?? fn() — zero overhead when omitted, transparent when supplied. Named steps:

  • ghcrSource: ghcr-token, fetch-target-manifest, list-patch-tags, fetch-chain-manifest, download-patch
  • githubReleaseSource: fetch-releases, download-patch

Additive & backward-compatible. Minor bump 0.2.0 → 0.3.0.

Tests

  • New: assert every named ghcrSource HTTP step flows through the hook (full 1-hop chain mock + assert all 5 names appear). 54/54 pass, typecheck + build green.
  • Mutation-verified: reverting one site (list-patch-tags) to a bare call turns the new test RED — non-vacuous guard on the wrapper.

BYK added 2 commits July 25, 2026 10:16
Consumers (notably getsentry/cli) want per-HTTP tracing spans around each
registry/API call the library makes on their behalf. binpatch exposes 3
coarse telemetry hooks (onResolved/onOfflineMiss/onUnavailable) but those
collapse the inner per-fetch timing into a single span, losing observability
for Sentry's own CLI.

Add an optional `instrument?` field on GhcrSourceConfig and
GitHubReleaseSourceConfig of type `InstrumentHook = <T>(name, fn) => Promise<T>`.
The library wraps every HTTP step in `config.instrument?.(name, fn) ?? fn()` —
zero overhead when omitted, transparent when supplied. Named steps:

  - ghcrSource:        ghcr-token, fetch-target-manifest, list-patch-tags,
                       fetch-chain-manifest, download-patch
  - githubReleaseSource: fetch-releases, download-patch

Additive & backward-compatible. New tests assert all named steps flow through
the hook; mutation-verified (reverting one site to a bare call turns the
test RED). Minor bump 0.2.0 -> 0.3.0.
…hook

Adversarial review NIT: the initial PR only exercised the ghcrSource
instrument step names; the githubReleaseSource paths (fetch-releases,
download-patch) relied on the symmetry of the local `i` helper without
direct test coverage.

Add a test that drives a full githubReleaseSource.resolveChain against a
mocked GitHub Release API and asserts both named steps flow through the
hook. Mutation-verified: renaming the step name makes the test RED — the
assertion checks the exact label, not just call counts.
@BYK
BYK merged commit 2ad3b4b into main Jul 25, 2026
1 check passed
@BYK
BYK deleted the feat/per-http-instrument branch July 25, 2026 10:46
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.

1 participant