Class StatsWriter

  • All Implemented Interfaces:
    AutoCloseable

    public class StatsWriter
    extends Object
    implements AutoCloseable
    Writes the current heap memory count to the file (bytes), along with a timestamp. This class provides a way to monitor memory allocation of a KinesisVideoClient by periodically writing the allocation size to a specified file in a csv-format.

    This class will spawn a new thread to record the metrics, and terminate that thread once close() is called.

    • Constructor Detail

      • StatsWriter

        public StatsWriter​(@Nonnull
                           String filePath,
                           @Nonnull
                           Duration pollingIntervalMs,
                           @Nonnull
                           NativeKinesisVideoClient kinesisVideoClient)
                    throws IOException
        Creates a new HeapWriter instance.
        Parameters:
        filePath - The path to the file where heap information will be written
        pollingIntervalMs - The interval in milliseconds between heap measurements
        kinesisVideoClient - The KinesisVideoClient instance to monitor
        Throws:
        IOException - If there's an error creating or opening the output file
    • Method Detail

      • close

        public void close()
        Stops the monitoring and closes all resources.
        Specified by:
        close in interface AutoCloseable