java-dogstatsd-client

A tiny library allowing Java applications to communicate with DataDog statsd instances easily.

License

License

Categories

Categories

Java Languages CLI User Interface
GroupId

GroupId

com.github.arnabk
ArtifactId

ArtifactId

java-dogstatsd-client
Last Version

Last Version

1.0.4
Release Date

Release Date

Type

Type

jar
Description

Description

java-dogstatsd-client
A tiny library allowing Java applications to communicate with DataDog statsd instances easily.
Project URL

Project URL

https://github.com/arnabk/java-dogstatsd-client
Source Code Management

Source Code Management

http://github.com/arnabk/java-dogstatsd-client

Download java-dogstatsd-client

How to add to project

<!-- https://jarcasting.com/artifacts/com.github.arnabk/java-dogstatsd-client/ -->
<dependency>
    <groupId>com.github.arnabk</groupId>
    <artifactId>java-dogstatsd-client</artifactId>
    <version>1.0.4</version>
</dependency>
// https://jarcasting.com/artifacts/com.github.arnabk/java-dogstatsd-client/
implementation 'com.github.arnabk:java-dogstatsd-client:1.0.4'
// https://jarcasting.com/artifacts/com.github.arnabk/java-dogstatsd-client/
implementation ("com.github.arnabk:java-dogstatsd-client:1.0.4")
'com.github.arnabk:java-dogstatsd-client:jar:1.0.4'
<dependency org="com.github.arnabk" name="java-dogstatsd-client" rev="1.0.4">
  <artifact name="java-dogstatsd-client" type="jar" />
</dependency>
@Grapes(
@Grab(group='com.github.arnabk', module='java-dogstatsd-client', version='1.0.4')
)
libraryDependencies += "com.github.arnabk" % "java-dogstatsd-client" % "1.0.4"
[com.github.arnabk/java-dogstatsd-client "1.0.4"]

Dependencies

compile (1)

Group / Artifact Type Version
org.apache.commons : commons-math3 jar 3.4.1

test (3)

Group / Artifact Type Version
junit : junit jar 4.11
org.hamcrest : hamcrest-all jar 1.3
com.googlecode.openpojo : openpojo jar 0.6.2

Project Modules

There are no modules declared in this project.

java-dogstatsd-client Build Status

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 events and blocking metrics for use with dogstatsd.

Downloads

The client jar is distributed via maven central

<dependency>
    <groupId>com.github.arnabk</groupId>
    <artifactId>java-dogstatsd-client</artifactId>
    <version>1.0.5</version>
</dependency>

Usage

Non-blocking usage (metrics)

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

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 */

    /* Compatibility note: Unlike upstream statsd, DataDog expects execution times to be a
     * floating-point value in seconds, not a millisecond value. This library
     * does the conversion from ms to fractional seconds.
     */
    statsd.recordExecutionTime("bag", 25, "cluster:foo"); /* DataDog extension: cluster tag */
  }
}

Blocking usage (metrics)

import com.github.arnabk.statsd.BlockingStatsDClient;
import com.timgroup.statsd.StatsDClient;

public class Foo {

  private static final StatsDClient statsd = new BlockingStatsDClient(
    "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 */

    /* Compatibility note: Unlike upstream statsd, DataDog expects execution times to be a
     * floating-point value in seconds, not a millisecond value. This library
     * does the conversion from ms to fractional seconds.
     */
    statsd.recordExecutionTime("bag", 25, "cluster:foo"); /* DataDog extension: cluster tag */
  }
}

Non-blocking usage (events)

import com.github.arnabk.statsd.NonBlockingStatsDEventClient;

public class Foo {

  private static final NonBlockingStatsDEventClient statsd = new NonBlockingStatsDEventClient(
    "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.event("title", "message");
  }
}

Blocking usage (events)

import com.github.arnabk.statsd.BlockingStatsDEventClient;

public class Foo {

  private static final BlockingStatsDEventClient statsd = new BlockingStatsDEventClient(
    "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.event("title", "message");
  }
}

Versions

Version
1.0.4
1.0.3
1.0.2
1.0.1
1.0.0