Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
44 commits
Select commit Hold shift + click to select a range
11e4a22
Set up M3 reporter project, build, and thrift compilation
justinjc Aug 25, 2017
5d426d9
Update DEVELOPER.md about Thrift
justinjc Aug 25, 2017
fa23527
Initial commit of UDP transport
justinjc Aug 25, 2017
d9785ee
Use safer synchronized Objects over locks
justinjc Aug 25, 2017
6b749f4
Fix checkstyle errors
justinjc Aug 28, 2017
668e99a
Big chunk of M3 reporter functionality
justinjc Aug 29, 2017
53bf961
Include missing changes from previous commit
justinjc Aug 29, 2017
b6b543d
Add ExecutorService and ObjectPool
justinjc Aug 30, 2017
11ba23d
Add ResourcePool
justinjc Aug 30, 2017
66c9888
Use ResourcePool instead of allocating new
justinjc Aug 31, 2017
88119c2
Fix exceptions; add JavaDocs
justinjc Aug 31, 2017
38fb9d9
Move MetricType into correct package
justinjc Aug 31, 2017
80c68bd
Revert to previous gradle-wrapper
justinjc Aug 31, 2017
c52a7f8
Use Gradle 3.5
justinjc Sep 1, 2017
fcca248
Install Thrift on Travis
justinjc Sep 8, 2017
46bd28e
Install different packages to install Thrift
justinjc Sep 8, 2017
3b45aa7
More M3 reporter functionality
justinjc Sep 11, 2017
d0aef44
Improve comments and Javadocs
justinjc Sep 11, 2017
c9932e5
Fix ObjectPool and SizedMetric bug; add some tests
justinjc Sep 12, 2017
f7186dd
Fix checkstyle
justinjc Sep 12, 2017
880147a
Clarify some design choices in comments
justinjc Sep 13, 2017
b0c2eca
Put generated sources in source dir to check into git
justinjc Sep 13, 2017
8291cd1
Only compile thrift if explicitly set a property to; update DEVELOPER…
justinjc Sep 13, 2017
21260a1
Extract out function to get hostname
justinjc Sep 13, 2017
6cbbf4e
Have SizedMetric ObjectPools; warn instead of throw on InterruptedExc…
justinjc Sep 14, 2017
7ed0f75
Move thrift-specific classes into m3 package
justinjc Sep 18, 2017
db8015f
JMH profiling; Use Gradle 4.0; Benchmarking ResourcePool; Use TCompac…
justinjc Sep 24, 2017
7221592
Remove ResourcePool usage
justinjc Sep 24, 2017
488c891
Use isOpen flag on M3Reporter
justinjc Sep 24, 2017
0bc003f
Make Duration toString similar to Go's; remove Cached* usage
justinjc Sep 26, 2017
0376dc7
Remove dead ObjectPool and Cached* code
justinjc Sep 26, 2017
c69450d
Move M3Reporter constructor validation to Builder
justinjc Sep 26, 2017
3fed782
Support for multi-UDP connections
justinjc Sep 27, 2017
c3fef3b
Remove unused MetricType; Fix multi UDP client bug
justinjc Sep 28, 2017
ee94804
Fix various edge condition bugs
justinjc Sep 28, 2017
e59d63d
Warn instead of throw on recoverable exceptions; flush automatically …
justinjc Oct 3, 2017
cb0191e
Don't re-interrupt thread when we want to continue business as usual
justinjc Oct 9, 2017
267babc
Use close sentinel metric instead of locks; code refactoring
justinjc Oct 16, 2017
d3ba08f
New MetricBatch instantiation instead of use/clean to avoid synchroni…
justinjc Oct 16, 2017
ea745f5
Fix flushing with close SizedMetric sentinel
justinjc Oct 17, 2017
9c32835
Put Processor back as private class
justinjc Oct 17, 2017
fa7b255
Comment on HashMap sizing
justinjc Oct 18, 2017
cccaeaf
Remove flush retry logic
justinjc Oct 23, 2017
c9177dc
Configurable max processor wait time
justinjc Oct 24, 2017
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions DEVELOPER.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ This document summarizes information relevant to Java tally contributors.
### Prerequisites
In order to build this project, you must have:
- JDK-7 or later
- Apache Thrift 0.9.x -- only if you plan to make changes to Thrift files and recompile (regenerate) source files

### Building and testing
Gradle is used to build tally. Run this from the top-level directory to build the project:
Expand All @@ -19,6 +20,12 @@ To run the project's tests:
./gradlew check
```

By default, the build does *not* compile Thrift files to generate sources. If you make changes to Thrift files and need
regenerate sources, make sure you have thrift 0.9.x installed and build with the `genThrift` property set, e.g.
```bash
./gradlew clean :tally-m3:build -PgenThrift

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

dope!

```

### Making changes
The source code of tally is managed using GitHub, and as such, we use its features to, for example,
track [issues](https://help.github.com/articles/about-issues/) and create
Expand Down
33 changes: 21 additions & 12 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ plugins {
id 'signing'
id 'checkstyle'
id 'jacoco'
id 'net.researchgate.release' version '2.4.0' apply false
id 'net.researchgate.release' version '2.6.0' apply false
id 'com.github.kt3k.coveralls' version '2.8.1'
}

Expand Down Expand Up @@ -126,13 +126,6 @@ allprojects {
}
}

// ----------------------
// Build & Release
// ----------------------
task wrapper(type: Wrapper) {
gradleVersion = '3.3'
}

release {
tagTemplate = '$name-$version'
}
Expand Down Expand Up @@ -171,6 +164,11 @@ subprojects {

ext."signing.secretKeyRingFile" = "ci/${ext.secretKeyRingFileName}"

task wrapper(type: Wrapper) {
// Gradle version 4+ required for JMH benchmarking, otherwise v3.5+ is sufficient
gradleVersion = '4.0'
}

// ----------------------
// Fat jar task factories
// ----------------------
Expand Down Expand Up @@ -206,7 +204,8 @@ def fatJavadocJar(name, projects) {
type: Javadoc,
dependsOn: projects.collect{it + ':classes'}
]) {
source = projects.collect{ project(it).sourceSets.main.allSource }
classpath = files(projects.collect{ project(it).sourceSets.main.compileClasspath })
source = projects.collect{ project(it).sourceSets.main.allJava }
}

return tasks.create([
Expand All @@ -221,19 +220,29 @@ def fatJavadocJar(name, projects) {
}

// --------------------------------------
// StatsD fat jar
// StatsD reporter fat jar
// --------------------------------------

def statsd_fat_jar_name = 'tally-statsd-fat'
def statsd_fat_jar_projs = [':tally-core', ':tally-statsd']

// --------------------------------------
// M3 reporter fat jar

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If I read this right, you're only creating fat jars. Do you also want to create thin jars?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The thin jars are created automatically, configured in the subprojects section of this build file. The fat jars need explicit logic to create, since the parent project is just a shell to contain the subprojects and does not have any code of its own.

// --------------------------------------

def m3_fat_jar_name = 'tally-m3-fat'
def m3_fat_jar_projs = [':tally-core', ':tally-m3']

// -------------------
// Fat jars to publish
// -------------------
artifacts {
archives fatJar(statsd_fat_jar_name, statsd_fat_jar_projs),
fatSourcesJar(statsd_fat_jar_name, statsd_fat_jar_projs),
fatJavadocJar(statsd_fat_jar_name, statsd_fat_jar_projs)
fatJavadocJar(statsd_fat_jar_name, statsd_fat_jar_projs),
fatJar(m3_fat_jar_name, m3_fat_jar_projs),
fatSourcesJar(m3_fat_jar_name, m3_fat_jar_projs),
fatJavadocJar(m3_fat_jar_name, m3_fat_jar_projs)
}

nexusStaging {}
Expand All @@ -248,7 +257,7 @@ coveralls {
task jacocoRootReport(type: org.gradle.testing.jacoco.tasks.JacocoReport) {
dependsOn = subprojects.test
sourceDirectories = files(subprojects.sourceSets.main.allSource.srcDirs)
classDirectories = files(subprojects.sourceSets.main.output.classesDir)
classDirectories = files(subprojects.sourceSets.main.output.classesDirs)
executionData = files(subprojects.jacocoTestReport.executionData)

reports {
Expand Down
8 changes: 8 additions & 0 deletions checkstyles/suppressions.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<?xml version="1.0"?>
<!DOCTYPE suppressions PUBLIC
"-//Puppy Crawl//DTD Suppressions 1.1//EN"
"http://www.puppycrawl.com/dtds/suppressions_1_1.dtd">

<suppressions>
<suppress files="[\\/]generated[\\/]" checks="[a-zA-Z0-9]*"/>
</suppressions>
4 changes: 4 additions & 0 deletions checkstyles/uber_checks.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,10 @@
<module name="Checker">
<property name="charset" value="UTF-8"/>

<module name="SuppressionFilter">
<property name="file" value="checkstyles/suppressions.xml" />
</module>

<!-- Trailing spaces -->
<module name="RegexpSingleline">
<property name="format" value="\s+$"/>
Expand Down
11 changes: 10 additions & 1 deletion core/src/main/java/com/uber/m3/tally/AbstractBuckets.java
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@

import com.uber.m3.util.Duration;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
import java.util.Iterator;
Expand All @@ -35,7 +36,15 @@ public abstract class AbstractBuckets<T> implements Buckets<T> {
protected List<T> buckets;

AbstractBuckets(T[] buckets) {
this.buckets = Arrays.asList(buckets);
if (buckets == null) {
this.buckets = new ArrayList<>();
} else {
this.buckets = new ArrayList<>(Arrays.asList(buckets));
}
}

AbstractBuckets() {
this(null);
}

@Override
Expand Down
78 changes: 76 additions & 2 deletions core/src/main/java/com/uber/m3/tally/BucketPairImpl.java
Original file line number Diff line number Diff line change
Expand Up @@ -22,16 +22,18 @@

import com.uber.m3.util.Duration;

import java.util.Collections;

/**
* Default implementation of a {@link BucketPair}
*/
class BucketPairImpl implements BucketPair {
public class BucketPairImpl implements BucketPair {
private double lowerBoundValue;
private double upperBoundValue;
private Duration lowerBoundDuration;
private Duration upperBoundDuration;

BucketPairImpl(
public BucketPairImpl(
double lowerBoundValue,
double upperBoundValue,
Duration lowerBoundDuration,
Expand All @@ -43,6 +45,78 @@ class BucketPairImpl implements BucketPair {
this.upperBoundDuration = upperBoundDuration;
}

public static BucketPair[] bucketPairs(Buckets buckets) {
if (buckets == null || buckets.size() < 1) {
return new BucketPair[]{
new BucketPairImpl(
-Double.MAX_VALUE,
Double.MAX_VALUE,
Duration.MIN_VALUE,
Duration.MAX_VALUE
)
};
}

if (buckets instanceof DurationBuckets) {
// If using duration buckets separating negative times and
// positive times is very much desirable as depending on the
// reporter will create buckets "-infinity,0" and "0,{first_bucket}"
// instead of just "-infinity,{first_bucket}" which for time
// durations is not desirable nor pragmatic
boolean hasZero = false;

for (Duration duration : buckets.asDurations()) {
if (duration.equals(Duration.ZERO)) {
hasZero = true;
break;
}
}

if (!hasZero) {
((DurationBuckets) buckets).add(Duration.ZERO);
}
}

Collections.sort(buckets);

Double[] asValueBuckets = buckets.asValues();
Duration[] asDurationBuckets = buckets.asDurations();
BucketPair[] pairs = new BucketPair[buckets.size() + 1];

// Add lower bound
pairs[0] = new BucketPairImpl(
-Double.MAX_VALUE,
asValueBuckets[0],
Duration.MIN_VALUE,
asDurationBuckets[0]
);

double prevValueBucket = asValueBuckets[0];
Duration prevDurationBucket = asDurationBuckets[0];

for (int i = 1; i < buckets.size(); i++) {
pairs[i] = new BucketPairImpl(
prevValueBucket,
asValueBuckets[i],
prevDurationBucket,
asDurationBuckets[i]
);

prevValueBucket = asValueBuckets[i];
prevDurationBucket = asDurationBuckets[i];
}

// Add upper bound
pairs[pairs.length - 1] = new BucketPairImpl(
prevValueBucket,
Double.MAX_VALUE,
prevDurationBucket,
Duration.MAX_VALUE
);

return pairs;
}

@Override
public double lowerBoundValue() {
return lowerBoundValue;
Expand Down
32 changes: 0 additions & 32 deletions core/src/main/java/com/uber/m3/tally/CachedCounter.java

This file was deleted.

32 changes: 0 additions & 32 deletions core/src/main/java/com/uber/m3/tally/CachedGauge.java

This file was deleted.

32 changes: 0 additions & 32 deletions core/src/main/java/com/uber/m3/tally/CachedHistogramBucket.java

This file was deleted.

34 changes: 0 additions & 34 deletions core/src/main/java/com/uber/m3/tally/CachedTimer.java

This file was deleted.

Loading