Skip to content

Instantly share code, notes, and snippets.

View benhubert's full-sized avatar

Benjamin Hubert benhubert

View GitHub Profile
@benhubert
benhubert / MethodProfiler.java
Created September 20, 2017 12:05
Example method profiler using AspectJ for StatsD blogpost at tech.willhaben.at
@Aspect
public class MethodProfiler {
private final StatsDClient statsd;
public MethodProfiler(StatsDClient statsd) {
this.statsd = statsd;
}
@Pointcut("execution(* at.willhaben.examples.statsd.rest.RandomController.*(..))")
@benhubert
benhubert / example StatsD UDP packet
Created September 20, 2017 11:58
Example StatsD packet for tech.willhaben.at blogpost
example.app.service.random:1|c
@benhubert
benhubert / StatsD Example
Created September 20, 2017 11:57
Example for tech.willhaben.at blogpost
statsd.incrementCounter("service.random");
@benhubert
benhubert / MetricsConfig.java
Created September 20, 2017 11:54
Spring Boot configuration for collecting metrics with StatsD
@Configuration
public class MetricsConfig {
@Bean
public StatsDClient statsDClient(
@Value("${metrics.statsd.host:localhost}") String host,
@Value("${metrics.statsd.port:8125}") int port,
@Value("${metrics.prefix:example.app}") String prefix
) {
return new NonBlockingStatsDClient(prefix, host, port);
}
@benhubert
benhubert / pom.xml
Created September 20, 2017 11:39
Maven dependency for timgroup
<dependency>
<groupid>com.timgroup</groupid>
<artifactid>java-statsd-client</artifactid>
<version>3.0.1</version>
</dependency>
import java.io.*;
import java.net.*;
/**
* Simple UDP server that listens for packets on port 8125 and
* prints them. Intended for testing a StatsD client.
*/
public class StatsdLogger
{
public static void main(String args[]) throws Exception {