Repository navigation
feat(discover): per-HTTP instrument hook for consumer-facing telemetry - #4
Merged
Merged
Conversation
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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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 typeInstrumentHook = <T>(name, fn) => Promise<T>. The library wraps every HTTP step inconfig.instrument?.(name, fn) ?? fn()— zero overhead when omitted, transparent when supplied. Named steps:ghcr-token,fetch-target-manifest,list-patch-tags,fetch-chain-manifest,download-patchfetch-releases,download-patchAdditive & backward-compatible. Minor bump 0.2.0 → 0.3.0.
Tests
list-patch-tags) to a bare call turns the new test RED — non-vacuous guard on the wrapper.