Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Client library changes for codahale/signalfx integration
Summary: A few extra libraries and helper function to join source/metric pairs Test Plan: Used internally Reviewed By: kris
- Loading branch information
Jack
committed
Aug 23, 2014
1 parent
dba3584
commit 381b490
Showing
27 changed files
with
727 additions
and
243 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 |
---|---|---|
|
@@ -31,3 +31,4 @@ cleanmvn.dot | |
*.iml | ||
.idea | ||
/analytics/server/log/ | ||
*.versionsBackup |
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,2 @@ | ||
#!/bin/bash | ||
mvn clean deploy -P release |
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,2 @@ | ||
#!/bin/bash | ||
mvn clean deploy |
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
42 changes: 42 additions & 0 deletions
42
...use-codahale/src/main/java/com/signalfuse/codahale/metrics/CallbackCumulativeCounter.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,42 @@ | ||
package com.signalfuse.codahale.metrics; | ||
|
||
import com.codahale.metrics.Counter; | ||
import com.codahale.metrics.Gauge; | ||
|
||
/** | ||
* <p> | ||
* Sometimes you want the rate of something like you would with a {@link Counter}, but you can't get | ||
* individual events and instead must set a total "count" of events at some periodic rate. This | ||
* class abstracts that out into a {@link Counter} that codahale can understand. | ||
* <p/> | ||
*/ | ||
public class CallbackCumulativeCounter extends Counter { | ||
private final Callback callback; | ||
|
||
public CallbackCumulativeCounter(Callback callback) { | ||
this.callback = callback; | ||
} | ||
|
||
@Override public void inc() { | ||
throw new UnsupportedOperationException("inc() on CallbackCumulativeCounter"); | ||
} | ||
|
||
@Override public void inc(long n) { | ||
throw new UnsupportedOperationException("inc() on CallbackCumulativeCounter"); | ||
} | ||
|
||
@Override public void dec() { | ||
throw new UnsupportedOperationException("dec() on CallbackCumulativeCounter"); | ||
} | ||
|
||
@Override public void dec(long n) { | ||
throw new UnsupportedOperationException("dec() on CallbackCumulativeCounter"); | ||
} | ||
|
||
@Override public long getCount() { | ||
return callback.getValue(); | ||
} | ||
|
||
public interface Callback extends Gauge<Long> { | ||
} | ||
} |
18 changes: 18 additions & 0 deletions
18
signalfuse-codahale/src/main/java/com/signalfuse/codahale/metrics/SettableDoubleGauge.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,18 @@ | ||
package com.signalfuse.codahale.metrics; | ||
|
||
import com.codahale.metrics.Gauge; | ||
import com.codahale.metrics.Metric; | ||
import com.google.common.util.concurrent.AtomicDouble; | ||
|
||
/** | ||
* Same as {@link SettableLongGauge} but for a double | ||
*/ | ||
public class SettableDoubleGauge implements Metric, Gauge<Double> { | ||
private final AtomicDouble value = new AtomicDouble(); | ||
public void setValue(double value) { | ||
this.value.set(value); | ||
} | ||
public Double getValue() { | ||
return value.get(); | ||
} | ||
} |
19 changes: 19 additions & 0 deletions
19
signalfuse-codahale/src/main/java/com/signalfuse/codahale/metrics/SettableLongGauge.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,19 @@ | ||
package com.signalfuse.codahale.metrics; | ||
|
||
import java.util.concurrent.atomic.AtomicLong; | ||
import com.codahale.metrics.Gauge; | ||
import com.codahale.metrics.Metric; | ||
|
||
/** | ||
* Works like a Gauge, but rather than getting its value from a callback, the value | ||
* is set when needed. This can be somewhat convienent, but direct use of a Gauge is likely better | ||
*/ | ||
public class SettableLongGauge implements Metric, Gauge<Long> { | ||
private final AtomicLong value = new AtomicLong(); | ||
public void setValue(long value) { | ||
this.value.set(value); | ||
} | ||
public Long getValue() { | ||
return value.get(); | ||
} | ||
} |
Oops, something went wrong.