use of com.microsoft.applicationinsights.agent.internal.exporter.Exporter in project ApplicationInsights-Java by microsoft.
the class OpenTelemetryConfigurer method createExporter.
private static BatchSpanProcessor createExporter(Configuration configuration) {
List<ProcessorConfig> processors = configuration.preview.processors.stream().filter(processor -> processor.type != Configuration.ProcessorType.METRIC_FILTER).collect(Collectors.toCollection(ArrayList::new));
// Reversing the order of processors before passing it to SpanProcessor
Collections.reverse(processors);
SpanExporter currExporter = new Exporter(TelemetryClient.getActive(), configuration.preview.captureHttpServer4xxAsError);
// flushing TelemetryClient
if (!processors.isEmpty()) {
for (ProcessorConfig processorConfig : processors) {
switch(processorConfig.type) {
case ATTRIBUTE:
currExporter = new ExporterWithAttributeProcessor(processorConfig, currExporter);
break;
case SPAN:
currExporter = new ExporterWithSpanProcessor(processorConfig, currExporter);
break;
case LOG:
currExporter = new ExporterWithLogProcessor(processorConfig, currExporter);
break;
default:
throw new IllegalStateException("Not an expected ProcessorType: " + processorConfig.type);
}
}
// this is temporary until semantic attributes stabilize and we make breaking change
// then can use java.util.functions.Predicate<Attributes>
currExporter = new BackCompatHttpUrlProcessor(currExporter);
}
// using BatchSpanProcessor in order to get off of the application thread as soon as possible
BatchSpanProcessorBuilder builder = BatchSpanProcessor.builder(currExporter);
String delayMillisStr = System.getenv("APPLICATIONINSIGHTS_PREVIEW_BSP_SCHEDULE_DELAY");
if (delayMillisStr != null) {
// experimenting with flushing at small interval instead of using batch size 1
// (suspect this may be better performance on small containers)
builder.setScheduleDelay(Duration.ofMillis(Integer.parseInt(delayMillisStr)));
} else {
// using batch size 1 because need to convert to SpanData as soon as possible to grab data for
// live metrics. the real batching is done at a lower level
builder.setMaxExportBatchSize(1);
}
return builder.build();
}
Aggregations