Repository navigation
feat(besreceiver): stamp bazel.run attrs from ExecRequestConstructed - #69
Merged
Merged
Conversation
chagui
force-pushed
the
chagui/besreceiver/issue-63-exec-request
branch
from
April 25, 2026 08:00
4505158 to
4aa9fd1
Compare
chagui
marked this pull request as ready for review
April 25, 2026 08:01
Bazel emits ExecRequestConstructed only for `bazel run` invocations, after the build succeeds and just before the target is exec'd. Until now the event was dropped (see #26), leaving `bazel run` traces indistinguishable from `bazel build` at the root span. Buffer the single per-invocation payload on invocationState alongside WorkspaceStatus / StructuredCommandLine and stamp five attributes on the root bazel.build span during writeRootSpan: - bazel.run.argv (Slice[string]) — PII.IncludeCommandArgs - bazel.run.environment (Slice[Map{name,value}])— PII.IncludeCommandArgs - bazel.run.working_directory (string) — PII.IncludeWorkingDir - bazel.run.environment_variable_count (int) — always emitted - bazel.run.should_exec (bool) — always emitted Count and should_exec are emitted even when details are redacted so operators retain a "run invocation arrived" signal. argv and environment share the IncludeCommandArgs gate because env commonly carries argv-adjacent secrets. Issue #63. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
chagui
force-pushed
the
chagui/besreceiver/issue-63-exec-request
branch
from
April 25, 2026 09:32
4aa9fd1 to
a13ca2b
Compare
chagui
added a commit
that referenced
this pull request
Apr 25, 2026
…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.
chagui
added a commit
that referenced
this pull request
Apr 25, 2026
…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.
chagui
added a commit
that referenced
this pull request
Apr 25, 2026
…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.
chagui
added a commit
that referenced
this pull request
Apr 25, 2026
…cted (#69) (#74) 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.
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.
On
bazel runinvocations Bazel emitsExecRequestConstructedcarrying the final argv, working directory, environment, env-vars-to-unset, and whether the process will actually exec. The PR exposes those on five always-on counts/booleans plus four PII-gated detail attributes sobazel runtraces are self-describing without operators having to correlate by command name.bazel build/bazel testinvocations emit nothing here.Review-driven design choices
ExecRequestConstructed"after a successful build and before trying to execute" — i.e. it can arrive afterBuildFinishedon the wire. The receiver handles both orderings: pre-flush, attrs land on the rootbazel.buildspan (current design); post-flush, the receiver emits a standalonebazel.runchild span (parented to the root via traceID/spanID) carrying the same attrs through a newlateRunSpanhelper. Without this, everybazel runinvocation would silently emit emptybazel.run.*attrs.IncludeRunEnvironmentfromIncludeCommandArgs. Run environments routinely carry credentials, tokens, and host-derived secrets that command-line arguments do not. The original PR re-usedIncludeCommandArgsfor both axes; the gates are now independent so operators can show argv without exposing env, and vice versa. Docstrings anddocs/attributes.mdare updated accordingly.environment_variable_to_clear(proto field 4) emitted. Previously dropped silently — operators saw the env-set list, ran a repro with those vars, and got different behavior because exec also unset others. Now exposed as both a slice and an always-on count.utf8.ValidStringguard per cast site).truncateAttrValuehelper. The always-on count attributes report the full payload size, not the capped slice, so operators see the truth even when emission is clipped.Deferred to follow-up
process.command_args/process.runtime.environment) — separate task, requires schema discussion.nolint:gocycloreplacement oneventTypeNamewith amap[reflect.Type]string— applies project-wide to every dispatch site, scoped out of this PR.Closes #63.