use of com.splunk.opentelemetry.logs.BatchingLogsProcessor in project splunk-otel-java by signalfx.
the class JfrActivator method activateJfrAndRunForever.
private void activateJfrAndRunForever(Config config, Resource resource) {
// can't be null, default value is set in Configuration.getProperties
Duration recordingDuration = config.getDuration(CONFIG_KEY_RECORDING_DURATION, null);
Path outputDir = Paths.get(config.getString(CONFIG_KEY_PROFILER_DIRECTORY));
RecordingFileNamingConvention namingConvention = new RecordingFileNamingConvention(outputDir);
RecordingEscapeHatch recordingEscapeHatch = RecordingEscapeHatch.builder().namingConvention(namingConvention).configKeepsFilesOnDisk(keepFiles(config)).recordingDuration(recordingDuration).build();
Map<String, String> jfrSettings = buildJfrSettings(config);
RecordedEventStream.Factory recordedEventStreamFactory = () -> new BasicJfrRecordingFile(JFR.instance);
SpanContextualizer spanContextualizer = new SpanContextualizer();
EventPeriods periods = new EventPeriods(jfrSettings::get);
LogDataCommonAttributes commonAttributes = new LogDataCommonAttributes(periods);
LogExporter logsExporter = LogExporterBuilder.fromConfig(config);
ScheduledExecutorService exportExecutorService = HelpfulExecutors.newSingleThreadedScheduledExecutor("Batched Logs Exporter");
BatchingLogsProcessor batchingLogsProcessor = BatchingLogsProcessor.builder().maxTimeBetweenBatches(MAX_TIME_BETWEEN_BATCHES).maxBatchSize(MAX_BATCH_SIZE).batchAction(logsExporter).executorService(exportExecutorService).build();
batchingLogsProcessor.start();
LogDataCreator logDataCreator = new LogDataCreator(commonAttributes, resource);
StackToSpanLinkageProcessor processor = new StackToSpanLinkageProcessor(logDataCreator, batchingLogsProcessor);
ThreadDumpProcessor threadDumpProcessor = buildThreadDumpProcessor(spanContextualizer, processor, buildStackTraceFilter(config), config);
TLABProcessor tlabProcessor = TLABProcessor.builder(config).logProcessor(batchingLogsProcessor).commonAttributes(commonAttributes).resource(resource).spanContextualizer(spanContextualizer).build();
EventProcessingChain eventProcessingChain = new EventProcessingChain(spanContextualizer, threadDumpProcessor, tlabProcessor);
Consumer<Path> deleter = buildFileDeleter(config);
JfrDirCleanup dirCleanup = new JfrDirCleanup(deleter);
Consumer<Path> onFileFinished = buildOnFileFinished(deleter, dirCleanup);
JfrPathHandler jfrPathHandler = JfrPathHandler.builder().recordedEventStreamFactory(recordedEventStreamFactory).eventProcessingChain(eventProcessingChain).onFileFinished(onFileFinished).build();
Consumer<Path> onNewRecording = buildOnNewRecording(jfrPathHandler, dirCleanup);
JfrRecorder recorder = JfrRecorder.builder().settings(jfrSettings).maxAgeDuration(recordingDuration.multipliedBy(10)).jfr(JFR.instance).namingConvention(namingConvention).onNewRecordingFile(onNewRecording).build();
RecordingSequencer sequencer = RecordingSequencer.builder().recordingDuration(recordingDuration).recordingEscapeHatch(recordingEscapeHatch).recorder(recorder).build();
sequencer.start();
dirCleanup.registerShutdownHook();
}
use of com.splunk.opentelemetry.logs.BatchingLogsProcessor in project splunk-otel-java by signalfx.
the class StackToSpanLinkageProcessorTest method testProcessor.
@Test
void testProcessor() {
Instant time = Instant.now();
StackToSpanLinkage linkedSpan = new StackToSpanLinkage(time, "some stack", "event name", SpanLinkage.NONE);
LogDataCreator logCreator = mock(LogDataCreator.class);
BatchingLogsProcessor exportProcessor = mock(BatchingLogsProcessor.class);
LogDataBuilder builder = LogDataBuilder.create(Resource.getDefault(), InstrumentationLibraryInfo.create("test", "1.2.3"));
LogData log = builder.setBody("the.body").build();
when(logCreator.apply(linkedSpan)).thenReturn(log);
StackToSpanLinkageProcessor processor = new StackToSpanLinkageProcessor(logCreator, exportProcessor);
processor.accept(linkedSpan);
verify(exportProcessor).emit(log);
}
Aggregations