File tree Expand file tree Collapse file tree 1 file changed +12
-10
lines changed
dd-trace-core/src/main/java/datadog/trace/core/flare Expand file tree Collapse file tree 1 file changed +12
-10
lines changed Original file line number Diff line number Diff line change 1616import datadog .trace .util .AgentTaskScheduler .Scheduled ;
1717import datadog .trace .util .Strings ;
1818import java .io .ByteArrayOutputStream ;
19+ import java .io .File ;
1920import java .io .IOException ;
21+ import java .io .RandomAccessFile ;
2022import java .lang .management .ManagementFactory ;
2123import java .lang .management .RuntimeMXBean ;
2224import java .lang .management .ThreadInfo ;
@@ -293,17 +295,17 @@ private void addLogs(ZipOutputStream zip) throws IOException {
293295 try {
294296 long size = Files .size (path );
295297 if (size > MAX_LOGFILE_SIZE_BYTES ) {
296- TracerFlare .addText (
297- zip ,
298- "tracer.log" ,
299- "Can't add tracer log file to the flare due to its size: "
300- + size
301- + "."
302- + "Max Size is "
303- + MAX_LOGFILE_SIZE_MB
304- + " MB." );
298+ int maxSizeOfSplit = MAX_LOGFILE_SIZE_BYTES / 2 ;
299+ File originalFile = new File (path .toString ());
300+ try (RandomAccessFile ras = new RandomAccessFile (originalFile , "r" )) {
301+ final byte [] buffer = new byte [maxSizeOfSplit ];
302+ ras .readFully (buffer );
303+ TracerFlare .addBinary (zip , "tracer_begin.log" , buffer );
304+ ras .seek (size - maxSizeOfSplit );
305+ ras .readFully (buffer );
306+ TracerFlare .addBinary (zip , "tracer_end.log" , buffer );
307+ }
305308 } else {
306-
307309 TracerFlare .addBinary (zip , "tracer.log" , readAllBytes (path ));
308310 }
309311 } catch (Throwable e ) {
You can’t perform that action at this time.
0 commit comments