Skip to content

Commit 1b587fe

Browse files
authored
Add scheduled delay for batch span processor (#2222)
1 parent 0c05471 commit 1b587fe

File tree

1 file changed

+7
-7
lines changed

1 file changed

+7
-7
lines changed

agent/agent-tooling/src/main/java/com/microsoft/applicationinsights/agent/internal/init/OpenTelemetryConfigurer.java

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -166,17 +166,17 @@ private static BatchSpanProcessor createExporter(Configuration configuration) {
166166
BatchSpanProcessorBuilder builder = BatchSpanProcessor.builder(currExporter);
167167

168168
String delayMillisStr = System.getenv("APPLICATIONINSIGHTS_PREVIEW_BSP_SCHEDULE_DELAY");
169+
int delayMillis;
169170
if (delayMillisStr != null) {
170-
// experimenting with flushing at small interval instead of using batch size 1
171-
// (suspect this may be better performance on small containers)
172-
builder.setScheduleDelay(Duration.ofMillis(Integer.parseInt(delayMillisStr)));
171+
delayMillis = Integer.parseInt(delayMillisStr);
173172
} else {
174-
// using batch size 1 because need to convert to SpanData as soon as possible to grab data for
175-
// live metrics. the real batching is done at a lower level
176-
builder.setMaxExportBatchSize(1);
173+
// using small interval because need to convert to SpanData as soon as possible to grab data
174+
// for live metrics. the real batching is done at a lower level
175+
// (not using batch size 1 because that seems to cause poor performance on small containers)
176+
delayMillis = 100;
177177
}
178178

179-
return builder.build();
179+
return builder.setScheduleDelay(Duration.ofMillis(delayMillis)).build();
180180
}
181181

182182
private static class BackCompatHttpUrlProcessor implements SpanExporter {

0 commit comments

Comments
 (0)