Code Monkey home page Code Monkey logo

statsd-netty's Introduction

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

statsd-netty's People

Contributors

flozano avatar timboudreau avatar bitdeli-chef avatar

Stargazers

Moteesh avatar Omachonu Ogali avatar  avatar dan avatar Shimi Kiviti avatar

Watchers

Meletis Margaritis avatar James Cloos avatar  avatar

statsd-netty's Issues

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.