forked from bazelbuild/bazel
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Report evaluation start and end for module extensions as fetch events
Closes bazelbuild#20100. PiperOrigin-RevId: 580915088 Change-Id: Ia944ed2f3e45b5529546092a9bc4dd58b0c31bd6
- Loading branch information
1 parent
0e66fd7
commit b5c38af
Showing
4 changed files
with
77 additions
and
2 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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
73 changes: 73 additions & 0 deletions
73
...in/java/com/google/devtools/build/lib/bazel/bzlmod/ModuleExtensionEvaluationProgress.java
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,73 @@ | ||
// Copyright 2023 The Bazel Authors. All rights reserved. | ||
// | ||
// Licensed under the Apache License, Version 2.0 (the "License"); | ||
// you may not use this file except in compliance with the License. | ||
// You may obtain a copy of the License at | ||
// | ||
// http://www.apache.org/licenses/LICENSE-2.0 | ||
// | ||
// Unless required by applicable law or agreed to in writing, software | ||
// distributed under the License is distributed on an "AS IS" BASIS, | ||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
// See the License for the specific language governing permissions and | ||
// limitations under the License. | ||
package com.google.devtools.build.lib.bazel.bzlmod; | ||
|
||
import com.google.devtools.build.lib.events.ExtendedEventHandler.FetchProgress; | ||
|
||
/** Reports the progress of the evaluation of a module extension. */ | ||
public class ModuleExtensionEvaluationProgress implements FetchProgress { | ||
|
||
private final ModuleExtensionId extensionId; | ||
private final boolean finished; | ||
private final String message; | ||
|
||
/** Returns the unique identifying string for a module extension evaluation event. */ | ||
public static String moduleExtensionEvaluationContextString(ModuleExtensionId extensionId) { | ||
String suffix = | ||
extensionId | ||
.getIsolationKey() | ||
.map( | ||
isolationKey -> | ||
String.format( | ||
" for %s in %s", | ||
isolationKey.getUsageExportedName(), isolationKey.getModule())) | ||
.orElse(""); | ||
return String.format( | ||
"module extension %s in %s%s", | ||
extensionId.getExtensionName(), | ||
extensionId.getBzlFileLabel().getUnambiguousCanonicalForm(), | ||
suffix); | ||
} | ||
|
||
public static ModuleExtensionEvaluationProgress ongoing( | ||
ModuleExtensionId extensionId, String message) { | ||
return new ModuleExtensionEvaluationProgress(extensionId, /* finished= */ false, message); | ||
} | ||
|
||
public static ModuleExtensionEvaluationProgress finished(ModuleExtensionId extensionId) { | ||
return new ModuleExtensionEvaluationProgress(extensionId, /* finished= */ true, "finished."); | ||
} | ||
|
||
private ModuleExtensionEvaluationProgress( | ||
ModuleExtensionId extensionId, boolean finished, String message) { | ||
this.extensionId = extensionId; | ||
this.finished = finished; | ||
this.message = message; | ||
} | ||
|
||
@Override | ||
public String getResourceIdentifier() { | ||
return moduleExtensionEvaluationContextString(extensionId); | ||
} | ||
|
||
@Override | ||
public String getProgress() { | ||
return message; | ||
} | ||
|
||
@Override | ||
public boolean isFinished() { | ||
return finished; | ||
} | ||
} |
This file contains 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