@Test public void testUniqueLocalTraceFileName() { String filename1 = LocalFileSpanReceiver.getUniqueLocalTraceFileName(); String filename2 = LocalFileSpanReceiver.getUniqueLocalTraceFileName(); boolean eq = filename1.equals(filename2); if (System.getProperty("os.name").startsWith("Linux")) { // ${java.io.tmpdir}/[pid] assertTrue(eq); } else { // ${java.io.tmpdir}/[random UUID] assertFalse(eq); } }
doFlush(toFlush, numToFlush); } catch (IOException ioe) { LOG.error("Error flushing buffers to " + path + ": " +
path = getUniqueLocalTraceFileName(); } else { path = pathStr;
doFlush(toFlush, numToFlush); } catch (IOException ioe) { LOG.error("Error flushing buffers to " + path + ": " +
path = getUniqueLocalTraceFileName(); } else { path = pathStr;
doFlush(toFlush, numToFlush); } catch (IOException ioe) { LOG.error("Error flushing buffers to " + path + ": " +
path = getUniqueLocalTraceFileName(); } else { path = pathStr;
doFlush(toFlush, toFlush.length); } catch (IOException ioe) { LOG.error("Error flushing buffers to " + path + ": " +
@Test public void testWriteToLocalFile() throws IOException { String traceFileName = LocalFileSpanReceiver.getUniqueLocalTraceFileName(); Tracer tracer = new Tracer.Builder(). name("testWriteToLocalFileTracer"). tracerPool(new TracerPool("testWriteToLocalFile")). conf(HTraceConfiguration.fromKeyValuePairs( "sampler.classes", "AlwaysSampler", "span.receiver.classes", LocalFileSpanReceiver.class.getName(), "local.file.span.receiver.path", traceFileName, "tracer.id", "%{tname}")). build(); TraceScope scope = tracer.newScope("testWriteToLocalFile"); scope.close(); tracer.close(); ObjectMapper mapper = new ObjectMapper(); MilliSpan span = mapper.readValue(new File(traceFileName), MilliSpan.class); assertEquals("testWriteToLocalFile", span.getDescription()); assertEquals("testWriteToLocalFileTracer", span.getTracerId()); } }
doFlush(toFlush, toFlush.length); } catch (IOException ioe) { LOG.error("Error flushing buffers to " + path + ": " +
doFlush(toFlush, toFlush.length); } catch (IOException ioe) { LOG.error("Error flushing buffers to " + path + ": " +