All Projects → indeedeng → java-dogstatsd-client

indeedeng / java-dogstatsd-client

Licence: other
a java statsd client library

Project Moved

This project has merged with datadog/java-dogstatsd-client. This repository primarily exists for historical purposes. Please file issues and pull requests at datadog/java-dogstatsd-client.

java-dogstatsd-client

A statsd client library implemented in Java. Allows for Java applications to easily communicate with statsd.

This version is forked from the upstream java-statsd-client project, adding support for Datadog extensions for use with dogstatsd.

This version also adds support for empty or null prefixes, to allow a client to send arbitrary statistic names.

Downloads

The client jar is distributed via maven central, and can be downloaded here.

<dependency>
    <groupId>com.indeed</groupId>
    <artifactId>java-dogstatsd-client</artifactId>
    <version>2.0.16</version>
</dependency>

Usage

import com.timgroup.statsd.StatsDClient;
import com.timgroup.statsd.NonBlockingStatsDClient;

public class Foo {

  private static final StatsDClient statsd = new NonBlockingStatsDClient(
    "my.prefix",                          /* prefix to any stats; may be null or empty string */
    "statsd-host",                        /* common case: localhost */
    8125,                                 /* port */
    new String[] {"tag:value"}            /* Datadog extension: Constant tags, always applied */
  );

  public static final void main(String[] args) {
    statsd.incrementCounter("foo");
    statsd.recordGaugeValue("bar", 100);
    statsd.recordGaugeValue("baz", 0.01); /* Datadog extension: support for floating-point gauges */
    statsd.recordHistogramValue("qux", 15);    /* Datadog extension: histograms */
    statsd.recordHistogramValue("qux", 15.5);  /* ...also floating-point */

    /* expects times in milliseconds
     */
    statsd.recordExecutionTime("bag", 25, "cluster:foo"); /* Datadog extension: cluster tag */
  }
}
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].