Skip to content

Commit ea50d98

Browse files
author
Bruno Volpato
authored
Increase logging buffer size to 256kb (#25922)
1 parent 92abdf6 commit ea50d98

1 file changed

Lines changed: 9 additions & 1 deletion

File tree

runners/google-cloud-dataflow-java/worker/src/main/java/org/apache/beam/runners/dataflow/worker/logging/DataflowWorkerLoggingHandler.java

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,13 @@ public class DataflowWorkerLoggingHandler extends Handler {
7575
BEAM_LOG_LEVEL_TO_CLOUD_LOG_LEVEL.put(BeamFnApi.LogEntry.Severity.Enum.CRITICAL, "CRITICAL");
7676
}
7777

78+
/**
79+
* Buffer size to use when writing logs. This matches <a
80+
* href="https://cloud.google.com/logging/quotas#log-limits">Logging usage limits</a> to avoid
81+
* spreading the same log entry across multiple disk flushes.
82+
*/
83+
private static final int LOGGING_WRITER_BUFFER_SIZE = 262144; // 256kb
84+
7885
/**
7986
* Formats the throwable as per {@link Throwable#printStackTrace()}.
8087
*
@@ -278,7 +285,8 @@ public OutputStream get() {
278285
try {
279286
String filename = filepath + "." + formatter.format(new Date()) + ".log";
280287
return new BufferedOutputStream(
281-
new FileOutputStream(new File(filename), true /* append */));
288+
new FileOutputStream(new File(filename), true /* append */),
289+
LOGGING_WRITER_BUFFER_SIZE);
282290
} catch (IOException e) {
283291
throw new RuntimeException(e);
284292
}

0 commit comments

Comments
 (0)