Repository navigation
feat(besreceiver): apply review-fix follow-ups for ExecRequestConstructed (#69) - #74
Conversation
8125aeb to
9a3b145
Compare
|
Round-2 review fixes amended (force-push pending). P0 — P1 — UTF-8 filter ordering symmetric across argv/env/env-to-clear. All three helpers now follow the same shape: UTF-8 filter raw bytes → sort (env / env-to-clear) → cap → emit. P1 — P2 polish (sort.SliceStable, argv 355 tests + lint green at |
…cted (#69) Lands the review feedback that was prepared for #69 but did not reach main before the merge. The PR-#69 commit body in main describes the pre-review-fix design (single PII gate, no late path, no environment_variable_to_clear, byte-boundary truncation, no UTF-8 validation); this commit brings the implementation in line with the agreed review outcome. - Late post-flush handling: when ExecRequestConstructed arrives after BuildFinished (the production wire order per BEP proto:1461-1462), the receiver emits a standalone bazel.run child span parented to the root via traceID/spanID rather than silently dropping the attrs. - environment_variable_to_clear (proto field 4) emitted as a slice plus always-on bazel.run.environment_variable_to_clear_count for parity with the existing environment_variable_count. - IncludeRunEnvironment PII gate split from IncludeCommandArgs. Run environments routinely carry credentials and host secrets that argv does not; the gates are now independent. - UTF-8 validation on every bytes→string cast. Non-UTF-8 entries are silently skipped because OTLP/JSON exporters reject invalid encoding and that failure cascades the entire span batch. - Bounded argv/env emission. argv capped at 200 entries, env at 50, env- to-clear at 50; per-value bytes clipped at 256 via truncateAttrValue. Always-on count attributes still report the full payload size so operators see truncation explicitly. - Server-side env sort. Bazel emits env in process-environ iteration order which is not stable across OSes; sorting in the receiver makes emission deterministic regardless of how Bazel sees the environ. Tests: 8 new — late post-flush, pre-BuildStarted drop, environment_variable_to_clear, non-UTF-8 skipped, argv/env caps, split PII gates (argv-only and env-only). Docs updated: docs/attributes.md and collector-config.yaml.
9a3b145 to
4c16199
Compare
Lands the review feedback that was prepared for #69 but did not reach
mainbefore the merge — plus the consensus P0/P1 list from #74's own review. The squash-merged #69 in main describes the pre-review-fix design (single PII gate, noenvironment_variable_to_clear, byte-boundary truncation, no UTF-8 validation, no late-path handling, silent argv/env truncation). This PR brings the implementation in line with the reviewers' agreed outcome.Review-driven fixes applied this round
P0 (must fix before merge — codex held P0 for the cluster):
lateRunSpannow stamps a zero-width span at handler-time (time.Now()) — start == end, both non-zero. Previously the span had epoch timestamps, which OTLP backends interpret as 1970 and either reject or display as off-the-flamegraph. Mirrors thepopulateFetchSpanpattern.ExecRequestConstructedper invocation, but BES gRPC reconnect/replay can violate it. NewrunEmitted booloninvocationStategates the late-path branch — a duplicate post-flush event now logs Warn and drops, instead of emitting a secondbazel.runspan with the same SpanID (which downstream backends collapse or reject). Pre-flush re-stamping is naturally idempotent so no separate guard is needed there.P1 (3/3 reviewer consensus):
applyExecRequestArgv,applyExecRequestEnv, andapplyExecRequestEnvToClearnow thread[]truncationRecordthrough and append a record on cap. Pre-flush records ridewriteRootSpan's existing root-span Warn loop; post-flush records are logged fromhandleExecRequestConstructed. Matches theapplyPatternAttrs/appendGarbageMetricspattern.bazel.run.argv_count(always-on). Parallelsenvironment_variable_countso operators see the raw argv payload size even when the slice is capped orIncludeCommandArgsis closed. All three count attributes now report pre-cap totals.handleExecRequestConstructedlogs the late-path emission at Info (visible in production) instead of Debug (suppressed). Truncations during late emission also log at Warn.P2 (consensus polish):
TestExecRequest_WireOrderParityruns the same payload through both pre-flush and post-flush wire orders × {drop, build_only, targets, verbose} and asserts byte-identicalbazel.run.*output — formalizes the design choice thatbazel.runis filter-exempt because it carries displaced root-span data. A symmetric receiver-wideallowRun()gate is tracked separately as a follow-up; opening would create wire-order-dependent output, which is strictly worse.findRunSpanstest helper. Replaces the hand-rolled four-level pdata iteration inTestExecRequest_LatePostFlush. Same shape asfindFetchSpans.TestExecRequest_LatePostFlushasserts SpanID identity (spanIDFromIdentity(uuid, "run")) and non-zero zero-width timestamps — would have caught the P0 bugs immediately.TestExecRequest_LateDuplicateDropped. Regression guard for the newrunEmittedflag.TestExecRequest_TruncationRecordsEmitted. Asserts the Warn-log contract viazaptest/observer, parallel to existing pattern-truncation tests.maxRunArgvEntries/maxRunEnvEntries/maxRunEnvClearEntriescites observed shapes ("argv rarely exceeds 150 entries; OS-typical env has 30-100 entries").docs/attributes.md(attribute table footer covers argv strings, env names/values, working_directory, env-to-clear names).env_countDebug log key renamed toenv_var_countfor parity withenv_to_clear_count.Lifted from #69 review (already in this PR pre-#74-review)
lateRunSpan(against silent drop)environment_variable_to_clearemitted with always-on countIncludeRunEnvironmentPII gate split fromIncludeCommandArgstruncateAttrValueTests
12 new across the two review rounds: late post-flush (existing), pre-
BuildStarteddrop,environment_variable_to_clear, non-UTF-8 skipped, argv-cap, env-cap,IncludeCommandArgs-only,IncludeRunEnvironment-only, late-duplicate dropped, wire-order parity (4 sub-cases), truncation records emitted. Totalreceiver/besreceivercount: 354.Deferred to follow-ups
bes_receiver_late_run_spans_totalmetric (new counter, separate concern from the trace path).allowRun()symmetric filter gate. Single-side gating would create wire-order-dependent output; the test asserting parity is the placeholder until a coherent design lands.attrs.go(file-widemaxAttrValueLen) andinvocation.go(per-feature caps). Cosmetic.Cross-references #69 (the original feature) and the review summaries at
/tmp/besreceiver-reviews/pr-69-review.mdand/tmp/besreceiver-reviews/pr-74-review.md.