Skip to content

Track server Instance ID in BuildMetrics BES event - #29817

Closed
alexander-scott wants to merge 1 commit into
bazelbuild:masterfrom
alexander-scott:track_previous_server_invocation_id_in_bes_event
Closed

alexander-scott wants to merge 1 commit into
bazelbuild:masterfrom
alexander-scott:track_previous_server_invocation_id_in_bes_event

Conversation

@alexander-scott

@alexander-scott alexander-scott commented Jun 12, 2026 •

Copy link
Copy Markdown
Contributor

Description

This PR adds a new field to the CumulativeMetrics message that belongs to the BuildMetrics BES event. The field is named instance_id, and is simply the instance ID of the current running server. It will persist across builds on the server, but if the server is killed and restarted, it will be a cold start and therefore have a brand new instance ID.

Motivation

To help debug incrementality or performance issues, it's often handy to work out what ran on the Bazel server directly before my build. Tracking this allows us to fetch metrics/logs for invocations that ran on the server with this instance ID and diff stats/metrics/inputs/outputs to understand why the current build behaved the way it did.

The instance ID and also the previous invocation ID is already available in the server log, but putting it here as well alongside the other cumulative metrics makes it even more accessible.

Build API Changes

No

Checklist

  • I have added tests for the new use cases (if any).
  • I have updated the documentation (if applicable).

Release Notes

RELNOTES: Added a new instance_id field to the BuildMetrics BES event, in order to help diff between the current and previous builds on the running server.

@alexander-scott alexander-scott changed the title Track previous invocation ID on server in BES event Track previous invocation ID on server in BuildMetrics BES event Jun 12, 2026
@alexander-scott
alexander-scott marked this pull request as ready for review June 19, 2026 08:45
@github-actions github-actions Bot added team-Performance Issues for Performance teams awaiting-review PR is awaiting review from an assigned reviewer labels Jun 19, 2026
@meisterT

Copy link
Copy Markdown
Member

I think I would prefer exposing the instanceId, see

UUID instanceId = (this.instanceId == null) ? UUID.randomUUID() : this.instanceId;

@meisterT meisterT added awaiting-user-response Awaiting a response from the author and removed awaiting-review PR is awaiting review from an assigned reviewer labels Jul 1, 2026
@alexander-scott
alexander-scott force-pushed the track_previous_server_invocation_id_in_bes_event branch from 14156b6 to eaa0988 Compare July 8, 2026 01:17
@alexander-scott alexander-scott changed the title Track previous invocation ID on server in BuildMetrics BES event Track server Instance ID in BuildMetrics BES event Jul 8, 2026
@alexander-scott

alexander-scott commented Jul 8, 2026 •

Copy link
Copy Markdown
Contributor Author

Hi @meisterT, I've updated the PR based on your feedback. I believe the CI failures are unrelated to the changes Rebased on master

To help debug incrementality or performance issues, it's often handy
to work out which invocations ran on the same Bazel server as my
build.

Expose the server's instance UUID in BuildMetrics.CumulativeMetrics,
alongside the other server-lifetime metrics. Invocations that report
the same instance_id shared a server (and therefore its incremental
state), which makes it possible to fetch and diff
stats/metrics/inputs/outputs against earlier invocations on the same
server.

The instance ID was previously created in BlazeRuntime.Builder.build()
and only handed to modules via blazeStartup(); it is now also retained
on BlazeRuntime with a getter, so it can be read anywhere the
CommandEnvironment is available.
@alexander-scott
alexander-scott force-pushed the track_previous_server_invocation_id_in_bes_event branch from eaa0988 to 281c49f Compare July 8, 2026 04:29
@meisterT meisterT added awaiting-PR-merge PR has been approved by a reviewer and is ready to be merge internally and removed awaiting-user-response Awaiting a response from the author labels Jul 8, 2026
copybara-service Bot pushed a commit to bazelbuild/intellij that referenced this pull request Jul 15, 2026
โ€ฆl#29817)

### Description

This PR adds a new field to the `CumulativeMetrics` message that belongs to the `BuildMetrics` BES event. The field is named `instance_id`, and is simply the instance ID of the current running server. It will persist across builds on the server, but if the server is killed and restarted, it will be a cold start and therefore have a brand new instance ID.

### Motivation

To help debug incrementality or performance issues, it's often handy to work out what ran on the Bazel server directly before my build. Tracking this allows us to fetch metrics/logs for invocations that ran on the server with this instance ID and diff stats/metrics/inputs/outputs to understand why the current build behaved the way it did.

The instance ID and also the previous invocation ID is already available in the server log, but putting it here as well alongside the other cumulative metrics makes it even more accessible.

### Build API Changes

No

### Checklist

- [x] I have added tests for the new use cases (if any).
- [x] I have updated the documentation (if applicable).

### Release Notes

RELNOTES: Added a new `instance_id` field to the `BuildMetrics` BES event, in order to help diff between the current and previous builds on the running server.

Closes #29817.

PiperOrigin-RevId: 948419715
@github-actions github-actions Bot removed the awaiting-PR-merge PR has been approved by a reviewer and is ready to be merge internally label Jul 15, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

team-Performance Issues for Performance teams

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants