Skip to content

Commit b1a9dbe

Browse files
committed
extract method
1 parent 07f0e4b commit b1a9dbe

File tree

1 file changed

+21
-19
lines changed
  • agent/agent-tooling/src/main/java/com/microsoft/applicationinsights/agent/internal/init

1 file changed

+21
-19
lines changed

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

Lines changed: 21 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -260,25 +260,6 @@ public void customize(AutoConfigurationCustomizer autoConfiguration) {
260260
return props;
261261
})
262262
.addPropertiesCustomizer(new AiConfigCustomizer())
263-
.addLogRecordProcessorCustomizer(
264-
(logRecordProcessor, configProperties) -> {
265-
if (logRecordProcessor instanceof BatchLogRecordProcessor) {
266-
List<LogRecordProcessor> logRecordProcessors =
267-
getLogRecordProcessors(configuration);
268-
269-
// the filtering log record processor needs to be chained on front of the batch log
270-
// record processor, hopefully log filtering will be better supported by
271-
// OpenTelemetry SDK in the future, see
272-
// https://github.com/open-telemetry/opentelemetry-specification/pull/4439
273-
logFilteringProcessor =
274-
createLogFilteringProcessor(logRecordProcessor, configuration);
275-
276-
logRecordProcessors.add(logFilteringProcessor);
277-
return LogRecordProcessor.composite(
278-
logRecordProcessors.toArray(new LogRecordProcessor[0]));
279-
}
280-
return logRecordProcessor;
281-
})
282263
.addSpanExporterCustomizer(
283264
(spanExporter, configProperties) -> {
284265
if (spanExporter instanceof AzureMonitorSpanExporterProvider.MarkerSpanExporter) {
@@ -295,6 +276,13 @@ public void customize(AutoConfigurationCustomizer autoConfiguration) {
295276
return metricExporter;
296277
}
297278
})
279+
.addLogRecordProcessorCustomizer(
280+
(logRecordProcessor, configProperties) -> {
281+
if (logRecordProcessor instanceof BatchLogRecordProcessor) {
282+
return wrapBatchLogRecordProcessor(logRecordProcessor, configuration);
283+
}
284+
return logRecordProcessor;
285+
})
298286
.addLogRecordExporterCustomizer(
299287
(logRecordExporter, configProperties) -> {
300288
if (logRecordExporter
@@ -322,6 +310,20 @@ public void customize(AutoConfigurationCustomizer autoConfiguration) {
322310
});
323311
}
324312

313+
private static LogRecordProcessor wrapBatchLogRecordProcessor(
314+
LogRecordProcessor logRecordProcessor, Configuration configuration) {
315+
List<LogRecordProcessor> logRecordProcessors = getLogRecordProcessors(configuration);
316+
317+
// the filtering log record processor needs to be chained on front of the batch log
318+
// record processor, hopefully log filtering will be better supported by
319+
// OpenTelemetry SDK in the future, see
320+
// https://github.com/open-telemetry/opentelemetry-specification/pull/4439
321+
logFilteringProcessor = createLogFilteringProcessor(logRecordProcessor, configuration);
322+
323+
logRecordProcessors.add(logFilteringProcessor);
324+
return LogRecordProcessor.composite(logRecordProcessors.toArray(new LogRecordProcessor[0]));
325+
}
326+
325327
private static AzureMonitorLogFilteringProcessor createLogFilteringProcessor(
326328
LogRecordProcessor logRecordProcessor, Configuration configuration) {
327329

0 commit comments

Comments
 (0)