diff --git a/examples/build.gradle b/examples/build.gradle new file mode 100644 index 0000000000..fcb520bcce --- /dev/null +++ b/examples/build.gradle @@ -0,0 +1,43 @@ +plugins { + id 'com.github.sherter.google-java-format' apply false + id "com.jfrog.artifactory" apply false +} + +subprojects { + apply plugin: 'eclipse' + apply plugin: 'java' + apply plugin: 'java-library' + apply plugin: 'idea' + apply plugin: 'com.github.sherter.google-java-format' + + group = "io.opentelemetry" + version = "0.1.0-SNAPSHOT" + + ext { + opentelemetryVersion = "0.4.0-SNAPSHOT" + grpcVersion = '1.24.0' // CURRENT_GRPC_VERSION + protobufVersion = '3.10.0' + protocVersion = protobufVersion + } + + repositories { + mavenCentral() + jcenter() + maven { + // Add snapshot repository + url "https://oss.jfrog.org/artifactory/oss-snapshot-local" + } + } + + googleJavaFormat { + toolVersion = '1.7' + } + compileJava.dependsOn(verifyGoogleJavaFormat) + + //create a single Jar with all dependencies + task fatJar(type: Jar) { + baseName = project.name + '-all' + from { configurations.compile.collect { it.isDirectory() ? it : zipTree(it) } } + with jar + } +} diff --git a/examples/grpc/gradle/wrapper/gradle-wrapper.jar b/examples/gradle/wrapper/gradle-wrapper.jar similarity index 64% rename from examples/grpc/gradle/wrapper/gradle-wrapper.jar rename to examples/gradle/wrapper/gradle-wrapper.jar index 490fda8577..cc4fdc293d 100644 Binary files a/examples/grpc/gradle/wrapper/gradle-wrapper.jar and b/examples/gradle/wrapper/gradle-wrapper.jar differ diff --git a/examples/http/gradle/wrapper/gradle-wrapper.properties b/examples/gradle/wrapper/gradle-wrapper.properties similarity index 79% rename from examples/http/gradle/wrapper/gradle-wrapper.properties rename to examples/gradle/wrapper/gradle-wrapper.properties index a4b4429748..7578b974b4 100644 --- a/examples/http/gradle/wrapper/gradle-wrapper.properties +++ b/examples/gradle/wrapper/gradle-wrapper.properties @@ -1,5 +1,5 @@ distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-6.3-bin.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-6.3-all.zip zipStoreBase=GRADLE_USER_HOME -zipStorePath=wrapper/dists +zipStorePath=wrapper/dists \ No newline at end of file diff --git a/examples/grpc/gradlew b/examples/gradlew similarity index 100% rename from examples/grpc/gradlew rename to examples/gradlew diff --git a/examples/jaeger/gradlew.bat b/examples/gradlew.bat similarity index 92% rename from examples/jaeger/gradlew.bat rename to examples/gradlew.bat index 9109989e3c..24467a141f 100644 --- a/examples/jaeger/gradlew.bat +++ b/examples/gradlew.bat @@ -29,9 +29,6 @@ if "%DIRNAME%" == "" set DIRNAME=. set APP_BASE_NAME=%~n0 set APP_HOME=%DIRNAME% -@rem Resolve any "." and ".." in APP_HOME to make it shorter. -for %%i in ("%APP_HOME%") do set APP_HOME=%%~fi - @rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. set DEFAULT_JVM_OPTS="-Xmx64m" "-Xms64m" diff --git a/examples/grpc/README.md b/examples/grpc/README.md index af1fd5c190..9229d220f2 100644 --- a/examples/grpc/README.md +++ b/examples/grpc/README.md @@ -14,21 +14,21 @@ and create a **Child Span**. * Java 1.8 ## 1 - Compile -```bash -gradlew fatJar +```shell script +../gradlew fatJar ``` ## 2 - Start the Server -```bash -java -cp ./build/libs/opentelemetry-example-grpc-all-0.1.0-SNAPSHOT.jar io.opentelemetry.example.HelloWorldServer +```shell script +java -cp ./build/libs/opentelemetry-examples-grpc-all-0.1.0-SNAPSHOT.jar io.opentelemetry.example.HelloWorldServer ``` ## 3 - Start the normal Client -```bash -java -cp ./build/libs/opentelemetry-example-grpc-all-0.1.0-SNAPSHOT.jar io.opentelemetry.example.HelloWorldClient +```shell script +java -cp ./build/libs/opentelemetry-examples-grpc-all-0.1.0-SNAPSHOT.jar io.opentelemetry.example.HelloWorldClient ``` ## 4 - Start the streamed Client -```bash -java -cp ./build/libs/opentelemetry-example-grpc-all-0.1.0-SNAPSHOT.jar io.opentelemetry.example.HelloWorldClientStream +```shell script +java -cp ./build/libs/opentelemetry-examples-grpc-all-0.1.0-SNAPSHOT.jar io.opentelemetry.example.HelloWorldClientStream ``` \ No newline at end of file diff --git a/examples/grpc/build.gradle b/examples/grpc/build.gradle index c026a7eacf..1cb36b7e41 100644 --- a/examples/grpc/build.gradle +++ b/examples/grpc/build.gradle @@ -1,36 +1,19 @@ plugins { - // ASSUMES GRADLE 2.12 OR HIGHER. Use plugin version 0.7.5 with earlier gradle versions - id 'com.google.protobuf' version '0.8.8' - // Generate IntelliJ IDEA's .idea & .iml project files - id 'java' + id "com.google.protobuf" } -apply plugin: 'com.google.protobuf' - -group 'io.opentelemetry' -version '0.1.0-SNAPSHOT' - -def opentelemetryVersion = '0.3.0' +description = 'OpenTelemetry Examples for gRPC' +ext.moduleName = "io.opentelemetry.examples.grpc" -def grpcVersion = '1.24.0' // CURRENT_GRPC_VERSION -def protobufVersion = '3.10.0' -def protocVersion = protobufVersion - -repositories { - mavenCentral() -} dependencies { compile "io.opentelemetry:opentelemetry-api:${opentelemetryVersion}" compile "io.opentelemetry:opentelemetry-sdk:${opentelemetryVersion}" compile "io.opentelemetry:opentelemetry-exporters-logging:${opentelemetryVersion}" - compile "io.grpc:grpc-protobuf:${grpcVersion}" compile "io.grpc:grpc-stub:${grpcVersion}" compile "io.grpc:grpc-netty-shaded:${grpcVersion}" - - testCompile group: 'junit', name: 'junit', version: '4.12' } protobuf { @@ -52,11 +35,3 @@ sourceSets { } } } - -//create a single Jar with all dependencies -task fatJar(type: Jar) { - baseName = project.name + '-all' - from { configurations.compile.collect { it.isDirectory() ? it : zipTree(it) } } - with jar -} - diff --git a/examples/grpc/gradle/wrapper/gradle-wrapper.properties b/examples/grpc/gradle/wrapper/gradle-wrapper.properties deleted file mode 100644 index a4b4429748..0000000000 --- a/examples/grpc/gradle/wrapper/gradle-wrapper.properties +++ /dev/null @@ -1,5 +0,0 @@ -distributionBase=GRADLE_USER_HOME -distributionPath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-6.3-bin.zip -zipStoreBase=GRADLE_USER_HOME -zipStorePath=wrapper/dists diff --git a/examples/grpc/gradlew.bat b/examples/grpc/gradlew.bat deleted file mode 100644 index 9109989e3c..0000000000 --- a/examples/grpc/gradlew.bat +++ /dev/null @@ -1,103 +0,0 @@ -@rem -@rem Copyright 2015 the original author or authors. -@rem -@rem Licensed under the Apache License, Version 2.0 (the "License"); -@rem you may not use this file except in compliance with the License. -@rem You may obtain a copy of the License at -@rem -@rem https://www.apache.org/licenses/LICENSE-2.0 -@rem -@rem Unless required by applicable law or agreed to in writing, software -@rem distributed under the License is distributed on an "AS IS" BASIS, -@rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -@rem See the License for the specific language governing permissions and -@rem limitations under the License. -@rem - -@if "%DEBUG%" == "" @echo off -@rem ########################################################################## -@rem -@rem Gradle startup script for Windows -@rem -@rem ########################################################################## - -@rem Set local scope for the variables with windows NT shell -if "%OS%"=="Windows_NT" setlocal - -set DIRNAME=%~dp0 -if "%DIRNAME%" == "" set DIRNAME=. -set APP_BASE_NAME=%~n0 -set APP_HOME=%DIRNAME% - -@rem Resolve any "." and ".." in APP_HOME to make it shorter. -for %%i in ("%APP_HOME%") do set APP_HOME=%%~fi - -@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. -set DEFAULT_JVM_OPTS="-Xmx64m" "-Xms64m" - -@rem Find java.exe -if defined JAVA_HOME goto findJavaFromJavaHome - -set JAVA_EXE=java.exe -%JAVA_EXE% -version >NUL 2>&1 -if "%ERRORLEVEL%" == "0" goto init - -echo. -echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. -echo. -echo Please set the JAVA_HOME variable in your environment to match the -echo location of your Java installation. - -goto fail - -:findJavaFromJavaHome -set JAVA_HOME=%JAVA_HOME:"=% -set JAVA_EXE=%JAVA_HOME%/bin/java.exe - -if exist "%JAVA_EXE%" goto init - -echo. -echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% -echo. -echo Please set the JAVA_HOME variable in your environment to match the -echo location of your Java installation. - -goto fail - -:init -@rem Get command-line arguments, handling Windows variants - -if not "%OS%" == "Windows_NT" goto win9xME_args - -:win9xME_args -@rem Slurp the command line arguments. -set CMD_LINE_ARGS= -set _SKIP=2 - -:win9xME_args_slurp -if "x%~1" == "x" goto execute - -set CMD_LINE_ARGS=%* - -:execute -@rem Setup the command line - -set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar - -@rem Execute Gradle -"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS% - -:end -@rem End local scope for the variables with windows NT shell -if "%ERRORLEVEL%"=="0" goto mainEnd - -:fail -rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of -rem the _cmd.exe /c_ return code! -if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1 -exit /b 1 - -:mainEnd -if "%OS%"=="Windows_NT" endlocal - -:omega diff --git a/examples/grpc/settings.gradle b/examples/grpc/settings.gradle deleted file mode 100644 index 59061d66c8..0000000000 --- a/examples/grpc/settings.gradle +++ /dev/null @@ -1,2 +0,0 @@ -rootProject.name = 'opentelemetry-example-grpc' - diff --git a/examples/grpc/src/main/java/io/opentelemetry/example/HelloWorldClient.java b/examples/grpc/src/main/java/io/opentelemetry/example/HelloWorldClient.java index 381a3b8807..cc46b0bd49 100644 --- a/examples/grpc/src/main/java/io/opentelemetry/example/HelloWorldClient.java +++ b/examples/grpc/src/main/java/io/opentelemetry/example/HelloWorldClient.java @@ -38,7 +38,6 @@ import io.opentelemetry.sdk.trace.export.SimpleSpansProcessor; import io.opentelemetry.trace.Span; import io.opentelemetry.trace.Status; import io.opentelemetry.trace.Tracer; - import java.util.concurrent.TimeUnit; import java.util.logging.Level; import java.util.logging.Logger; diff --git a/examples/grpc/src/main/java/io/opentelemetry/example/HelloWorldClientStream.java b/examples/grpc/src/main/java/io/opentelemetry/example/HelloWorldClientStream.java index 56a0f01c13..cf4985fa44 100644 --- a/examples/grpc/src/main/java/io/opentelemetry/example/HelloWorldClientStream.java +++ b/examples/grpc/src/main/java/io/opentelemetry/example/HelloWorldClientStream.java @@ -39,7 +39,6 @@ import io.opentelemetry.sdk.trace.export.SimpleSpansProcessor; import io.opentelemetry.trace.Span; import io.opentelemetry.trace.Status; import io.opentelemetry.trace.Tracer; - import java.util.Arrays; import java.util.List; import java.util.concurrent.TimeUnit; @@ -61,12 +60,13 @@ public class HelloWorldClientStream { // Share context via text headers HttpTextFormat textFormat = OpenTelemetry.getPropagators().getHttpTextFormat(); // Inject context into the gRPC request metadata - HttpTextFormat.Setter setter = new HttpTextFormat.Setter() { - @Override - public void set(Metadata carrier, String key, String value) { - carrier.put(Metadata.Key.of(key, Metadata.ASCII_STRING_MARSHALLER), value); - } - }; + HttpTextFormat.Setter setter = + new HttpTextFormat.Setter() { + @Override + public void set(Metadata carrier, String key, String value) { + carrier.put(Metadata.Key.of(key, Metadata.ASCII_STRING_MARSHALLER), value); + } + }; /** Construct client connecting to HelloWorld server at {@code host:port}. */ public HelloWorldClientStream(String host, int port) { @@ -102,7 +102,7 @@ public class HelloWorldClientStream { // Start a span Span span = - tracer.spanBuilder("helloworld.Greeter/SayHello").setSpanKind(Span.Kind.CLIENT).startSpan(); + tracer.spanBuilder("helloworld.Greeter/SayHello").setSpanKind(Span.Kind.CLIENT).startSpan(); span.setAttribute("component", "grpc"); span.setAttribute("rpc.service", "Greeter"); span.setAttribute("net.peer.ip", this.serverHostname); @@ -114,7 +114,7 @@ public class HelloWorldClientStream { try (Scope scope = tracer.withSpan(span)) { HelloReplyStreamObserver replyObserver = new HelloReplyStreamObserver(); requestObserver = asyncStub.sayHelloStream(replyObserver); - for(String name : names){ + for (String name : names) { try { requestObserver.onNext(HelloRequest.newBuilder().setName(name).build()); // Sleep for a bit before sending the next one. @@ -127,7 +127,7 @@ public class HelloWorldClientStream { requestObserver.onCompleted(); span.addEvent("Done sending"); span.setStatus(Status.OK); - } catch (StatusRuntimeException e){ + } catch (StatusRuntimeException e) { logger.log(Level.WARNING, "RPC failed: {0}", e.getStatus()); // TODO create mapping for io.grpc.Status<->io.opentelemetry.trace.Status span.setStatus(Status.UNKNOWN.withDescription("gRPC status: " + e.getStatus())); @@ -160,8 +160,8 @@ public class HelloWorldClientStream { @Override public void onCompleted() { - //Since onCompleted is async and the span.end() is called in the main thread, - //it is recommended to set the span Status in the main thread. + // Since onCompleted is async and the span.end() is called in the main thread, + // it is recommended to set the span Status in the main thread. } } diff --git a/examples/grpc/src/main/java/io/opentelemetry/example/HelloWorldServer.java b/examples/grpc/src/main/java/io/opentelemetry/example/HelloWorldServer.java index 348d9ad06d..55fc125018 100644 --- a/examples/grpc/src/main/java/io/opentelemetry/example/HelloWorldServer.java +++ b/examples/grpc/src/main/java/io/opentelemetry/example/HelloWorldServer.java @@ -37,7 +37,6 @@ import io.opentelemetry.sdk.trace.export.SimpleSpansProcessor; import io.opentelemetry.trace.Span; import io.opentelemetry.trace.Status; import io.opentelemetry.trace.Tracer; - import java.io.IOException; import java.net.InetSocketAddress; import java.util.logging.Logger; @@ -49,7 +48,8 @@ public class HelloWorldServer { private final int port = 50051; // OTel API - Tracer tracer = OpenTelemetry.getTracerProvider().get("io.opentelemetry.example.HelloWorldServer"); + Tracer tracer = + OpenTelemetry.getTracerProvider().get("io.opentelemetry.example.HelloWorldServer"); // Export traces as log LoggingSpanExporter exporter = new LoggingSpanExporter(); // Share context via text @@ -133,13 +133,13 @@ public class HelloWorldServer { // We serve a stream gRPC call @Override - public StreamObserver sayHelloStream(final StreamObserver responseObserver) { + public StreamObserver sayHelloStream( + final StreamObserver responseObserver) { return new StreamObserver() { @Override public void onNext(HelloRequest value) { responseObserver.onNext( - HelloReply.newBuilder().setMessage("Hello " + value.getName()).build() - ); + HelloReply.newBuilder().setMessage("Hello " + value.getName()).build()); } @Override @@ -161,16 +161,16 @@ public class HelloWorldServer { public ServerCall.Listener interceptCall( ServerCall call, Metadata headers, ServerCallHandler next) { // Extract the Span Context from the metadata of the gRPC request - Context extractedContext = textFormat.extract(Context.current(),headers, getter); + Context extractedContext = textFormat.extract(Context.current(), headers, getter); InetSocketAddress clientInfo = (InetSocketAddress) call.getAttributes().get(Grpc.TRANSPORT_ATTR_REMOTE_ADDR); // Build a span based on the received context try (Scope scope = ContextUtils.withScopedContext(extractedContext)) { Span span = - tracer - .spanBuilder("helloworld.Greeter/SayHello") - .setSpanKind(Span.Kind.SERVER) - .startSpan(); + tracer + .spanBuilder("helloworld.Greeter/SayHello") + .setSpanKind(Span.Kind.SERVER) + .startSpan(); span.setAttribute("component", "grpc"); span.setAttribute("rpc.service", "Greeter"); span.setAttribute("net.peer.ip", clientInfo.getHostString()); diff --git a/examples/http/README.md b/examples/http/README.md index 1b186a4b5b..21c3209c4a 100644 --- a/examples/http/README.md +++ b/examples/http/README.md @@ -15,16 +15,16 @@ and create a **Child Span** with attached a **Span Event**. * Be on the project root folder ## 1 - Compile -```bash -gradlew fatJar +```shell script +../gradlew fatJar ``` ## 2 - Start the Server -```bash -java -cp ./build/libs/opentelemetry-example-http-all-0.2.0.jar io.opentelemetry.example.http.HttpServer +```shell script +java -cp ./build/libs/opentelemetry-examples-http-all-0.1.0-SNAPSHOT.jar io.opentelemetry.example.http.HttpServer ``` ## 3 - Start the Client -```bash -java -cp ./build/libs/opentelemetry-example-http-all-0.2.0.jar io.opentelemetry.example.http.HttpClient +```shell script +java -cp ./build/libs/opentelemetry-examples-http-all-0.1.0-SNAPSHOT.jar io.opentelemetry.example.http.HttpClient ``` \ No newline at end of file diff --git a/examples/http/build.gradle b/examples/http/build.gradle index 16cb5e9084..9d4395af3b 100644 --- a/examples/http/build.gradle +++ b/examples/http/build.gradle @@ -2,27 +2,11 @@ plugins { id 'java' } -group 'io.opentelemetry' -version '0.1.0-SNAPSHOT' - -def opentelemetryVersion = '0.3.0' - -//create a single Jar with all dependencies -task fatJar(type: Jar) { - baseName = project.name + '-all' - from { configurations.compile.collect { it.isDirectory() ? it : zipTree(it) } } - with jar -} - -repositories { - mavenCentral() -} +description = 'OpenTelemetry Examples for HTTP' +ext.moduleName = "io.opentelemetry.examples.http" dependencies { compile("io.opentelemetry:opentelemetry-api:${opentelemetryVersion}") compile("io.opentelemetry:opentelemetry-sdk:${opentelemetryVersion}") compile("io.opentelemetry:opentelemetry-exporters-logging:${opentelemetryVersion}") - compile("io.grpc:grpc-protobuf:1.28.0") - compile("io.grpc:grpc-netty-shaded:1.28.0") - testCompile group: 'junit', name: 'junit', version: '4.12' } diff --git a/examples/http/gradle/wrapper/gradle-wrapper.jar b/examples/http/gradle/wrapper/gradle-wrapper.jar deleted file mode 100644 index 490fda8577..0000000000 Binary files a/examples/http/gradle/wrapper/gradle-wrapper.jar and /dev/null differ diff --git a/examples/http/gradlew b/examples/http/gradlew deleted file mode 100755 index 2fe81a7d95..0000000000 --- a/examples/http/gradlew +++ /dev/null @@ -1,183 +0,0 @@ -#!/usr/bin/env sh - -# -# Copyright 2015 the original author or authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# https://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# - -############################################################################## -## -## Gradle start up script for UN*X -## -############################################################################## - -# Attempt to set APP_HOME -# Resolve links: $0 may be a link -PRG="$0" -# Need this for relative symlinks. -while [ -h "$PRG" ] ; do - ls=`ls -ld "$PRG"` - link=`expr "$ls" : '.*-> \(.*\)$'` - if expr "$link" : '/.*' > /dev/null; then - PRG="$link" - else - PRG=`dirname "$PRG"`"/$link" - fi -done -SAVED="`pwd`" -cd "`dirname \"$PRG\"`/" >/dev/null -APP_HOME="`pwd -P`" -cd "$SAVED" >/dev/null - -APP_NAME="Gradle" -APP_BASE_NAME=`basename "$0"` - -# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. -DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"' - -# Use the maximum available, or set MAX_FD != -1 to use that value. -MAX_FD="maximum" - -warn () { - echo "$*" -} - -die () { - echo - echo "$*" - echo - exit 1 -} - -# OS specific support (must be 'true' or 'false'). -cygwin=false -msys=false -darwin=false -nonstop=false -case "`uname`" in - CYGWIN* ) - cygwin=true - ;; - Darwin* ) - darwin=true - ;; - MINGW* ) - msys=true - ;; - NONSTOP* ) - nonstop=true - ;; -esac - -CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar - -# Determine the Java command to use to start the JVM. -if [ -n "$JAVA_HOME" ] ; then - if [ -x "$JAVA_HOME/jre/sh/java" ] ; then - # IBM's JDK on AIX uses strange locations for the executables - JAVACMD="$JAVA_HOME/jre/sh/java" - else - JAVACMD="$JAVA_HOME/bin/java" - fi - if [ ! -x "$JAVACMD" ] ; then - die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME - -Please set the JAVA_HOME variable in your environment to match the -location of your Java installation." - fi -else - JAVACMD="java" - which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. - -Please set the JAVA_HOME variable in your environment to match the -location of your Java installation." -fi - -# Increase the maximum file descriptors if we can. -if [ "$cygwin" = "false" -a "$darwin" = "false" -a "$nonstop" = "false" ] ; then - MAX_FD_LIMIT=`ulimit -H -n` - if [ $? -eq 0 ] ; then - if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then - MAX_FD="$MAX_FD_LIMIT" - fi - ulimit -n $MAX_FD - if [ $? -ne 0 ] ; then - warn "Could not set maximum file descriptor limit: $MAX_FD" - fi - else - warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT" - fi -fi - -# For Darwin, add options to specify how the application appears in the dock -if $darwin; then - GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\"" -fi - -# For Cygwin or MSYS, switch paths to Windows format before running java -if [ "$cygwin" = "true" -o "$msys" = "true" ] ; then - APP_HOME=`cygpath --path --mixed "$APP_HOME"` - CLASSPATH=`cygpath --path --mixed "$CLASSPATH"` - JAVACMD=`cygpath --unix "$JAVACMD"` - - # We build the pattern for arguments to be converted via cygpath - ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null` - SEP="" - for dir in $ROOTDIRSRAW ; do - ROOTDIRS="$ROOTDIRS$SEP$dir" - SEP="|" - done - OURCYGPATTERN="(^($ROOTDIRS))" - # Add a user-defined pattern to the cygpath arguments - if [ "$GRADLE_CYGPATTERN" != "" ] ; then - OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)" - fi - # Now convert the arguments - kludge to limit ourselves to /bin/sh - i=0 - for arg in "$@" ; do - CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -` - CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option - - if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition - eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"` - else - eval `echo args$i`="\"$arg\"" - fi - i=`expr $i + 1` - done - case $i in - 0) set -- ;; - 1) set -- "$args0" ;; - 2) set -- "$args0" "$args1" ;; - 3) set -- "$args0" "$args1" "$args2" ;; - 4) set -- "$args0" "$args1" "$args2" "$args3" ;; - 5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;; - 6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;; - 7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;; - 8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;; - 9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;; - esac -fi - -# Escape application args -save () { - for i do printf %s\\n "$i" | sed "s/'/'\\\\''/g;1s/^/'/;\$s/\$/' \\\\/" ; done - echo " " -} -APP_ARGS=`save "$@"` - -# Collect all arguments for the java command, following the shell quoting and substitution rules -eval set -- $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS "\"-Dorg.gradle.appname=$APP_BASE_NAME\"" -classpath "\"$CLASSPATH\"" org.gradle.wrapper.GradleWrapperMain "$APP_ARGS" - -exec "$JAVACMD" "$@" diff --git a/examples/http/gradlew.bat b/examples/http/gradlew.bat deleted file mode 100644 index 9109989e3c..0000000000 --- a/examples/http/gradlew.bat +++ /dev/null @@ -1,103 +0,0 @@ -@rem -@rem Copyright 2015 the original author or authors. -@rem -@rem Licensed under the Apache License, Version 2.0 (the "License"); -@rem you may not use this file except in compliance with the License. -@rem You may obtain a copy of the License at -@rem -@rem https://www.apache.org/licenses/LICENSE-2.0 -@rem -@rem Unless required by applicable law or agreed to in writing, software -@rem distributed under the License is distributed on an "AS IS" BASIS, -@rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -@rem See the License for the specific language governing permissions and -@rem limitations under the License. -@rem - -@if "%DEBUG%" == "" @echo off -@rem ########################################################################## -@rem -@rem Gradle startup script for Windows -@rem -@rem ########################################################################## - -@rem Set local scope for the variables with windows NT shell -if "%OS%"=="Windows_NT" setlocal - -set DIRNAME=%~dp0 -if "%DIRNAME%" == "" set DIRNAME=. -set APP_BASE_NAME=%~n0 -set APP_HOME=%DIRNAME% - -@rem Resolve any "." and ".." in APP_HOME to make it shorter. -for %%i in ("%APP_HOME%") do set APP_HOME=%%~fi - -@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. -set DEFAULT_JVM_OPTS="-Xmx64m" "-Xms64m" - -@rem Find java.exe -if defined JAVA_HOME goto findJavaFromJavaHome - -set JAVA_EXE=java.exe -%JAVA_EXE% -version >NUL 2>&1 -if "%ERRORLEVEL%" == "0" goto init - -echo. -echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. -echo. -echo Please set the JAVA_HOME variable in your environment to match the -echo location of your Java installation. - -goto fail - -:findJavaFromJavaHome -set JAVA_HOME=%JAVA_HOME:"=% -set JAVA_EXE=%JAVA_HOME%/bin/java.exe - -if exist "%JAVA_EXE%" goto init - -echo. -echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% -echo. -echo Please set the JAVA_HOME variable in your environment to match the -echo location of your Java installation. - -goto fail - -:init -@rem Get command-line arguments, handling Windows variants - -if not "%OS%" == "Windows_NT" goto win9xME_args - -:win9xME_args -@rem Slurp the command line arguments. -set CMD_LINE_ARGS= -set _SKIP=2 - -:win9xME_args_slurp -if "x%~1" == "x" goto execute - -set CMD_LINE_ARGS=%* - -:execute -@rem Setup the command line - -set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar - -@rem Execute Gradle -"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS% - -:end -@rem End local scope for the variables with windows NT shell -if "%ERRORLEVEL%"=="0" goto mainEnd - -:fail -rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of -rem the _cmd.exe /c_ return code! -if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1 -exit /b 1 - -:mainEnd -if "%OS%"=="Windows_NT" endlocal - -:omega diff --git a/examples/http/settings.gradle b/examples/http/settings.gradle deleted file mode 100644 index 7a40291245..0000000000 --- a/examples/http/settings.gradle +++ /dev/null @@ -1,2 +0,0 @@ -rootProject.name = 'opentelemetry-example-http' - diff --git a/examples/http/src/main/java/io/opentelemetry/example/http/HttpClient.java b/examples/http/src/main/java/io/opentelemetry/example/http/HttpClient.java index 7d1127f98c..77d617db70 100644 --- a/examples/http/src/main/java/io/opentelemetry/example/http/HttpClient.java +++ b/examples/http/src/main/java/io/opentelemetry/example/http/HttpClient.java @@ -27,7 +27,6 @@ import io.opentelemetry.sdk.trace.export.SimpleSpansProcessor; import io.opentelemetry.trace.Span; import io.opentelemetry.trace.Status; import io.opentelemetry.trace.Tracer; - import java.io.BufferedReader; import java.io.InputStreamReader; import java.net.HttpURLConnection; @@ -94,7 +93,8 @@ public class HttpClient { con.setRequestMethod("GET"); status = con.getResponseCode(); BufferedReader in = - new BufferedReader(new InputStreamReader(con.getInputStream(), Charset.defaultCharset())); + new BufferedReader( + new InputStreamReader(con.getInputStream(), Charset.defaultCharset())); String inputLine; while ((inputLine = in.readLine()) != null) { content.append(inputLine); diff --git a/examples/http/src/main/java/io/opentelemetry/example/http/HttpServer.java b/examples/http/src/main/java/io/opentelemetry/example/http/HttpServer.java index 7a512b3baa..b89fc23fff 100644 --- a/examples/http/src/main/java/io/opentelemetry/example/http/HttpServer.java +++ b/examples/http/src/main/java/io/opentelemetry/example/http/HttpServer.java @@ -16,9 +16,9 @@ package io.opentelemetry.example.http; -import io.grpc.Context; import com.sun.net.httpserver.HttpExchange; import com.sun.net.httpserver.HttpHandler; +import io.grpc.Context; import io.opentelemetry.OpenTelemetry; import io.opentelemetry.common.AttributeValue; import io.opentelemetry.context.ContextUtils; @@ -29,7 +29,6 @@ import io.opentelemetry.sdk.OpenTelemetrySdk; import io.opentelemetry.sdk.trace.TracerSdkProvider; import io.opentelemetry.sdk.trace.export.SimpleSpansProcessor; import io.opentelemetry.trace.*; - import java.io.IOException; import java.io.OutputStream; import java.net.InetSocketAddress; @@ -49,7 +48,8 @@ public class HttpServer { Span span = null; // Extract the context from the HTTP request - Context ctx = OpenTelemetry.getPropagators().getHttpTextFormat().extract(Context.current(), he, getter); + Context ctx = + OpenTelemetry.getPropagators().getHttpTextFormat().extract(Context.current(), he, getter); try (Scope scope = ContextUtils.withScopedContext(ctx)) { // Build a span automatically using the received context span = spanBuilder.startSpan(); diff --git a/examples/jaeger/README.md b/examples/jaeger/README.md index d5ba8f9cfb..d6d187a725 100644 --- a/examples/jaeger/README.md +++ b/examples/jaeger/README.md @@ -12,12 +12,12 @@ to instrument a simple application using Jaeger as trace exporter. ## 1 - Compile -```bash -gradlew fatJar +```shell script +../gradlew fatJar ``` ## 2 - Run Jaeger -```bash +```shell script docker run --rm -it --name jaeger\ -p 16686:16686 \ -p 14250:14250 \ @@ -26,8 +26,8 @@ docker run --rm -it --name jaeger\ ## 3 - Start the Application -```bash -java -cp build/libs/opentelemetry-example-jaeger-all-0.2.0.jar io.opentelemetry.example.JaegerExample localhost 14250 +```shell script +java -cp build/libs/opentelemetry-examples-jaeger-all-0.1.0-SNAPSHOT.jar io.opentelemetry.example.JaegerExample localhost 14250 ``` ## 4 - Open the Jaeger UI diff --git a/examples/jaeger/build.gradle b/examples/jaeger/build.gradle index d233d727e1..8b8ef64737 100644 --- a/examples/jaeger/build.gradle +++ b/examples/jaeger/build.gradle @@ -2,21 +2,8 @@ plugins { id 'java' } -group 'io.opentelemetry' -version '0.1.0-SNAPSHOT' - -def opentelemetryVersion = '0.3.0' - -//create a single Jar with all dependencies -task fatJar(type: Jar) { - baseName = project.name + '-all' - from { configurations.compile.collect { it.isDirectory() ? it : zipTree(it) } } - with jar -} - -repositories { - mavenCentral() -} +description = 'OpenTelemetry Examples for Jaeger Exporter' +ext.moduleName = "io.opentelemetry.examples.jaeger" dependencies { compile("io.opentelemetry:opentelemetry-api:${opentelemetryVersion}") @@ -24,5 +11,4 @@ dependencies { compile("io.opentelemetry:opentelemetry-exporters-jaeger:${opentelemetryVersion}") compile("io.grpc:grpc-protobuf:1.28.0") compile("io.grpc:grpc-netty-shaded:1.28.0") - testCompile group: 'junit', name: 'junit', version: '4.12' } diff --git a/examples/jaeger/gradle/wrapper/gradle-wrapper.jar b/examples/jaeger/gradle/wrapper/gradle-wrapper.jar deleted file mode 100644 index 490fda8577..0000000000 Binary files a/examples/jaeger/gradle/wrapper/gradle-wrapper.jar and /dev/null differ diff --git a/examples/jaeger/gradle/wrapper/gradle-wrapper.properties b/examples/jaeger/gradle/wrapper/gradle-wrapper.properties deleted file mode 100644 index a4b4429748..0000000000 --- a/examples/jaeger/gradle/wrapper/gradle-wrapper.properties +++ /dev/null @@ -1,5 +0,0 @@ -distributionBase=GRADLE_USER_HOME -distributionPath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-6.3-bin.zip -zipStoreBase=GRADLE_USER_HOME -zipStorePath=wrapper/dists diff --git a/examples/jaeger/gradlew b/examples/jaeger/gradlew deleted file mode 100755 index 2fe81a7d95..0000000000 --- a/examples/jaeger/gradlew +++ /dev/null @@ -1,183 +0,0 @@ -#!/usr/bin/env sh - -# -# Copyright 2015 the original author or authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# https://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# - -############################################################################## -## -## Gradle start up script for UN*X -## -############################################################################## - -# Attempt to set APP_HOME -# Resolve links: $0 may be a link -PRG="$0" -# Need this for relative symlinks. -while [ -h "$PRG" ] ; do - ls=`ls -ld "$PRG"` - link=`expr "$ls" : '.*-> \(.*\)$'` - if expr "$link" : '/.*' > /dev/null; then - PRG="$link" - else - PRG=`dirname "$PRG"`"/$link" - fi -done -SAVED="`pwd`" -cd "`dirname \"$PRG\"`/" >/dev/null -APP_HOME="`pwd -P`" -cd "$SAVED" >/dev/null - -APP_NAME="Gradle" -APP_BASE_NAME=`basename "$0"` - -# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. -DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"' - -# Use the maximum available, or set MAX_FD != -1 to use that value. -MAX_FD="maximum" - -warn () { - echo "$*" -} - -die () { - echo - echo "$*" - echo - exit 1 -} - -# OS specific support (must be 'true' or 'false'). -cygwin=false -msys=false -darwin=false -nonstop=false -case "`uname`" in - CYGWIN* ) - cygwin=true - ;; - Darwin* ) - darwin=true - ;; - MINGW* ) - msys=true - ;; - NONSTOP* ) - nonstop=true - ;; -esac - -CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar - -# Determine the Java command to use to start the JVM. -if [ -n "$JAVA_HOME" ] ; then - if [ -x "$JAVA_HOME/jre/sh/java" ] ; then - # IBM's JDK on AIX uses strange locations for the executables - JAVACMD="$JAVA_HOME/jre/sh/java" - else - JAVACMD="$JAVA_HOME/bin/java" - fi - if [ ! -x "$JAVACMD" ] ; then - die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME - -Please set the JAVA_HOME variable in your environment to match the -location of your Java installation." - fi -else - JAVACMD="java" - which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. - -Please set the JAVA_HOME variable in your environment to match the -location of your Java installation." -fi - -# Increase the maximum file descriptors if we can. -if [ "$cygwin" = "false" -a "$darwin" = "false" -a "$nonstop" = "false" ] ; then - MAX_FD_LIMIT=`ulimit -H -n` - if [ $? -eq 0 ] ; then - if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then - MAX_FD="$MAX_FD_LIMIT" - fi - ulimit -n $MAX_FD - if [ $? -ne 0 ] ; then - warn "Could not set maximum file descriptor limit: $MAX_FD" - fi - else - warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT" - fi -fi - -# For Darwin, add options to specify how the application appears in the dock -if $darwin; then - GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\"" -fi - -# For Cygwin or MSYS, switch paths to Windows format before running java -if [ "$cygwin" = "true" -o "$msys" = "true" ] ; then - APP_HOME=`cygpath --path --mixed "$APP_HOME"` - CLASSPATH=`cygpath --path --mixed "$CLASSPATH"` - JAVACMD=`cygpath --unix "$JAVACMD"` - - # We build the pattern for arguments to be converted via cygpath - ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null` - SEP="" - for dir in $ROOTDIRSRAW ; do - ROOTDIRS="$ROOTDIRS$SEP$dir" - SEP="|" - done - OURCYGPATTERN="(^($ROOTDIRS))" - # Add a user-defined pattern to the cygpath arguments - if [ "$GRADLE_CYGPATTERN" != "" ] ; then - OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)" - fi - # Now convert the arguments - kludge to limit ourselves to /bin/sh - i=0 - for arg in "$@" ; do - CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -` - CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option - - if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition - eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"` - else - eval `echo args$i`="\"$arg\"" - fi - i=`expr $i + 1` - done - case $i in - 0) set -- ;; - 1) set -- "$args0" ;; - 2) set -- "$args0" "$args1" ;; - 3) set -- "$args0" "$args1" "$args2" ;; - 4) set -- "$args0" "$args1" "$args2" "$args3" ;; - 5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;; - 6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;; - 7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;; - 8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;; - 9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;; - esac -fi - -# Escape application args -save () { - for i do printf %s\\n "$i" | sed "s/'/'\\\\''/g;1s/^/'/;\$s/\$/' \\\\/" ; done - echo " " -} -APP_ARGS=`save "$@"` - -# Collect all arguments for the java command, following the shell quoting and substitution rules -eval set -- $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS "\"-Dorg.gradle.appname=$APP_BASE_NAME\"" -classpath "\"$CLASSPATH\"" org.gradle.wrapper.GradleWrapperMain "$APP_ARGS" - -exec "$JAVACMD" "$@" diff --git a/examples/jaeger/settings.gradle b/examples/jaeger/settings.gradle deleted file mode 100644 index d73879b31b..0000000000 --- a/examples/jaeger/settings.gradle +++ /dev/null @@ -1,2 +0,0 @@ -rootProject.name = 'opentelemetry-example-jaeger' - diff --git a/examples/jaeger/src/main/java/io/opentelemetry/example/JaegerExample.java b/examples/jaeger/src/main/java/io/opentelemetry/example/JaegerExample.java index c77993f6f6..5c4467256b 100644 --- a/examples/jaeger/src/main/java/io/opentelemetry/example/JaegerExample.java +++ b/examples/jaeger/src/main/java/io/opentelemetry/example/JaegerExample.java @@ -27,7 +27,8 @@ public class JaegerExample { private void setupJaegerExporter() { // Create a channel towards Jaeger end point - ManagedChannel jaegerChannel = ManagedChannelBuilder.forAddress(ip, port).usePlaintext().build(); + ManagedChannel jaegerChannel = + ManagedChannelBuilder.forAddress(ip, port).usePlaintext().build(); // Export traces to Jaeger this.jaegerExporter = JaegerGrpcSpanExporter.newBuilder() diff --git a/examples/sdk-usage/README.md b/examples/sdk-usage/README.md index dac37f17e8..5fc7252473 100644 --- a/examples/sdk-usage/README.md +++ b/examples/sdk-usage/README.md @@ -9,15 +9,15 @@ This is a simple example that demonstrates how to use and configure the OpenTele ## Compile Compile with ```shell script -./gradlew fatJar +../gradlew fatJar ``` ## Run The following commands are used to run the examples. ```shell script -java -cp build/libs/opentelemetry-example-sdk-usage-all-0.3.0-SNAPSHOT.jar io.opentelemetry.sdk.example.ConfigureTraceExample +java -cp build/libs/opentelemetry-examples-sdk-usage-all-0.1.0-SNAPSHOT.jar io.opentelemetry.sdk.example.ConfigureTraceExample ``` ```shell script -java -cp build/libs/opentelemetry-example-sdk-usage-all-0.3.0-SNAPSHOT.jar io.opentelemetry.sdk.example.ConfigureSpanProcessorExample +java -cp build/libs/opentelemetry-examples-sdk-usage-all-0.1.0-SNAPSHOT.jar io.opentelemetry.sdk.example.ConfigureSpanProcessorExample ``` \ No newline at end of file diff --git a/examples/sdk-usage/build.gradle b/examples/sdk-usage/build.gradle index 4e5df82463..f7fc0c97d6 100644 --- a/examples/sdk-usage/build.gradle +++ b/examples/sdk-usage/build.gradle @@ -1,38 +1,11 @@ plugins { id 'java' - id 'com.github.sherter.google-java-format' version '0.8' - id "com.jfrog.artifactory" version "4.14.1" } -group 'io.opentelemetry' -version '0.1.0-SNAPSHOT' - -def opentelemetryVersion = '0.3.0' - -//create a single Jar with all dependencies -task fatJar(type: Jar) { - baseName = project.name + '-all' - from { configurations.compile.collect { it.isDirectory() ? it : zipTree(it) } } - with jar -} - -googleJavaFormat { - toolVersion = '1.7' -} - -compileJava.dependsOn(verifyGoogleJavaFormat) - -repositories { - mavenCentral() - jcenter() - maven { - // Add snapshot repository - url "https://oss.jfrog.org/artifactory/oss-snapshot-local" - } -} +description = 'OpenTelemetry Examples for SDK Usage' +ext.moduleName = "io.opentelemetry.examples.sdk.usage" dependencies { compile "io.opentelemetry:opentelemetry-sdk:${opentelemetryVersion}" compile "io.opentelemetry:opentelemetry-exporters-logging:${opentelemetryVersion}" - testCompile group: 'junit', name: 'junit', version: '4.12' } diff --git a/examples/sdk-usage/gradle/wrapper/gradle-wrapper.jar b/examples/sdk-usage/gradle/wrapper/gradle-wrapper.jar deleted file mode 100644 index 490fda8577..0000000000 Binary files a/examples/sdk-usage/gradle/wrapper/gradle-wrapper.jar and /dev/null differ diff --git a/examples/sdk-usage/gradle/wrapper/gradle-wrapper.properties b/examples/sdk-usage/gradle/wrapper/gradle-wrapper.properties deleted file mode 100644 index a4b4429748..0000000000 --- a/examples/sdk-usage/gradle/wrapper/gradle-wrapper.properties +++ /dev/null @@ -1,5 +0,0 @@ -distributionBase=GRADLE_USER_HOME -distributionPath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-6.3-bin.zip -zipStoreBase=GRADLE_USER_HOME -zipStorePath=wrapper/dists diff --git a/examples/sdk-usage/gradlew b/examples/sdk-usage/gradlew deleted file mode 100755 index 2fe81a7d95..0000000000 --- a/examples/sdk-usage/gradlew +++ /dev/null @@ -1,183 +0,0 @@ -#!/usr/bin/env sh - -# -# Copyright 2015 the original author or authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# https://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# - -############################################################################## -## -## Gradle start up script for UN*X -## -############################################################################## - -# Attempt to set APP_HOME -# Resolve links: $0 may be a link -PRG="$0" -# Need this for relative symlinks. -while [ -h "$PRG" ] ; do - ls=`ls -ld "$PRG"` - link=`expr "$ls" : '.*-> \(.*\)$'` - if expr "$link" : '/.*' > /dev/null; then - PRG="$link" - else - PRG=`dirname "$PRG"`"/$link" - fi -done -SAVED="`pwd`" -cd "`dirname \"$PRG\"`/" >/dev/null -APP_HOME="`pwd -P`" -cd "$SAVED" >/dev/null - -APP_NAME="Gradle" -APP_BASE_NAME=`basename "$0"` - -# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. -DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"' - -# Use the maximum available, or set MAX_FD != -1 to use that value. -MAX_FD="maximum" - -warn () { - echo "$*" -} - -die () { - echo - echo "$*" - echo - exit 1 -} - -# OS specific support (must be 'true' or 'false'). -cygwin=false -msys=false -darwin=false -nonstop=false -case "`uname`" in - CYGWIN* ) - cygwin=true - ;; - Darwin* ) - darwin=true - ;; - MINGW* ) - msys=true - ;; - NONSTOP* ) - nonstop=true - ;; -esac - -CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar - -# Determine the Java command to use to start the JVM. -if [ -n "$JAVA_HOME" ] ; then - if [ -x "$JAVA_HOME/jre/sh/java" ] ; then - # IBM's JDK on AIX uses strange locations for the executables - JAVACMD="$JAVA_HOME/jre/sh/java" - else - JAVACMD="$JAVA_HOME/bin/java" - fi - if [ ! -x "$JAVACMD" ] ; then - die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME - -Please set the JAVA_HOME variable in your environment to match the -location of your Java installation." - fi -else - JAVACMD="java" - which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. - -Please set the JAVA_HOME variable in your environment to match the -location of your Java installation." -fi - -# Increase the maximum file descriptors if we can. -if [ "$cygwin" = "false" -a "$darwin" = "false" -a "$nonstop" = "false" ] ; then - MAX_FD_LIMIT=`ulimit -H -n` - if [ $? -eq 0 ] ; then - if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then - MAX_FD="$MAX_FD_LIMIT" - fi - ulimit -n $MAX_FD - if [ $? -ne 0 ] ; then - warn "Could not set maximum file descriptor limit: $MAX_FD" - fi - else - warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT" - fi -fi - -# For Darwin, add options to specify how the application appears in the dock -if $darwin; then - GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\"" -fi - -# For Cygwin or MSYS, switch paths to Windows format before running java -if [ "$cygwin" = "true" -o "$msys" = "true" ] ; then - APP_HOME=`cygpath --path --mixed "$APP_HOME"` - CLASSPATH=`cygpath --path --mixed "$CLASSPATH"` - JAVACMD=`cygpath --unix "$JAVACMD"` - - # We build the pattern for arguments to be converted via cygpath - ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null` - SEP="" - for dir in $ROOTDIRSRAW ; do - ROOTDIRS="$ROOTDIRS$SEP$dir" - SEP="|" - done - OURCYGPATTERN="(^($ROOTDIRS))" - # Add a user-defined pattern to the cygpath arguments - if [ "$GRADLE_CYGPATTERN" != "" ] ; then - OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)" - fi - # Now convert the arguments - kludge to limit ourselves to /bin/sh - i=0 - for arg in "$@" ; do - CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -` - CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option - - if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition - eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"` - else - eval `echo args$i`="\"$arg\"" - fi - i=`expr $i + 1` - done - case $i in - 0) set -- ;; - 1) set -- "$args0" ;; - 2) set -- "$args0" "$args1" ;; - 3) set -- "$args0" "$args1" "$args2" ;; - 4) set -- "$args0" "$args1" "$args2" "$args3" ;; - 5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;; - 6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;; - 7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;; - 8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;; - 9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;; - esac -fi - -# Escape application args -save () { - for i do printf %s\\n "$i" | sed "s/'/'\\\\''/g;1s/^/'/;\$s/\$/' \\\\/" ; done - echo " " -} -APP_ARGS=`save "$@"` - -# Collect all arguments for the java command, following the shell quoting and substitution rules -eval set -- $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS "\"-Dorg.gradle.appname=$APP_BASE_NAME\"" -classpath "\"$CLASSPATH\"" org.gradle.wrapper.GradleWrapperMain "$APP_ARGS" - -exec "$JAVACMD" "$@" diff --git a/examples/sdk-usage/gradlew.bat b/examples/sdk-usage/gradlew.bat deleted file mode 100644 index 9109989e3c..0000000000 --- a/examples/sdk-usage/gradlew.bat +++ /dev/null @@ -1,103 +0,0 @@ -@rem -@rem Copyright 2015 the original author or authors. -@rem -@rem Licensed under the Apache License, Version 2.0 (the "License"); -@rem you may not use this file except in compliance with the License. -@rem You may obtain a copy of the License at -@rem -@rem https://www.apache.org/licenses/LICENSE-2.0 -@rem -@rem Unless required by applicable law or agreed to in writing, software -@rem distributed under the License is distributed on an "AS IS" BASIS, -@rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -@rem See the License for the specific language governing permissions and -@rem limitations under the License. -@rem - -@if "%DEBUG%" == "" @echo off -@rem ########################################################################## -@rem -@rem Gradle startup script for Windows -@rem -@rem ########################################################################## - -@rem Set local scope for the variables with windows NT shell -if "%OS%"=="Windows_NT" setlocal - -set DIRNAME=%~dp0 -if "%DIRNAME%" == "" set DIRNAME=. -set APP_BASE_NAME=%~n0 -set APP_HOME=%DIRNAME% - -@rem Resolve any "." and ".." in APP_HOME to make it shorter. -for %%i in ("%APP_HOME%") do set APP_HOME=%%~fi - -@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. -set DEFAULT_JVM_OPTS="-Xmx64m" "-Xms64m" - -@rem Find java.exe -if defined JAVA_HOME goto findJavaFromJavaHome - -set JAVA_EXE=java.exe -%JAVA_EXE% -version >NUL 2>&1 -if "%ERRORLEVEL%" == "0" goto init - -echo. -echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. -echo. -echo Please set the JAVA_HOME variable in your environment to match the -echo location of your Java installation. - -goto fail - -:findJavaFromJavaHome -set JAVA_HOME=%JAVA_HOME:"=% -set JAVA_EXE=%JAVA_HOME%/bin/java.exe - -if exist "%JAVA_EXE%" goto init - -echo. -echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% -echo. -echo Please set the JAVA_HOME variable in your environment to match the -echo location of your Java installation. - -goto fail - -:init -@rem Get command-line arguments, handling Windows variants - -if not "%OS%" == "Windows_NT" goto win9xME_args - -:win9xME_args -@rem Slurp the command line arguments. -set CMD_LINE_ARGS= -set _SKIP=2 - -:win9xME_args_slurp -if "x%~1" == "x" goto execute - -set CMD_LINE_ARGS=%* - -:execute -@rem Setup the command line - -set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar - -@rem Execute Gradle -"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS% - -:end -@rem End local scope for the variables with windows NT shell -if "%ERRORLEVEL%"=="0" goto mainEnd - -:fail -rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of -rem the _cmd.exe /c_ return code! -if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1 -exit /b 1 - -:mainEnd -if "%OS%"=="Windows_NT" endlocal - -:omega diff --git a/examples/sdk-usage/settings.gradle b/examples/sdk-usage/settings.gradle deleted file mode 100644 index edabe7fc5f..0000000000 --- a/examples/sdk-usage/settings.gradle +++ /dev/null @@ -1,2 +0,0 @@ -rootProject.name = 'opentelemetry-example-sdk-usage' - diff --git a/examples/settings.gradle b/examples/settings.gradle new file mode 100644 index 0000000000..171b98744d --- /dev/null +++ b/examples/settings.gradle @@ -0,0 +1,23 @@ +pluginManagement { + plugins { + id 'com.github.sherter.google-java-format' version "0.8" + id "com.jfrog.artifactory" version "4.13.0" + id 'com.google.protobuf' version '0.8.8' + } + + repositories { + gradlePluginPortal() + google() + } +} + +rootProject.name = "opentelemetry-java-examples" +include ":opentelemetry-examples-grpc", + ":opentelemetry-examples-http", + ":opentelemetry-examples-jaeger", + ":opentelemetry-examples-sdk-usage" + +rootProject.children.each { + it.projectDir = "$rootDir/" + it.name + .replace("opentelemetry-examples-", "") as File +}