Repository navigation
feat(besreceiver): emit bazel.fetch span per Fetch BEP event - #70
Merged
Merged
Conversation
chagui
marked this pull request as ready for review
April 24, 2026 17:30
chagui
force-pushed
the
chagui/besreceiver/issue-61-fetch
branch
3 times, most recently
from
April 25, 2026 12:41
179d3ca to
2777a07
Compare
Fetch events carry external-resource download outcome (success + URL), but were previously dropped. On clean builds dominated by http_archive / module downloads, this hides the first-order cause of slow builds. Each Fetch event now becomes a bazel.fetch span parented to the root bazel.build span with bazel.fetch.url and bazel.fetch.success attributes; failures set span status Error with message "fetch failed". The Fetch proto carries no timing, so the span spans invocation createdAt → now() at event-processing time — bounds the fetch on the flamegraph without claiming a precise duration. Filter behaviour mirrors per-target spans: drop / build_only default_level suppresses bazel.fetch via a new allowFetch() level helper. Empty URL or pre-BuildStarted arrival is silently dropped. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
chagui
force-pushed
the
chagui/besreceiver/issue-61-fetch
branch
from
April 25, 2026 13:03
2777a07 to
f443647
Compare
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.
Makes external dependency downloads (http_archive, http_file, module resolution, OCI, file:// mirrors) visible in the trace flamegraph as
bazel.fetchspans parented to the rootbazel.build. For repos with heavy external surface area, fetch latency is often the dominant cost of clean builds and was previously invisible.Review-driven design choices
user:token@host) is unconditionally stripped — fetch URLs frequently carry credentials inline. The query string is also stripped by default because pre-signed S3/GCS URLs put credentials inX-Amz-*parameters; operators who need them (debugging custom mirrors, version-pin tracking) opt in viapii.include_fetch_query_string: true. Redaction lives in a newredactFetchURLhelper and is applied to both the span attribute and the log body. Non-RFC-3986 references (oci://repo/image@sha256:…,file://mirrors) pass through unmodified rather than being dropped.handleFetchnow runsstate.filter.LevelForTarget("").allowFetch()once, at the top of the handler, before any log or span work. Drop / build_only operators no longer leak the URL into logs while suppressing the span. Per-rule patterns don't apply to fetches (no owning target, so the filter falls through todefault_level); this is documented explicitly indocs/attributes.md.start = invocation createdAt, end = time.Now(), which painted every fetch as a build-stream-spanning bar. The span is now zero-width at event-processing time — correctly indicating "this fetch happened" without fabricating duration. ThreadingOrderedBuildEvent.Event.EventTimefor richer timing is a follow-up if real per-event timestamps become useful.FetchId.Downloaderenum, and a per-invocation sequence counter (state.fetchSeq). Repeated fetches of the same URL — transient retries, multi-arch toolchain pulls,repository_cacheevictions — produce distinct SpanIDs that downstream backends do not collapse.bazel.fetch.downloaderattribute. Surfaces theFetchId.Downloaderenum (HTTP,GRPC,UNKNOWN) so retries via different transports are visible in queries.fetch failed: <url>status message. The redacted URL is included in the failure status so the trace identifies which fetch broke without forcing operators to cross-reference span attrs.Tests added
7 new on top of the existing 6: userinfo redaction (span + log), query-string default-strip, query-string opt-in, non-standard URL pass-through, downloader attribute, same-URL distinct SpanIDs, instant span timing, late post-flush emission, filter-suppresses-log-too.
Deferred to follow-up
url.fullalignment (dual-emit vs rename) — needs schema discussion.OrderedBuildEvent.Event.EventTimethrougheventMsgfor a real per-event timestamp.nolint:gocyclooneventTypeNamewith amap[reflect.Type]stringdispatch — applies to every dispatch site, scoped out of this PR.Closes #61.