Class InfluxExporter

  • All Implemented Interfaces:
    java.lang.AutoCloseable

    public class InfluxExporter
    extends java.lang.Object
    implements java.lang.AutoCloseable
    • Constructor Summary

      Constructors 
      Constructor Description
      InfluxExporter​(java.lang.String url, java.lang.String user, java.lang.String password, java.lang.String database, java.lang.String retention, boolean createDatabase, boolean exportDifference, java.util.function.Function<java.lang.String,​java.lang.String> measurementNameProvider)
      Creates a new influx Exporter.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      void close()
      Closes the underlying InfluxDB connection.
      void export()
      Fetches all metrics from OpenCensus and attempts to export them to Influx.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • InfluxExporter

        public InfluxExporter​(java.lang.String url,
                              java.lang.String user,
                              java.lang.String password,
                              java.lang.String database,
                              java.lang.String retention,
                              boolean createDatabase,
                              boolean exportDifference,
                              java.util.function.Function<java.lang.String,​java.lang.String> measurementNameProvider)
        Creates a new influx Exporter. The export does not export by itself, but instead has to be triggered manually by calling export(); This can be done periodically for example using ScheduledExecutorService.scheduleAtFixedRate(Runnable, long, long, TimeUnit).
        Parameters:
        url - The http url of the influx to connect to
        user - the user to use when connecting to influx, can be null
        password - the password to use when connecting to influx, can be null
        database - the influx database to
        retention - the retention policy of the database to write to
        createDatabase - if true, the exporter will create the specified database with an "autogen" policy when it connects
        measurementNameProvider - a function to use for resolving the measurement names for custom metrics. By default, this is done by finding the measure corresponding to a view. If this function returns a non-null value, the provided measurement name is used instead.
    • Method Detail

      • export

        public void export()
        Fetches all metrics from OpenCensus and attempts to export them to Influx. No exception is thrown in case of a failure, instead the data is just not written and the error is logged.
      • close

        public void close()
        Closes the underlying InfluxDB connection. If export() is invoked after close(), the connection will be opened again.
        Specified by:
        close in interface java.lang.AutoCloseable