java-monasca-statsd:用 Java 实现的 statsd 客户端库。 允许 Java 应用程序轻松地与 sta

  • i7_388268
    了解作者
  • 33.4KB
    文件大小
  • zip
    文件格式
  • 0
    收藏次数
  • VIP专享
    资源类型
  • 0
    下载次数
  • 2022-06-09 08:07
    上传日期
java-monasca-statsd 用 Java 实现的 statsd 客户端库。 允许 Java 应用程序轻松地与 statsd 通信。 这个版本是从上游的项目分叉出来的,增加了对 monasca 维度的支持 在讨论图书馆 下载 客户端jar通过maven central分发 < dependency> < groupId>com.github.arnabk</ groupId> < artifactId>java-dogstatsd-client</ artifactId> < version>1.0.1</ version> </ dependency> 用法 非阻塞使用(指标) import com.timgroup.statsd.NonBlockingStatsDClient ; import com.timgroup.stat
java-monasca-statsd-master.zip
内容介绍
java-monasca-statsd ================== 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](https://github.com/indeedeng/java-dogstatsd-client) project, adding support for monasca dimensions Discuss the library [here](http://ranartech.com/techblog/?p=160) Downloads --------- The client jar is distributed via maven central ```xml <dependency> <groupId>com.github.arnabk</groupId> <artifactId rel='nofollow' onclick='return false;'>java-dogstatsd-client</artifactId> <version>1.0.1</version> </dependency> ``` Usage ----- **Non-blocking usage (metrics)** ```java 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)** ```java 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)** ```java 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)** ```java 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"); } } ```
评论
    相关推荐