Aggregate Protobuf build telemetry into a single per-build report#4575
Open
Aggregate Protobuf build telemetry into a single per-build report#4575
Conversation
) The build-telemetry plug-in ran inside each per-file protoc invocation, producing N uploads with FileCount=1 instead of one upload describing the whole compilation. Generalize ProtocTask to take a `Plugins` item list (matching the shape of SlicecTask.Generators) and an `AdditionalOptions` parameter, and run it twice from the targets: per-file for codegen plus per-file dependency files, then once over all ProtoFile items for the telemetry plug-in.
There was a problem hiding this comment.
Pull request overview
This PR fixes Protobuf build telemetry being emitted once per .proto file by restructuring the MSBuild protoc invocations so telemetry runs in a single batched call over all ProtoFile items.
Changes:
- Generalize
ProtocTaskto accept a configurablePluginsitem list andAdditionalOptions. - Update
IceRpc.Protobuf.Tools.targetsto runprotocper-file for codegen (with per-file.ddepfiles) and once-per-build for telemetry. - Remove the unused/orphaned
BuildTelemetryTaskUsingTaskdeclaration.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
| src/IceRpc.Protobuf.Tools/ProtocTask.cs | Refactors task to run an arbitrary set of protoc plug-ins and append extra options. |
| src/IceRpc.Protobuf.Tools/IceRpc.Protobuf.Tools.targets | Splits protoc execution into per-file codegen and batched telemetry invocations; removes unused task registration. |
Comment on lines
+80
to
+81
| builder.AppendTextUnquoted(" "); | ||
| builder.AppendTextUnquoted(option); |
| BuildTelemetryPath="$(IceRpcProtocBuildTelemetryPath)" | ||
| RunBuildTelemetry="$(IceRpcBuildTelemetry)" | ||
| Plugins="@(_ProtocCodegenPlugin)" | ||
| AdditionalOptions="--dependency_out=%(_ProtoFile.OutputDir)/%(_ProtoFile.OutputFileName).d" |
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.
Fixes #4443.
Summary
The build-telemetry plug-in was running inside each per-file
protocinvocation, so a project with N.protofiles produced N uploads (each withFileCount=1and a per-file hash) instead of one upload describing the whole compilation. The 3-second per-upload timeout also amplified the offline-build slowdown — N × 3 seconds when the telemetry server was unreachable.The fix keeps the per-file fanout (which is required to produce per-file
.ddependency files for incremental builds) and runs the telemetry plug-in in a separate batchedprotocinvocation that sees everyProtoFilein one go. The plug-in then naturally computes a single aggregate compilation hash and the correct file count, and uploads once per build.Changes
ProtocTaskto take aPluginsitem list (each item:Identity= plug-in name,Pathmetadata = script path or empty for protoc built-ins) and anAdditionalOptionsstring array — same shape asSlicecTask.Generators/AdditionalOptions.IceRpc.Protobuf.Tools.targetsnow invokesProtocTasktwice:ProtoFile(driven bySources=\"%(_ProtoFile.Identity)\") with thecsharpandicerpc-csharpplug-ins, andAdditionalOptions=\"--dependency_out=…\"to keep per-file.dfiles.ProtoFileitems with theicerpc-build-telemetryplug-in only, gated onIceRpcBuildTelemetry=true. Telemetry runs on every build (including incremental no-op builds) for analytics consistency.BuildTelemetryTaskUsingTaskdeclaration left behind by Convert Protobuf build telemetry to protoc plug-in #4249.Test plan
-p:IceRpcBuildTelemetry=true: 4.cs+ 4.IceRpc.cs+ 4.dfiles produced; one telemetry txt file inobj/Debug/net10.0/; server reports successful upload.-p:IceRpcBuildTelemetry=false: codegen unchanged, no telemetry call.IceRpc.Protobuf.Tests: 48/48 pass.