statsd-netty

A netty-based StatsD UDP client

License

License

Categories

Categories

Net Netty Networking
GroupId

GroupId

com.flozano.statsd-netty
ArtifactId

ArtifactId

statsd-netty
Last Version

Last Version

0.1.5
Release Date

Release Date

Type

Type

jar
Description

Description

statsd-netty
A netty-based StatsD UDP client
Project URL

Project URL

https://github.com/flozano/statsd-netty
Source Code Management

Source Code Management

https://github.com/flozano/statsd-netty/

Download statsd-netty

How to add to project

<!-- https://jarcasting.com/artifacts/com.flozano.statsd-netty/statsd-netty/ -->
<dependency>
    <groupId>com.flozano.statsd-netty</groupId>
    <artifactId>statsd-netty</artifactId>
    <version>0.1.5</version>
</dependency>
// https://jarcasting.com/artifacts/com.flozano.statsd-netty/statsd-netty/
implementation 'com.flozano.statsd-netty:statsd-netty:0.1.5'
// https://jarcasting.com/artifacts/com.flozano.statsd-netty/statsd-netty/
implementation ("com.flozano.statsd-netty:statsd-netty:0.1.5")
'com.flozano.statsd-netty:statsd-netty:jar:0.1.5'
<dependency org="com.flozano.statsd-netty" name="statsd-netty" rev="0.1.5">
  <artifact name="statsd-netty" type="jar" />
</dependency>
@Grapes(
@Grab(group='com.flozano.statsd-netty', module='statsd-netty', version='0.1.5')
)
libraryDependencies += "com.flozano.statsd-netty" % "statsd-netty" % "0.1.5"
[com.flozano.statsd-netty/statsd-netty "0.1.5"]

Dependencies

compile (3)

Group / Artifact Type Version
org.javassist : javassist Optional jar 3.19.0-GA
io.netty : netty-all jar 4.0.25.Final
org.slf4j : slf4j-api jar 1.7.9

test (5)

Group / Artifact Type Version
junit : junit jar 4.11
org.mockito : mockito-all jar 1.10.17
ch.qos.logback : logback-classic jar 1.1.2
com.jayway.awaitility : awaitility jar 1.6.3
com.google.guava : guava jar 18.0

Project Modules

There are no modules declared in this project.

statsd-netty

Build Status

A Netty-based statsd client with Apache 2.0 License.

It requires Java 8, netty and SLF4J.

How to use:

Maven dependency:

		<dependency>
			<groupId>com.flozano.statsd-netty</groupId>
			<artifactId>statsd-netty</artifactId>
			<version>0.1.4</version>
		</dependency>

Example code:

		try (Metrics metrics = MetricsBuilder.create()
				.withClient((clientBuilder) -> //
						clientBuilder.withHost("127.0.0.1") //
								.withPort(8125) //
								.withSampleRate(0.5) // send 50% of metrics only
				).withClock(Clock.systemUTC()).build()) {

			// Send a counter metric immediately
			metrics.counter("visitors").hit();

			// Create a batch of metrics that will be sent at the end of the try
			// block.
			try (Metrics batch = metrics.batch()) {
				batch.gauge("activeDatabaseConnections").value(
						getConnectionsFromPool());
				batch.gauge("activeSessions").delta(-1);
			}

			// Schedule a couple of gauges to be reported every 60 seconds
			metrics.gauge("databaseConnectionPool", "activeConnections")
					.supply(60, TimeUnit.SECONDS,
							() -> getConnectionsFromPool());

			metrics.gauge("databaseConnectionPool", "waitingForConnection")
					.supply(1, TimeUnit.MINUTES,
							() -> getWaitingForConnection());

			// Measure the time spent inside the try block
			try (TimeKeeping o = metrics.timer("timeSpentSavingData").time()) {
				saveData();
			}
		}

(note that you should keep the "Metrics" instance open for the whole lifecycle of your application).

Copyright 2014 Francisco A. Lozano López

Bitdeli Badge

Versions

Version
0.1.5
0.1.4
0.1.3
0.1.2
0.1.1
0.1.0
0.0.4
0.0.3
0.0.2