Repository navigation
feat(besreceiver): stamp bazel.patterns on root span from PatternExpanded - #71
Merged
Merged
Conversation
chagui
marked this pull request as ready for review
April 25, 2026 08:01
chagui
force-pushed
the
chagui/besreceiver/issue-62-patterns
branch
2 times, most recently
from
April 25, 2026 12:44
df68ad6 to
6b0922a
Compare
…nded Buffer PatternExpanded events per invocation (map pattern -> target_count) and emit them as a bazel.patterns Slice[Map] on the root bazel.build span during writeRootSpan. Entries are aggregated by pattern string across events, sorted lexicographically, and capped by the new high_cardinality_caps.patterns field (default 50). Truncation appends a truncationRecord and the trace-builder logs a warning matching the #29 shape (invocation_id, attribute, original_count, kept). Closes #62. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
chagui
force-pushed
the
chagui/besreceiver/issue-62-patterns
branch
from
April 25, 2026 13:18
6b0922a to
20ead1f
Compare
4 tasks done
chagui
added a commit
that referenced
this pull request
Apr 25, 2026
…rn_skipped (#75) Three P0 corrections to bazel.patterns from the post-merge review of #71: 1. target_count filters to TargetConfigured children. Previously len(children) counted nested PatternExpanded ids and UnconfiguredLabel failure markers, inflating the reported count of resolved targets. 2. Multi-pattern events even-split target_count across the event's non-empty patterns (floor(M/N)). The proto carries no per-pattern attribution; the prior code stamped the full count to each pattern, summing to N×M across the slice. Single-pattern events — Bazel's dominant case — keep the exact count. Eliminates the inflation that the prior multi-pattern test had cemented as the contract. 3. pattern_skipped events route to a new bazel.patterns_skipped Slice[string] on the root span, instead of being silently dropped. Bazel emits these under --keep_going for parts of a top-level pattern whose expansion was skipped. eventTypeName surfaces them under a distinct event_type label so bes.events.processed counts the two id shapes separately. Test coverage added: NonTargetConfiguredChildren_NotCounted, PatternSkipped_EmitsSkippedAttribute, PatternSkippedOnly_NoPatternsAttribute, PostFlush_Dropped. The existing multi-pattern test is renamed and updated to assert the corrected even-split semantics. docs/attributes.md drops the "1,400 tests" example and documents the new semantics + the new attribute. Refs #62, follow-up to #71. Co-authored-by: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
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.
Surfaces
PatternExpandedevents as a Slice[Map] attributebazel.patternson the rootbazel.buildspan. Each entry is{pattern, target_count}aggregated by pattern across the invocation. Test-heavy repos that invokebazel test //...get a self-describing trace — the difference between "asked for one thing" and "ran 1,400 tests" is now visible without correlating against external logs. Empty patterns and zero-target expansions are skipped.Capped under
high_cardinality_caps.patterns(default 50) following the #29 pattern. Truncation surfaces a warning log via the new[]truncationRecordreturn fromwriteRootSpan— same shape as the BuildMetrics truncation pipeline. Aggregation is done over amap[string]int64buffered oninvocationStateand stamped duringwriteRootSpan, identical to the workspace_items / build_metadata buffering. Empty buffer → no attribute, so absent vs present-but-empty stays a meaningful distinction.One proto-shape note worth flagging: the pattern strings live on
BuildEventId.pattern.pattern(repeated on the id), not on thePatternExpandedpayload itself. The payload only carriestest_suite_expansions.target_countis derived fromlen(event.children)— each child id is a target (or nested pattern) the expansion resolved to.Required signature changes for the truncation plumbing:
writeRootSpannow returns[]truncationRecord, which threads throughfinalizeandflushOrphaned. Both existing callers intracebuilder.goupdated to consume and warn-log the records. Distinct log message ("Truncated high-cardinality root-span attribute") so operators can filter from the BuildMetrics-side warning by namespace.Closes #62.