1// Copyright 2016 The Bazel Authors. All rights reserved. 2// 3// Licensed under the Apache License, Version 2.0 (the "License"); 4// you may not use this file except in compliance with the License. 5// You may obtain a copy of the License at 6// 7// http://www.apache.org/licenses/LICENSE-2.0 8// 9// Unless required by applicable law or agreed to in writing, software 10// distributed under the License is distributed on an "AS IS" BASIS, 11// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12// See the License for the specific language governing permissions and 13// limitations under the License. 14 15syntax = "proto3"; 16 17package build_event_stream; 18 19import "google/protobuf/duration.proto"; 20import "google/protobuf/timestamp.proto"; 21import "src/main/protobuf/command_line.proto"; 22import "src/main/protobuf/failure_details.proto"; 23import "src/main/protobuf/invocation_policy.proto"; 24 25option java_package = "com.google.devtools.build.lib.buildeventstream"; 26option java_outer_classname = "BuildEventStreamProtos"; 27 28// Identifier for a build event. It is deliberately structured to also provide 29// information about which build target etc the event is related to. 30// 31// Events are chained via the event id as follows: each event has an id and a 32// set of ids of children events such that apart from the initial event each 33// event has an id that is mentioned as child id in an earlier event and a build 34// invocation is complete if and only if all direct and indirect children of the 35// initial event have been posted. 36message BuildEventId { 37 // Generic identifier for a build event. This is the default type of 38 // BuildEventId, but should not be used outside testing; nevertheless, 39 // tools should handle build events with this kind of id gracefully. 40 message UnknownBuildEventId { 41 string details = 1; 42 } 43 44 // Identifier of an event reporting progress. Those events are also used to 45 // chain in events that come early. 46 message ProgressId { 47 // Unique identifier. No assumption should be made about how the ids are 48 // assigned; the only meaningful operation on this field is test for 49 // equality. 50 int32 opaque_count = 1; 51 } 52 53 // Identifier of an event indicating the beginning of a build; this will 54 // normally be the first event. 55 message BuildStartedId {} 56 57 // Identifier on an event indicating the original commandline received by 58 // the bazel server. 59 message UnstructuredCommandLineId {} 60 61 // Identifier on an event describing the commandline received by Bazel. 62 message StructuredCommandLineId { 63 // A title for this command line value, as there may be multiple. 64 // For example, a single invocation may wish to report both the literal and 65 // canonical command lines, and this label would be used to differentiate 66 // between both versions. 67 string command_line_label = 1; 68 } 69 70 // Identifier of an event indicating the workspace status. 71 message WorkspaceStatusId {} 72 73 // Identifier on an event reporting on the options included in the command 74 // line, both explicitly and implicitly. 75 message OptionsParsedId {} 76 77 // Identifier of an event reporting that an external resource was fetched 78 // from. 79 message FetchId { 80 // The external resource that was fetched from. 81 string url = 1; 82 } 83 84 // Identifier of an event indicating that a target pattern has been expanded 85 // further. 86 // Messages of this shape are also used to describe parts of a pattern that 87 // have been skipped for some reason, if the actual expansion was still 88 // carried out (e.g., if keep_going is set). In this case, the 89 // pattern_skipped choice in the id field is to be made. 90 message PatternExpandedId { 91 repeated string pattern = 1; 92 } 93 94 message WorkspaceConfigId {} 95 96 message BuildMetadataId {} 97 98 // Identifier of an event indicating that a target has been expanded by 99 // identifying for which configurations it should be build. 100 message TargetConfiguredId { 101 string label = 1; 102 103 // If empty, the id refers to the expansion of the target. If not-empty, 104 // the id refers to the expansion of an aspect applied to the (already 105 // expanded) target. 106 // 107 // For example, when building an apple_binary that depends on proto_library 108 // "//:foo_proto", there will be two TargetConfigured events for 109 // "//:foo_proto": 110 // 111 // 1. An event with an empty aspect, corresponding to actions producing 112 // language-agnostic outputs from the proto_library; and 113 // 2. An event with aspect "ObjcProtoAspect", corresponding to Objective-C 114 // code generation. 115 string aspect = 2; 116 } 117 118 // Identifier of an event introducing a named set of files (usually artifacts) 119 // to be referred to in later messages. 120 message NamedSetOfFilesId { 121 // Identifier of the file set; this is an opaque string valid only for the 122 // particular instance of the event stream. 123 string id = 1; 124 } 125 126 // Identifier of an event introducing a configuration. 127 message ConfigurationId { 128 // Identifier of the configuration; users of the protocol should not make 129 // any assumptions about it having any structure, or equality of the 130 // identifier between different streams. 131 string id = 1; 132 } 133 134 // Identifier of an event indicating that a target was built completely; this 135 // does not include running the test if the target is a test target. 136 message TargetCompletedId { 137 string label = 1; 138 139 // The configuration for which the target was built. 140 ConfigurationId configuration = 3; 141 142 // If empty, the id refers to the completion of the target. If not-empty, 143 // the id refers to the completion of an aspect applied to the (already 144 // completed) target. 145 // 146 // For example, when building an apple_binary that depends on proto_library 147 // "//:foo_proto", there will be two TargetCompleted events for 148 // "//:foo_proto": 149 // 150 // 1. An event with an empty aspect, corresponding to actions producing 151 // language-agnostic outputs from the proto_library; and 152 // 2. An event with aspect "ObjcProtoAspect", corresponding to Objective-C 153 // code generation. 154 string aspect = 2; 155 } 156 157 // Identifier of an event reporting that an action was completed (not all 158 // actions are reported, only the ones that can be considered important; 159 // this includes all failed actions). 160 message ActionCompletedId { 161 string primary_output = 1; 162 // Optional, the label of the owner of the action, for reference. 163 string label = 2; 164 // Optional, the id of the configuration of the action owner. 165 ConfigurationId configuration = 3; 166 } 167 168 // Identifier of an event reporting an event associated with an unconfigured 169 // label. Usually, this indicates a failure due to a missing input file. In 170 // any case, it will report some form of error (i.e., the payload will be an 171 // Aborted event); there are no regular events using this identifier. The 172 // purpose of those events is to serve as the root cause of a failed target. 173 message UnconfiguredLabelId { 174 string label = 1; 175 } 176 177 // Identifier of an event reporting an event associated with a configured 178 // label, usually a visibility error. In any case, an event with such an 179 // id will always report some form of error (i.e., the payload will be an 180 // Aborted event); there are no regular events using this identifier. 181 message ConfiguredLabelId { 182 string label = 1; 183 ConfigurationId configuration = 2; 184 } 185 186 // Identifier of an event reporting on an individual test run. The label 187 // identifies the test that is reported about, the remaining fields are 188 // in such a way as to uniquely identify the action within a build. In fact, 189 // attempts for the same test, run, shard triple are counted sequentially, 190 // starting with 1. 191 message TestResultId { 192 string label = 1; 193 ConfigurationId configuration = 5; 194 int32 run = 2; 195 int32 shard = 3; 196 int32 attempt = 4; 197 } 198 199 // Identifier of an event reporting the summary of a test. 200 message TestSummaryId { 201 string label = 1; 202 ConfigurationId configuration = 2; 203 } 204 205 // Identifier of an event reporting the summary of a target. 206 message TargetSummaryId { 207 string label = 1; 208 ConfigurationId configuration = 2; 209 } 210 211 // Identifier of the BuildFinished event, indicating the end of a build. 212 message BuildFinishedId {} 213 214 // Identifier of an event providing additional logs/statistics after 215 // completion of the build. 216 message BuildToolLogsId {} 217 218 // Identifier of an event providing build metrics after completion 219 // of the build. 220 message BuildMetricsId {} 221 222 // Identifier of an event providing convenience symlinks information. 223 message ConvenienceSymlinksIdentifiedId {} 224 225 oneof id { 226 UnknownBuildEventId unknown = 1; 227 ProgressId progress = 2; 228 BuildStartedId started = 3; 229 UnstructuredCommandLineId unstructured_command_line = 11; 230 StructuredCommandLineId structured_command_line = 18; 231 WorkspaceStatusId workspace_status = 14; 232 OptionsParsedId options_parsed = 12; 233 FetchId fetch = 17; 234 ConfigurationId configuration = 15; 235 TargetConfiguredId target_configured = 16; 236 PatternExpandedId pattern = 4; 237 PatternExpandedId pattern_skipped = 10; 238 NamedSetOfFilesId named_set = 13; 239 TargetCompletedId target_completed = 5; 240 ActionCompletedId action_completed = 6; 241 UnconfiguredLabelId unconfigured_label = 19; 242 ConfiguredLabelId configured_label = 21; 243 TestResultId test_result = 8; 244 TestSummaryId test_summary = 7; 245 TargetSummaryId target_summary = 26; 246 BuildFinishedId build_finished = 9; 247 BuildToolLogsId build_tool_logs = 20; 248 BuildMetricsId build_metrics = 22; 249 WorkspaceConfigId workspace = 23; 250 BuildMetadataId build_metadata = 24; 251 ConvenienceSymlinksIdentifiedId convenience_symlinks_identified = 25; 252 } 253} 254 255// Payload of an event summarizing the progress of the build so far. Those 256// events are also used to be parents of events where the more logical parent 257// event cannot be posted yet as the needed information is not yet complete. 258message Progress { 259 // The next chunk of stdout that bazel produced since the last progress event 260 // or the beginning of the build. 261 string stdout = 1; 262 263 // The next chunk of stderr that bazel produced since the last progress event 264 // or the beginning of the build. 265 string stderr = 2; 266} 267 268// Payload of an event indicating that an expected event will not come, as 269// the build is aborted prematurely for some reason. 270message Aborted { 271 enum AbortReason { 272 UNKNOWN = 0; 273 274 // The user requested the build to be aborted (e.g., by hitting Ctl-C). 275 USER_INTERRUPTED = 1; 276 277 // The user requested that no analysis be performed. 278 NO_ANALYZE = 8; 279 280 // The user requested that no build be carried out. 281 NO_BUILD = 9; 282 283 // The build or target was aborted as a timeout was exceeded. 284 TIME_OUT = 2; 285 286 // The build or target was aborted as some remote environment (e.g., for 287 // remote execution of actions) was not available in the expected way. 288 REMOTE_ENVIRONMENT_FAILURE = 3; 289 290 // Failure due to reasons entirely internal to the build tool, i.e. an 291 // unexpected crash due to programmer error. 292 INTERNAL = 4; 293 294 // A Failure occurred in the loading phase of a target. 295 LOADING_FAILURE = 5; 296 297 // A Failure occurred in the analysis phase of a target. 298 ANALYSIS_FAILURE = 6; 299 300 // Target build was skipped (e.g. due to incompatible CPU constraints). 301 SKIPPED = 7; 302 303 // Build incomplete due to an earlier build failure (e.g. --keep_going was 304 // set to false causing the build be ended upon failure). 305 INCOMPLETE = 10; 306 307 // The build tool ran out of memory and crashed. 308 OUT_OF_MEMORY = 11; 309 } 310 AbortReason reason = 1; 311 312 // A human readable description with more details about there reason, where 313 // available and useful. 314 string description = 2; 315} 316 317// Payload of an event indicating the beginning of a new build. Usually, events 318// of those type start a new build-event stream. The target pattern requested 319// to be build is contained in one of the announced child events; it is an 320// invariant that precisely one of the announced child events has a non-empty 321// target pattern. 322message BuildStarted { 323 string uuid = 1; 324 325 // Start of the build in ms since the epoch. 326 // 327 // Deprecated, use `start_time` instead. 328 // 329 // TODO(yannic): Remove. 330 int64 start_time_millis = 2 [deprecated = true]; 331 332 // Start of the build. 333 google.protobuf.Timestamp start_time = 9; 334 335 // Version of the build tool that is running. 336 string build_tool_version = 3; 337 338 // A human-readable description of all the non-default option settings 339 string options_description = 4; 340 341 // The name of the command that the user invoked. 342 string command = 5; 343 344 // The working directory from which the build tool was invoked. 345 string working_directory = 6; 346 347 // The directory of the workspace. 348 string workspace_directory = 7; 349 350 // The process ID of the Bazel server. 351 int64 server_pid = 8; 352} 353 354// Configuration related to the blaze workspace and output tree. 355message WorkspaceConfig { 356 // The root of the local blaze exec root. All output files live underneath 357 // this at "blaze-out/". 358 string local_exec_root = 1; 359} 360 361// Payload of an event reporting the command-line of the invocation as 362// originally received by the server. Note that this is not the command-line 363// given by the user, as the client adds information about the invocation, 364// like name and relevant entries of rc-files and client environment variables. 365// However, it does contain enough information to reproduce the build 366// invocation. 367message UnstructuredCommandLine { 368 repeated string args = 1; 369} 370 371// Payload of an event reporting on the parsed options, grouped in various ways. 372message OptionsParsed { 373 repeated string startup_options = 1; 374 repeated string explicit_startup_options = 2; 375 repeated string cmd_line = 3; 376 repeated string explicit_cmd_line = 4; 377 blaze.invocation_policy.InvocationPolicy invocation_policy = 5; 378 string tool_tag = 6; 379} 380 381// Payload of an event indicating that an external resource was fetched. This 382// event will only occur in streams where an actual fetch happened, not in ones 383// where a cached copy of the entity to be fetched was used. 384message Fetch { 385 bool success = 1; 386} 387 388// Payload of an event reporting the workspace status. Key-value pairs can be 389// provided by specifying the workspace_status_command to an executable that 390// returns one key-value pair per line of output (key and value separated by a 391// space). 392message WorkspaceStatus { 393 message Item { 394 string key = 1; 395 string value = 2; 396 } 397 repeated Item item = 1; 398} 399 400// Payload of an event reporting custom key-value metadata associated with the 401// build. 402message BuildMetadata { 403 // Custom metadata for the build. 404 map<string, string> metadata = 1; 405} 406 407// Payload of an event reporting details of a given configuration. 408message Configuration { 409 string mnemonic = 1; 410 string platform_name = 2; 411 string cpu = 3; 412 map<string, string> make_variable = 4; 413 // Whether this configuration is used for building tools. 414 bool is_tool = 5; 415} 416 417// Payload of the event indicating the expansion of a target pattern. 418// The main information is in the chaining part: the id will contain the 419// target pattern that was expanded and the children id will contain the 420// target or target pattern it was expanded to. 421message PatternExpanded { 422 // Represents a test_suite target and the tests that it expanded to. Nested 423 // test suites are recursively expanded. The test labels only contain the 424 // final test targets, not any nested suites. 425 message TestSuiteExpansion { 426 // The label of the test_suite rule. 427 string suite_label = 1; 428 // Labels of the test targets included in the suite. Includes all tests in 429 // the suite regardless of any filters or negative patterns which may result 430 // in the test not actually being run. 431 repeated string test_labels = 2; 432 } 433 434 // All test suites requested via top-level target patterns. Does not include 435 // test suites whose label matched a negative pattern. 436 repeated TestSuiteExpansion test_suite_expansions = 1; 437} 438 439// Enumeration type characterizing the size of a test, as specified by the 440// test rule. 441enum TestSize { 442 UNKNOWN = 0; 443 SMALL = 1; 444 MEDIUM = 2; 445 LARGE = 3; 446 ENORMOUS = 4; 447} 448 449// Payload of the event indicating that the configurations for a target have 450// been identified. As with pattern expansion the main information is in the 451// chaining part: the id will contain the target that was configured and the 452// children id will contain the configured targets it was configured to. 453message TargetConfigured { 454 // The kind of target (e.g., e.g. "cc_library rule", "source file", 455 // "generated file") where the completion is reported. 456 string target_kind = 1; 457 458 // The size of the test, if the target is a test target. Unset otherwise. 459 TestSize test_size = 2; 460 461 // List of all tags associated with this target (for all possible 462 // configurations). 463 repeated string tag = 3; 464} 465 466message File { 467 // A sequence of prefixes to apply to the file name to construct a full path. 468 // In most but not all cases, there will be 3 entries: 469 // 1. A root output directory, eg "bazel-out" 470 // 2. A configuration mnemonic, eg "k8-fastbuild" 471 // 3. An output category, eg "genfiles" 472 repeated string path_prefix = 4; 473 474 // identifier indicating the nature of the file (e.g., "stdout", "stderr") 475 string name = 1; 476 477 oneof file { 478 // A location where the contents of the file can be found. The string is 479 // encoded according to RFC2396. 480 string uri = 2; 481 // The contents of the file, if they are guaranteed to be short. 482 bytes contents = 3; 483 } 484 485 // Digest of the file, using the build tool's configured digest algorithm, 486 // hex-encoded. 487 string digest = 5; 488 489 // Length of the file in bytes. 490 int64 length = 6; 491} 492 493// Payload of a message to describe a set of files, usually build artifacts, to 494// be referred to later by their name. In this way, files that occur identically 495// as outputs of several targets have to be named only once. 496message NamedSetOfFiles { 497 // Files that belong to this named set of files. 498 repeated File files = 1; 499 500 // Other named sets whose members also belong to this set. 501 repeated BuildEventId.NamedSetOfFilesId file_sets = 2; 502} 503 504// Payload of the event indicating the completion of an action. The main purpose 505// of posting those events is to provide details on the root cause for a target 506// failing; however, consumers of the build-event protocol must not assume 507// that only failed actions are posted. 508message ActionExecuted { 509 bool success = 1; 510 511 // The mnemonic of the action that was executed 512 string type = 8; 513 514 // The exit code of the action, if it is available. 515 int32 exit_code = 2; 516 517 // Location where to find the standard output of the action 518 // (e.g., a file path). 519 File stdout = 3; 520 521 // Location where to find the standard error of the action 522 // (e.g., a file path). 523 File stderr = 4; 524 525 // Deprecated. This field is now present on ActionCompletedId. 526 string label = 5 [deprecated = true]; 527 528 // Deprecated. This field is now present on ActionCompletedId. 529 BuildEventId.ConfigurationId configuration = 7 [deprecated = true]; 530 531 // Primary output; only provided for successful actions. 532 File primary_output = 6; 533 534 // The command-line of the action, if the action is a command. 535 repeated string command_line = 9; 536 537 // List of paths to log files 538 repeated File action_metadata_logs = 10; 539 540 // Only populated if success = false, and sometimes not even then. 541 failure_details.FailureDetail failure_detail = 11; 542} 543 544// Collection of all output files belonging to that output group. 545message OutputGroup { 546 // Ids of fields that have been removed. 547 reserved 2; 548 549 // Name of the output group 550 string name = 1; 551 552 // List of file sets that belong to this output group as well. 553 repeated BuildEventId.NamedSetOfFilesId file_sets = 3; 554 555 // Indicates that one or more of the output group's files were not built 556 // successfully (the generating action failed). 557 bool incomplete = 4; 558} 559 560// Payload of the event indicating the completion of a target. The target is 561// specified in the id. If the target failed the root causes are provided as 562// children events. 563message TargetComplete { 564 bool success = 1; 565 566 // The kind of target (e.g., e.g. "cc_library rule", "source file", 567 // "generated file") where the completion is reported. 568 // Deprecated: use the target_kind field in TargetConfigured instead. 569 string target_kind = 5 [deprecated = true]; 570 571 // The size of the test, if the target is a test target. Unset otherwise. 572 // Deprecated: use the test_size field in TargetConfigured instead. 573 TestSize test_size = 6 [deprecated = true]; 574 575 // The output files are arranged by their output group. If an output file 576 // is part of multiple output groups, it appears once in each output 577 // group. 578 repeated OutputGroup output_group = 2; 579 580 // Temporarily, also report the important outputs directly. This is only to 581 // allow existing clients help transition to the deduplicated representation; 582 // new clients should not use it. 583 repeated File important_output = 4 [deprecated = true]; 584 585 // Report output artifacts (referenced transitively via output_group) which 586 // emit directories instead of singleton files. These directory_output entries 587 // will never include a uri. 588 repeated File directory_output = 8; 589 590 // List of tags associated with this configured target. 591 repeated string tag = 3; 592 593 // The timeout specified for test actions under this configured target. 594 // 595 // Deprecated, use `test_timeout` instead. 596 // 597 // TODO(yannic): Remove. 598 int64 test_timeout_seconds = 7 [deprecated = true]; 599 600 // The timeout specified for test actions under this configured target. 601 google.protobuf.Duration test_timeout = 10; 602 603 // Failure information about the target, only populated if success is false, 604 // and sometimes not even then. Equal to one of the ActionExecuted 605 // failure_detail fields for one of the root cause ActionExecuted events. 606 failure_details.FailureDetail failure_detail = 9; 607} 608 609enum TestStatus { 610 NO_STATUS = 0; 611 PASSED = 1; 612 FLAKY = 2; 613 TIMEOUT = 3; 614 FAILED = 4; 615 INCOMPLETE = 5; 616 REMOTE_FAILURE = 6; 617 FAILED_TO_BUILD = 7; 618 TOOL_HALTED_BEFORE_TESTING = 8; 619} 620 621// Payload on events reporting about individual test action. 622message TestResult { 623 reserved 1; 624 625 // The status of this test. 626 TestStatus status = 5; 627 628 // Additional details about the status of the test. This is intended for 629 // user display and must not be parsed. 630 string status_details = 9; 631 632 // True, if the reported attempt is taken from the tool's local cache. 633 bool cached_locally = 4; 634 635 // Time in milliseconds since the epoch at which the test attempt was started. 636 // Note: for cached test results, this is time can be before the start of the 637 // build. 638 // 639 // Deprecated, use `test_attempt_start` instead. 640 // 641 // TODO(yannic): Remove. 642 int64 test_attempt_start_millis_epoch = 6 [deprecated = true]; 643 644 // Time at which the test attempt was started. 645 // Note: for cached test results, this is time can be before the start of the 646 // build. 647 google.protobuf.Timestamp test_attempt_start = 10; 648 649 // Time the test took to run. For locally cached results, this is the time 650 // the cached invocation took when it was invoked. 651 // 652 // Deprecated, use `test_attempt_duration` instead. 653 // 654 // TODO(yannic): Remove. 655 int64 test_attempt_duration_millis = 3 [deprecated = true]; 656 657 // Time the test took to run. For locally cached results, this is the time 658 // the cached invocation took when it was invoked. 659 google.protobuf.Duration test_attempt_duration = 11; 660 661 // Files (logs, test.xml, undeclared outputs, etc) generated by that test 662 // action. 663 repeated File test_action_output = 2; 664 665 // Warnings generated by that test action. 666 repeated string warning = 7; 667 668 // Message providing optional meta data on the execution of the test action, 669 // if available. 670 message ExecutionInfo { 671 // Deprecated, use TargetComplete.test_timeout instead. 672 int32 timeout_seconds = 1 [deprecated = true]; 673 674 // Name of the strategy to execute this test action (e.g., "local", 675 // "remote") 676 string strategy = 2; 677 678 // True, if the reported attempt was a cache hit in a remote cache. 679 bool cached_remotely = 6; 680 681 // The exit code of the test action. 682 int32 exit_code = 7; 683 684 // The hostname of the machine where the test action was executed (in case 685 // of remote execution), if known. 686 string hostname = 3; 687 688 // Represents a hierarchical timing breakdown of an activity. 689 // The top level time should be the total time of the activity. 690 // Invariant: `time` >= sum of `time`s of all direct children. 691 message TimingBreakdown { 692 repeated TimingBreakdown child = 1; 693 string name = 2; 694 // Deprecated, use `time` instead. 695 // 696 // TODO(yannic): Remove. 697 int64 time_millis = 3 [deprecated = true]; 698 google.protobuf.Duration time = 4; 699 } 700 TimingBreakdown timing_breakdown = 4; 701 702 message ResourceUsage { 703 string name = 1; 704 int64 value = 2; 705 } 706 repeated ResourceUsage resource_usage = 5; 707 } 708 ExecutionInfo execution_info = 8; 709} 710 711// Payload of the event summarizing a test. 712message TestSummary { 713 // Wrapper around BlazeTestStatus to support importing that enum to proto3. 714 // Overall status of test, accumulated over all runs, shards, and attempts. 715 TestStatus overall_status = 5; 716 717 // Total number of shard attempts. 718 // E.g., if a target has 4 runs, 3 shards, each with 2 attempts, 719 // then total_run_count will be 4*3*2 = 24. 720 int32 total_run_count = 1; 721 722 // Value of runs_per_test for the test. 723 int32 run_count = 10; 724 725 // Number of attempts. 726 // If there are a different number of attempts per shard, the highest attempt 727 // count across all shards for each run is used. 728 int32 attempt_count = 15; 729 730 // Number of shards. 731 int32 shard_count = 11; 732 733 // Path to logs of passed runs. 734 repeated File passed = 3; 735 736 // Path to logs of failed runs; 737 repeated File failed = 4; 738 739 // Total number of cached test actions 740 int32 total_num_cached = 6; 741 742 // When the test first started running. 743 // 744 // Deprecated, use `first_start_time` instead. 745 // 746 // TODO(yannic): Remove. 747 int64 first_start_time_millis = 7 [deprecated = true]; 748 749 // When the test first started running. 750 google.protobuf.Timestamp first_start_time = 13; 751 752 // When the last test action completed. 753 // 754 // Deprecated, use `last_stop_time` instead. 755 // 756 // TODO(yannic): Remove. 757 int64 last_stop_time_millis = 8 [deprecated = true]; 758 759 // When the test first started running. 760 google.protobuf.Timestamp last_stop_time = 14; 761 762 // The total runtime of the test. 763 // 764 // Deprecated, use `total_run` instead. 765 // 766 // TODO(yannic): Remove. 767 int64 total_run_duration_millis = 9 [deprecated = true]; 768 769 // The total runtime of the test. 770 google.protobuf.Duration total_run_duration = 12; 771} 772 773// Payload of the event summarizing a target (test or non-test). 774message TargetSummary { 775 // Conjunction of TargetComplete events for this target, including aspects. 776 bool overall_build_success = 1; 777 778 // Repeats TestSummary's overall_status if available. 779 TestStatus overall_test_status = 2; 780} 781 782// Event indicating the end of a build. 783message BuildFinished { 784 // Exit code of a build. The possible values correspond to the predefined 785 // codes in bazel's lib.ExitCode class, as well as any custom exit code a 786 // module might define. The predefined exit codes are subject to change (but 787 // rarely do) and are not part of the public API. 788 // 789 // A build was successful iff ExitCode.code equals 0. 790 message ExitCode { 791 // The name of the exit code. 792 string name = 1; 793 794 // The exit code. 795 int32 code = 2; 796 } 797 798 // Things that happened during the build that could be of interest. 799 message AnomalyReport { 800 // Was the build suspended at any time during the build. 801 // Examples of suspensions are SIGSTOP, or the hardware being put to sleep. 802 // If was_suspended is true, then most of the timings for this build are 803 // suspect. 804 // NOTE: This is no longer set and is deprecated. 805 bool was_suspended = 1; 806 } 807 808 // If the build succeeded or failed. 809 bool overall_success = 1 [deprecated = true]; 810 811 // The overall status of the build. A build was successful iff 812 // ExitCode.code equals 0. 813 ExitCode exit_code = 3; 814 815 // End of the build in ms since the epoch. 816 // 817 // Deprecated, use `finish_time` instead. 818 // 819 // TODO(yannic): Remove. 820 int64 finish_time_millis = 2 [deprecated = true]; 821 822 // End of the build. 823 google.protobuf.Timestamp finish_time = 5; 824 825 AnomalyReport anomaly_report = 4 [deprecated = true]; 826} 827 828message BuildMetrics { 829 message ActionSummary { 830 // The total number of actions created and registered during the build, 831 // including both aspects and configured targets. This metric includes 832 // unused actions that were constructed but not executed during this build. 833 // It does not include actions that were created on prior builds that are 834 // still valid, even if those actions had to be re-executed on this build. 835 // For the total number of actions that would be created if this invocation 836 // were "clean", see BuildGraphMetrics below. 837 int64 actions_created = 1; 838 839 // The total number of actions created this build just by configured 840 // targets. Used mainly to allow consumers of actions_created, which used to 841 // not include aspects' actions, to normalize across the Blaze release that 842 // switched actions_created to include all created actions. 843 int64 actions_created_not_including_aspects = 3; 844 845 // The total number of actions executed during the build. This includes any 846 // remote cache hits, but excludes local action cache hits. 847 int64 actions_executed = 2; 848 849 message ActionData { 850 string mnemonic = 1; 851 852 // The total number of actions of this type executed during the build. As 853 // above, includes remote cache hits but excludes local action cache hits. 854 int64 actions_executed = 2; 855 856 // When the first action of this type started being executed, in 857 // milliseconds from the epoch. 858 int64 first_started_ms = 3; 859 860 // When the last action of this type ended being executed, in 861 // milliseconds from the epoch. 862 int64 last_ended_ms = 4; 863 } 864 // Contains the top N actions by number of actions executed. 865 repeated ActionData action_data = 4; 866 867 // Deprecated. The total number of remote cache hits. 868 int64 remote_cache_hits = 5 [deprecated = true]; 869 870 message RunnerCount { 871 string name = 1; 872 int32 count = 2; 873 } 874 repeated RunnerCount runner_count = 6; 875 } 876 ActionSummary action_summary = 1; 877 878 message MemoryMetrics { 879 // Size of the JVM heap post build in bytes. This is only collected if 880 // --memory_profile is set, since it forces a full GC. 881 int64 used_heap_size_post_build = 1; 882 883 // Size of the peak JVM heap size in bytes post GC. Note that this reports 0 884 // if there was no major GC during the build. 885 int64 peak_post_gc_heap_size = 2; 886 887 // Size of the peak tenured space JVM heap size event in bytes post GC. Note 888 // that this reports 0 if there was no major GC during the build. 889 int64 peak_post_gc_tenured_space_heap_size = 4; 890 891 message GarbageMetrics { 892 // Type of garbage collected, e.g. G1 Old Gen. 893 string type = 1; 894 // Number of bytes of garbage of the given type collected during this 895 // invocation. 896 int64 garbage_collected = 2; 897 } 898 899 repeated GarbageMetrics garbage_metrics = 3; 900 } 901 MemoryMetrics memory_metrics = 2; 902 903 message TargetMetrics { 904 // DEPRECATED 905 // No longer populated. It never measured what it was supposed to (targets 906 // loaded): it counted targets that were analyzed even if the underlying 907 // package had not changed. 908 // TODO(janakr): rename and remove. 909 int64 targets_loaded = 1; 910 911 // Number of targets/aspects configured during this build. Does not include 912 // targets/aspects that were configured on prior builds on this server and 913 // were cached. See BuildGraphMetrics below if you need that. 914 int64 targets_configured = 2; 915 916 // Number of configured targets analyzed during this build. Does not include 917 // aspects. Used mainly to allow consumers of targets_configured, which used 918 // to not include aspects, to normalize across the Blaze release that 919 // switched targets_configured to include aspects. 920 int64 targets_configured_not_including_aspects = 3; 921 } 922 TargetMetrics target_metrics = 3; 923 924 message PackageMetrics { 925 // Number of BUILD files (aka packages) successfully loaded during this 926 // build. 927 // 928 // [For Bazel binaries built at source states] Before Dec 2021, this value 929 // was the number of packages attempted to be loaded, for a particular 930 // definition of "attempted". 931 // 932 // After Dec 2021, this value would sometimes overcount because the same 933 // package could sometimes be attempted to be loaded multiple times due to 934 // memory pressure. 935 // 936 // After Feb 2022, this value is the number of packages successfully 937 // loaded. 938 int64 packages_loaded = 1; 939 } 940 PackageMetrics package_metrics = 4; 941 942 message TimingMetrics { 943 // The CPU time in milliseconds consumed during this build. 944 int64 cpu_time_in_ms = 1; 945 // The elapsed wall time in milliseconds during this build. 946 int64 wall_time_in_ms = 2; 947 // The elapsed wall time in milliseconds during the analysis phase. 948 // When analysis and execution phases are interleaved, this measures the 949 // elapsed time from the first analysis work to the last. 950 int64 analysis_phase_time_in_ms = 3; 951 } 952 TimingMetrics timing_metrics = 5; 953 954 message CumulativeMetrics { 955 // One-indexed number of "analyses" the server has run, including the 956 // current one. Will be incremented for every build/test/cquery/etc. command 957 // that reaches the analysis phase. 958 int32 num_analyses = 11; 959 // One-indexed number of "builds" the server has run, including the current 960 // one. Will be incremented for every build/test/run/etc. command that 961 // reaches the execution phase. 962 int32 num_builds = 12; 963 } 964 965 CumulativeMetrics cumulative_metrics = 6; 966 967 message ArtifactMetrics { 968 reserved 1; 969 970 message FilesMetric { 971 int64 size_in_bytes = 1; 972 int32 count = 2; 973 } 974 975 // Measures all source files newly read this build. Does not include 976 // unchanged sources on incremental builds. 977 FilesMetric source_artifacts_read = 2; 978 // Measures all output artifacts from executed actions. This includes 979 // actions that were cached locally (via the action cache) or remotely (via 980 // a remote cache or executor), but does *not* include outputs of actions 981 // that were cached internally in Skyframe. 982 FilesMetric output_artifacts_seen = 3; 983 // Measures all output artifacts from actions that were cached locally 984 // via the action cache. These artifacts were already present on disk at the 985 // start of the build. Does not include Skyframe-cached actions' outputs. 986 FilesMetric output_artifacts_from_action_cache = 4; 987 // Measures all artifacts that belong to a top-level output group. Does not 988 // deduplicate, so if there are two top-level targets in this build that 989 // share an artifact, it will be counted twice. 990 FilesMetric top_level_artifacts = 5; 991 } 992 993 ArtifactMetrics artifact_metrics = 7; 994 995 // Information about the size and shape of the build graph. Some fields may 996 // not be populated if Bazel was able to skip steps due to caching. 997 message BuildGraphMetrics { 998 // How many configured targets/aspects were in this build, including any 999 // that were analyzed on a prior build and are still valid. May not be 1000 // populated if analysis phase was fully cached. Note: for historical 1001 // reasons this includes input/output files and other configured targets 1002 // that do not actually have associated actions. 1003 int32 action_lookup_value_count = 1; 1004 // How many configured targets alone were in this build: always at most 1005 // action_lookup_value_count. Useful mainly for historical comparisons to 1006 // TargetMetrics.targets_configured, which used to not count aspects. This 1007 // also includes configured targets that do not have associated actions. 1008 int32 action_lookup_value_count_not_including_aspects = 5; 1009 // How many actions belonged to the configured targets/aspects above. It may 1010 // not be necessary to execute all of these actions to build the requested 1011 // targets. May not be populated if analysis phase was fully cached. 1012 int32 action_count = 2; 1013 // How many actions belonged to configured targets: always at most 1014 // action_count. Useful mainly for historical comparisons to 1015 // ActionMetrics.actions_created, which used to not count aspects' actions. 1016 int32 action_count_not_including_aspects = 6; 1017 // How many "input file" configured targets there were: one per source file. 1018 // Should agree with artifact_metrics.source_artifacts_read.count above, 1019 int32 input_file_configured_target_count = 7; 1020 // How many "output file" configured targets there were: output files that 1021 // are targets (not implicit outputs). 1022 int32 output_file_configured_target_count = 8; 1023 // How many "other" configured targets there were (like alias, 1024 // package_group, and other non-rule non-file configured targets). 1025 int32 other_configured_target_count = 9; 1026 // How many artifacts are outputs of the above actions. May not be populated 1027 // if analysis phase was fully cached. 1028 int32 output_artifact_count = 3; 1029 // How many Skyframe nodes there are in memory at the end of the build. This 1030 // may underestimate the number of nodes when running with memory-saving 1031 // settings or with Skybuild, and may overestimate if there are nodes from 1032 // prior evaluations still in the cache. 1033 int32 post_invocation_skyframe_node_count = 4; 1034 } 1035 1036 BuildGraphMetrics build_graph_metrics = 8; 1037 1038 // Information about all workers that were alive during the invocation. 1039 message WorkerMetrics { 1040 // Unique id of worker. 1041 int32 worker_id = 1; 1042 // Worker process id. If there is no process for worker, equals to zero. 1043 uint32 process_id = 2; 1044 // Mnemonic of running worker. 1045 string mnemonic = 3; 1046 // Multiplex or singleplex worker. 1047 bool is_multiplex = 4; 1048 // Using worker sandbox file system or not. 1049 bool is_sandbox = 5; 1050 // Shows is worker stats measured at the end of invocation. 1051 bool is_measurable = 6; 1052 1053 // Information collected from worker at some point. 1054 message WorkerStats { 1055 // Epoch unix time of collection of metrics. 1056 int64 collect_time_in_ms = 1; 1057 // RSS size of worker process. 1058 int32 worker_memory_in_kb = 2; 1059 // Epoch unix time of last action started on specific worker. 1060 int64 last_action_start_time_in_ms = 3; 1061 } 1062 1063 // Combined workers statistics. 1064 repeated WorkerStats worker_stats = 7; 1065 } 1066 1067 repeated WorkerMetrics worker_metrics = 9; 1068 1069 // Information about host network. 1070 message NetworkMetrics { 1071 // Information for all the network traffic going on on the host machine during the invocation. 1072 message SystemNetworkStats { 1073 // Total bytes sent during the invocation. 1074 uint64 bytes_sent = 1; 1075 // Total bytes received during the invocation. 1076 uint64 bytes_recv = 2; 1077 // Total packets sent during the invocation. 1078 uint64 packets_sent = 3; 1079 // Total packets received during the invocation. 1080 uint64 packets_recv = 4; 1081 // Peak bytes/sec sent during the invocation. 1082 uint64 peak_bytes_sent_per_sec = 5; 1083 // Peak bytes/sec received during the invocation. 1084 uint64 peak_bytes_recv_per_sec = 6; 1085 // Peak packets/sec sent during the invocation. 1086 uint64 peak_packets_sent_per_sec = 7; 1087 // Peak packets/sec received during the invocation. 1088 uint64 peak_packets_recv_per_sec = 8; 1089 } 1090 1091 SystemNetworkStats system_network_stats = 1; 1092 } 1093 1094 NetworkMetrics network_metrics = 10; 1095} 1096 1097// Event providing additional statistics/logs after completion of the build. 1098message BuildToolLogs { 1099 repeated File log = 1; 1100} 1101 1102// Event describing all convenience symlinks (i.e., workspace symlinks) to be 1103// created or deleted once the execution phase has begun. Note that this event 1104// does not say anything about whether or not the build tool actually executed 1105// these filesystem operations; it only says what logical operations should be 1106// performed. This event is emitted exactly once per build; if no symlinks are 1107// to be modified, the event is still emitted with empty contents. 1108message ConvenienceSymlinksIdentified { 1109 repeated ConvenienceSymlink convenience_symlinks = 1; 1110} 1111 1112// The message that contains what type of action to perform on a given path and 1113// target of a symlink. 1114message ConvenienceSymlink { 1115 enum Action { 1116 UNKNOWN = 0; 1117 1118 // Indicates a symlink should be created, or overwritten if it already 1119 // exists. 1120 CREATE = 1; 1121 1122 // Indicates a symlink should be deleted if it already exists. 1123 DELETE = 2; 1124 } 1125 1126 // The path of the symlink to be created or deleted, absolute or relative to 1127 // the workspace, creating any directories necessary. If a symlink already 1128 // exists at that location, then it should be replaced by a symlink pointing 1129 // to the new target. 1130 string path = 1; 1131 1132 // The operation we are performing on the symlink. 1133 Action action = 2; 1134 1135 // If action is CREATE, this is the target path that the symlink should point 1136 // to. If the path points underneath the output base, it is relative to the 1137 // output base; otherwise it is absolute. 1138 // 1139 // If action is DELETE, this field is not set. 1140 string target = 3; 1141} 1142 1143// Message describing a build event. Events will have an identifier that 1144// is unique within a given build invocation; they also announce follow-up 1145// events as children. More details, which are specific to the kind of event 1146// that is observed, is provided in the payload. More options for the payload 1147// might be added in the future. 1148message BuildEvent { 1149 reserved 11, 19; 1150 BuildEventId id = 1; 1151 repeated BuildEventId children = 2; 1152 bool last_message = 20; 1153 oneof payload { 1154 Progress progress = 3; 1155 Aborted aborted = 4; 1156 BuildStarted started = 5; 1157 UnstructuredCommandLine unstructured_command_line = 12; 1158 command_line.CommandLine structured_command_line = 22; 1159 OptionsParsed options_parsed = 13; 1160 WorkspaceStatus workspace_status = 16; 1161 Fetch fetch = 21; 1162 Configuration configuration = 17; 1163 PatternExpanded expanded = 6; 1164 TargetConfigured configured = 18; 1165 ActionExecuted action = 7; 1166 NamedSetOfFiles named_set_of_files = 15; 1167 TargetComplete completed = 8; 1168 TestResult test_result = 10; 1169 TestSummary test_summary = 9; 1170 TargetSummary target_summary = 28; 1171 BuildFinished finished = 14; 1172 BuildToolLogs build_tool_logs = 23; 1173 BuildMetrics build_metrics = 24; 1174 WorkspaceConfig workspace_info = 25; 1175 BuildMetadata build_metadata = 26; 1176 ConvenienceSymlinksIdentified convenience_symlinks_identified = 27; 1177 } 1178} 1179