public static void runTracer(int pid, Path filePath, long threshold, Consumer<? super Exception> exceptionHandler) throws IOException {
    if (running) throw new IllegalStateException("Tracer already started");
    tracingStartMs = System.currentTimeMillis();
    tracingStartNs = System.nanoTime();
    Files.createDirectories(filePath.getParent());
    FileOutputStream fileOutputStream = new FileOutputStream(filePath.toFile());
    OutputStreamWriter writer = new OutputStreamWriter(new BufferedOutputStream(fileOutputStream), StandardCharsets.UTF_8);
    fileState = new FileState(writer);
    durationThreshold = threshold;
    Tracer.pid = pid;
    executor = createExecutor();
    FlushingTask flushingTask = new FlushingTask(fileState, false, exceptionHandler);
    executor.scheduleAtFixedRate(flushingTask, 5, 5, TimeUnit.SECONDS);
    shutdownHook = new Thread(new FlushingTask(fileState, true, exceptionHandler), "Shutdown hook trace flusher");
    Runtime.getRuntime().addShutdownHook(shutdownHook);
    running = true;
  }
public static void runTracer(int pid, Path filePath, long threshold, Consumer<? super Exception> exceptionHandler)