-
Notifications
You must be signed in to change notification settings - Fork 93
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Andrew Johnson
committed
Dec 18, 2014
1 parent
c8b72c0
commit 596eeec
Showing
21 changed files
with
266 additions
and
98 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
.idea | ||
statsd-jvm-profiler.iml | ||
target | ||
dependency-reduced-pom.xml | ||
*.iml |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -8,7 +8,8 @@ | |
<packaging>jar</packaging> | ||
|
||
<name>statsd-jvm-profiler</name> | ||
<url>http://maven.apache.org</url> | ||
<url>https://github.com/etsy/statsd-jvm-profiler</url> | ||
|
||
<licenses> | ||
<license> | ||
<name>MIT License</name> | ||
|
@@ -17,6 +18,19 @@ | |
</license> | ||
</licenses> | ||
|
||
<scm> | ||
<url>[email protected]:etsy/statsd-jvm-profiler.git</url> | ||
<connection>scm:git:[email protected]:etsy/statsd-jvm-profiler.git</connection> | ||
</scm> | ||
|
||
<developers> | ||
<developer> | ||
<id>ajsquared</id> | ||
<name>Andrew Johnson</name> | ||
<url>github.com/ajsquared</url> | ||
</developer> | ||
</developers> | ||
|
||
<properties> | ||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> | ||
</properties> | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
16 changes: 16 additions & 0 deletions
16
src/main/java/com/etsy/statsd/profiler/reporter/Reporter.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
package com.etsy.statsd.profiler.reporter; | ||
|
||
/** | ||
* Interface for reporters | ||
* | ||
* @author Andrew Johnson | ||
*/ | ||
public interface Reporter { | ||
/** | ||
* Record a gauge value | ||
* | ||
* @param key The name of the gauge | ||
* @param value The value of the gauge | ||
*/ | ||
void recordGaugeValue(String key, long value); | ||
} |
28 changes: 28 additions & 0 deletions
28
src/main/java/com/etsy/statsd/profiler/reporter/StatsDReporter.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
package com.etsy.statsd.profiler.reporter; | ||
|
||
import com.timgroup.statsd.NonBlockingStatsDClient; | ||
import com.timgroup.statsd.StatsDClient; | ||
|
||
/** | ||
* Reporter that sends data to StatsD | ||
* | ||
* @author Andrew Johnson | ||
*/ | ||
public class StatsDReporter implements Reporter { | ||
private StatsDClient client; | ||
|
||
public StatsDReporter(String server, int port, String prefix) { | ||
client = new NonBlockingStatsDClient(prefix, server, port); | ||
} | ||
|
||
/** | ||
* Record a gauge value in StatsD | ||
* | ||
* @param key The key for the gauge | ||
* @param value The value of the gauge | ||
*/ | ||
@Override | ||
public void recordGaugeValue(String key, long value) { | ||
client.recordGaugeValue(key, value); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
package com.etsy.statsd.profiler.util; | ||
|
||
import java.util.Map; | ||
|
||
/** | ||
* Utility class for working with Maps | ||
* | ||
* @author Andrew Johnson | ||
*/ | ||
public class MapUtil { | ||
|
||
/** | ||
* Set a new value in a map or increment an existing value | ||
* | ||
* @param map The map in which to modify the value | ||
* @param key The key for the map | ||
* @param inc The new value or increment for the given key | ||
*/ | ||
public static void setOrIncrementMap(Map<String, Long> map, String key, long inc) { | ||
Long val = map.get(key); | ||
if (val == null) { | ||
map.put(key, inc); | ||
} else { | ||
map.put(key, val + inc); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.