Introduce `InstrumentationOutput` and apply it to profile

`InstrumentationOutput` aims at providing a unified way to handle writing and publishing instrumentation outputs.

PiperOrigin-RevId: 663316138
Change-Id: Ie5d80acd1843a94045307442ed00ffd6a9f98105
diff --git a/src/main/java/com/google/devtools/build/lib/runtime/InstrumentationOutput.java b/src/main/java/com/google/devtools/build/lib/runtime/InstrumentationOutput.java
new file mode 100644
index 0000000..f5130e6
--- /dev/null
+++ b/src/main/java/com/google/devtools/build/lib/runtime/InstrumentationOutput.java
@@ -0,0 +1,28 @@
+// Copyright 2024 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.runtime;
+
+import com.google.devtools.build.lib.buildtool.BuildResult.BuildToolLogCollection;
+import java.io.IOException;
+import java.io.OutputStream;
+
+/** Stores and publishes the instrumentation output information. */
+public interface InstrumentationOutput {
+
+  /** Creates the {@link OutputStream} for instrumentation output writes. */
+  OutputStream createOutputStream() throws IOException;
+
+  /** Publishes instrumentation output information to the {@link BuildToolLogCollection}. */
+  void publish(BuildToolLogCollection buildToolLogCollection);
+}