[maven] add new api to maven server telemetry

GitOrigin-RevId: 5e20b4895bcdad13a86efc3a4167215ae7e280ed
This commit is contained in:
Alexander Bubenchikov
2024-09-19 17:14:26 +02:00
committed by intellij-monorepo-bot
parent dd76c089dd
commit 0fab66f445

View File

@@ -33,6 +33,11 @@ public interface MavenServerOpenTelemetry {
<T, R> List<R> execute(boolean inParallel, @NotNull Collection<T> collection, @NotNull Function<T, R> method);
<T, R> List<R> executeWithSpan(@NotNull String spanName,
boolean inParallel,
@NotNull Collection<T> collection,
@NotNull Function<T, R> method);
byte[] shutdown();
static MavenServerOpenTelemetry of(@NotNull LongRunningTaskInput input) {
@@ -56,6 +61,14 @@ final class MavenServerOpenTelemetryNoop implements MavenServerOpenTelemetry {
return ParallelRunnerForServer.execute(inParallel, collection, method);
}
@Override
public <T, R> List<R> executeWithSpan(@NotNull String spanName,
boolean inParallel,
@NotNull Collection<T> collection,
@NotNull Function<T, R> method) {
return execute(inParallel, collection, method);
}
@Override
public byte[] shutdown() {
return ArrayUtilRt.EMPTY_BYTE_ARRAY;
@@ -130,6 +143,16 @@ final class MavenServerOpenTelemetryImpl implements MavenServerOpenTelemetry {
return ParallelRunnerForServer.execute(inParallel, collection, context.wrapFunction(method));
}
@Override
public <T, R> List<R> executeWithSpan(@NotNull String spanName,
boolean inParallel,
@NotNull Collection<T> collection,
@NotNull Function<T, R> method) {
return callWithSpan(spanName, () ->
execute(inParallel, collection, method)
);
}
public <T> T callWithSpan(@NotNull String spanName, @NotNull Function<Span, T> fn) {
return callWithSpan(spanName, (ignore) -> {
}, fn);