Class StatsdClient

java.lang.Object
org.jenkinsci.plugins.githubautostatus.StatsdClient
All Implemented Interfaces:
StatsdWrapper

public class StatsdClient extends Object implements StatsdWrapper
Wraps regular UDP based StatsD client with concurrent hostname refreshing logic.
Author:
Tom Hadlaw (thomas.hadlaw@hootsuite.com)
  • Constructor Summary

    Constructors
    Constructor
    Description
    StatsdClient(String prefix, String hostname, int port)
    Constructs a new StatsD client.
  • Method Summary

    Modifier and Type
    Method
    Description
    getInstance(String prefix, String hostname, int port)
     
    void
    increment(String key, int amount)
    Runs a StatsD increment in a safe way.
    final void
    Attempts to create a new StatsD client instance, if successful then the active client is safely swapped out.
    Marked "final" so it is not considered an "overridable method used in constructor".
    void
    time(String key, long duration)
    Runs a StatsD timer state in a safe way.

    Methods inherited from class java.lang.Object

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

    • StatsdClient

      public StatsdClient(String prefix, String hostname, int port) throws com.timgroup.statsd.StatsDClientException
      Constructs a new StatsD client.
      Parameters:
      prefix - StatsD prefix
      hostname - StatsD collector hostname (default localhost)
      port - StatsD collector listener port (default 8125)
      Throws:
      com.timgroup.statsd.StatsDClientException
  • Method Details

    • newClient

      public final void newClient() throws com.timgroup.statsd.StatsDClientException
      Attempts to create a new StatsD client instance, if successful then the active client is safely swapped out.
      Marked "final" so it is not considered an "overridable method used in constructor".
      Throws:
      com.timgroup.statsd.StatsDClientException - if unable to refresh client
    • getInstance

      public static StatsdClient getInstance(String prefix, String hostname, int port)
    • increment

      public void increment(String key, int amount)
      Runs a StatsD increment in a safe way.
      Specified by:
      increment in interface StatsdWrapper
      Parameters:
      key - the bucket key
      amount - amount to increment
    • time

      public void time(String key, long duration)
      Runs a StatsD timer state in a safe way.
      Specified by:
      time in interface StatsdWrapper
      Parameters:
      key - the bucket key
      duration - the duration