Class GraphiteClient


  • public class GraphiteClient
    extends Object
    A simple graphite client that sends metrics to graphite server.
    Author:
    Michal Rockban
    • Constructor Detail

      • GraphiteClient

        public GraphiteClient​(String host,
                              int port,
                              String rootPath)
        C-tor
        Parameters:
        host - the graphite host machine
        port - the graphite port
        rootPath - the graphite root path environment (i.e qa/prod/quality, etc). Nullable
    • Method Detail

      • sendMetric

        public void sendMetric​(String key,
                               Number value)
                        throws GraphiteException
        Sends the metric to graphite, under environment root path, in the current timestamp.
        Parameters:
        key - metric path
        value - metric value
        Throws:
        GraphiteException
      • sendMetrics

        public void sendMetrics​(Map<String,​? extends Number> metrics)
                         throws GraphiteException
        Sends the metrics to graphite, under environment root path, in the current timestamp.
        Parameters:
        metrics - metric path and key map
        Throws:
        GraphiteException
      • sendMetrics

        public void sendMetrics​(Map<String,​? extends Number> metrics,
                                long timestamp)
                         throws GraphiteException
        Sends the metric to graphite, under environment root path
        Parameters:
        metrics - metric path and key map
        timestamp - the timestampe, in seconds since epoch.
        Throws:
        GraphiteException
      • sendMetric

        public void sendMetric​(String key,
                               Number value,
                               long timestamp)
                        throws GraphiteException
        Sends the metric to graphite, under environment root path, in the given timestamp.
        Parameters:
        key - metric path
        value - metric value
        timestamp - the timestamp (in seconds since epoch)
        Throws:
        GraphiteException
      • getCurrentTimestamp

        protected long getCurrentTimestamp()