aboutsummaryrefslogtreecommitdiffstats
path: root/examples
diff options
context:
space:
mode:
authoreasy <g-easy@users.noreply.github.com>2018-03-15 16:21:31 +1100
committerGitHub <noreply@github.com>2018-03-15 16:21:31 +1100
commitb40fd021e3f3c2323c157f6a5cf3b5abdbca6bd8 (patch)
tree170ba6a99522483727e325ede49d192e31f79548 /examples
parent7d681cc50a3478303b5d26b884d0638d5dbae6d5 (diff)
downloadplatform_external_opencensus-java-b40fd021e3f3c2323c157f6a5cf3b5abdbca6bd8.tar.gz
platform_external_opencensus-java-b40fd021e3f3c2323c157f6a5cf3b5abdbca6bd8.tar.bz2
platform_external_opencensus-java-b40fd021e3f3c2323c157f6a5cf3b5abdbca6bd8.zip
Make "./gradlew goJF" work in examples/ (#1059)
Diffstat (limited to 'examples')
-rw-r--r--examples/build.gradle38
-rw-r--r--examples/src/main/java/io/opencensus/examples/helloworld/QuickStart.java23
2 files changed, 50 insertions, 11 deletions
diff --git a/examples/build.gradle b/examples/build.gradle
index fe72d75a..ab5de34a 100644
--- a/examples/build.gradle
+++ b/examples/build.gradle
@@ -1,8 +1,25 @@
description = 'OpenCensus Examples'
-apply plugin: "checkstyle"
+buildscript {
+ repositories {
+ mavenCentral()
+ mavenLocal()
+ maven {
+ url "https://plugins.gradle.org/m2/"
+ }
+ }
+ dependencies {
+ classpath "gradle.plugin.com.github.sherter.google-java-format:google-java-format-gradle-plugin:0.6"
+ }
+}
+
+apply plugin: 'checkstyle'
apply plugin: 'idea'
apply plugin: 'java'
+// Plugins that require java8
+if (JavaVersion.current().isJava8Compatible()) {
+ apply plugin: 'com.github.sherter.google-java-format'
+}
repositories {
mavenCentral()
@@ -24,6 +41,25 @@ checkstyle {
configProperties["rootDir"] = file("$rootDir/../")
}
+// Google formatter works only on java8.
+if (JavaVersion.current().isJava8Compatible()) {
+ googleJavaFormat {
+ toolVersion '1.5'
+ }
+
+ afterEvaluate { // Allow subproject to add more source sets.
+ tasks.googleJavaFormat {
+ source = sourceSets*.allJava
+ include '**/*.java'
+ }
+
+ tasks.verifyGoogleJavaFormat {
+ source = sourceSets*.allJava
+ include '**/*.java'
+ }
+ }
+}
+
tasks.withType(JavaCompile) {
sourceCompatibility = '1.8'
targetCompatibility = '1.8'
diff --git a/examples/src/main/java/io/opencensus/examples/helloworld/QuickStart.java b/examples/src/main/java/io/opencensus/examples/helloworld/QuickStart.java
index f6626135..2ff505ee 100644
--- a/examples/src/main/java/io/opencensus/examples/helloworld/QuickStart.java
+++ b/examples/src/main/java/io/opencensus/examples/helloworld/QuickStart.java
@@ -56,27 +56,30 @@ public final class QuickStart {
private static final TagKey FRONTEND_KEY = TagKey.create("my.org/keys/frontend");
// videoSize will measure the size of processed videos.
- private static final MeasureLong VIDEO_SIZE = MeasureLong.create(
- "my.org/measure/video_size", "size of processed videos", "MBy");
+ private static final MeasureLong VIDEO_SIZE =
+ MeasureLong.create("my.org/measure/video_size", "size of processed videos", "MBy");
// Create view to see the processed video size distribution broken down by frontend.
// The view has bucket boundaries (0, 256, 65536) that will group measure values into
// histogram buckets.
private static final View.Name VIDEO_SIZE_VIEW_NAME = View.Name.create("my.org/views/video_size");
- private static final View VIDEO_SIZE_VIEW = View.create(
- VIDEO_SIZE_VIEW_NAME,
- "processed video size over time",
- VIDEO_SIZE,
- Aggregation.Distribution.create(BucketBoundaries.create(Arrays.asList(0.0, 256.0, 65536.0))),
- Collections.singletonList(FRONTEND_KEY),
- Cumulative.create());
+ private static final View VIDEO_SIZE_VIEW =
+ View.create(
+ VIDEO_SIZE_VIEW_NAME,
+ "processed video size over time",
+ VIDEO_SIZE,
+ Aggregation.Distribution.create(
+ BucketBoundaries.create(Arrays.asList(0.0, 256.0, 65536.0))),
+ Collections.singletonList(FRONTEND_KEY),
+ Cumulative.create());
/** Main launcher for the QuickStart example. */
public static void main(String[] args) throws InterruptedException {
TagContextBuilder tagContextBuilder =
tagger.currentBuilder().put(FRONTEND_KEY, TagValue.create("mobile-ios9.3.5"));
SpanBuilder spanBuilder =
- tracer.spanBuilder("my.org/ProcessVideo")
+ tracer
+ .spanBuilder("my.org/ProcessVideo")
.setRecordEvents(true)
.setSampler(Samplers.alwaysSample());
viewManager.registerView(VIDEO_SIZE_VIEW);