Examples share a common gradle build script (#1123)
* Examples in a single separate project. Bump version to 0.4.0-SNAPSHOT * Formatting * Gradle 6.3. Remove local wrappers
This commit is contained in:
		
							parent
							
								
									cfba55f713
								
							
						
					
					
						commit
						1396200627
					
				|  | @ -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 | ||||||
|  |     } | ||||||
|  | } | ||||||
										
											Binary file not shown.
										
									
								
							|  | @ -1,5 +1,5 @@ | ||||||
| distributionBase=GRADLE_USER_HOME | distributionBase=GRADLE_USER_HOME | ||||||
| distributionPath=wrapper/dists | 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 | zipStoreBase=GRADLE_USER_HOME | ||||||
| zipStorePath=wrapper/dists | zipStorePath=wrapper/dists | ||||||
|  | @ -29,9 +29,6 @@ if "%DIRNAME%" == "" set DIRNAME=. | ||||||
| set APP_BASE_NAME=%~n0 | set APP_BASE_NAME=%~n0 | ||||||
| set APP_HOME=%DIRNAME% | 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. | @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" | set DEFAULT_JVM_OPTS="-Xmx64m" "-Xms64m" | ||||||
| 
 | 
 | ||||||
|  | @ -14,21 +14,21 @@ and create a **Child Span**. | ||||||
| * Java 1.8 | * Java 1.8 | ||||||
| 
 | 
 | ||||||
| ## 1 - Compile  | ## 1 - Compile  | ||||||
| ```bash | ```shell script | ||||||
| gradlew fatJar | ../gradlew fatJar | ||||||
| ``` | ``` | ||||||
| 
 | 
 | ||||||
| ## 2 - Start the Server | ## 2 - Start the Server | ||||||
| ```bash | ```shell script | ||||||
| java -cp ./build/libs/opentelemetry-example-grpc-all-0.1.0-SNAPSHOT.jar io.opentelemetry.example.HelloWorldServer | java -cp ./build/libs/opentelemetry-examples-grpc-all-0.1.0-SNAPSHOT.jar io.opentelemetry.example.HelloWorldServer | ||||||
| ``` | ``` | ||||||
|   |   | ||||||
| ## 3 - Start the normal Client | ## 3 - Start the normal Client | ||||||
| ```bash | ```shell script | ||||||
| java -cp ./build/libs/opentelemetry-example-grpc-all-0.1.0-SNAPSHOT.jar io.opentelemetry.example.HelloWorldClient | java -cp ./build/libs/opentelemetry-examples-grpc-all-0.1.0-SNAPSHOT.jar io.opentelemetry.example.HelloWorldClient | ||||||
| ``` | ``` | ||||||
| 
 | 
 | ||||||
| ## 4 - Start the streamed Client | ## 4 - Start the streamed Client | ||||||
| ```bash | ```shell script | ||||||
| java -cp ./build/libs/opentelemetry-example-grpc-all-0.1.0-SNAPSHOT.jar io.opentelemetry.example.HelloWorldClientStream | java -cp ./build/libs/opentelemetry-examples-grpc-all-0.1.0-SNAPSHOT.jar io.opentelemetry.example.HelloWorldClientStream | ||||||
| ``` | ``` | ||||||
|  | @ -1,36 +1,19 @@ | ||||||
| plugins { | plugins { | ||||||
|     // ASSUMES GRADLE 2.12 OR HIGHER. Use plugin version 0.7.5 with earlier gradle versions |     id "com.google.protobuf" | ||||||
|     id 'com.google.protobuf' version '0.8.8' |  | ||||||
|     // Generate IntelliJ IDEA's .idea & .iml project files |  | ||||||
|     id 'java' |  | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| apply plugin: 'com.google.protobuf' | description = 'OpenTelemetry Examples for gRPC' | ||||||
| 
 | ext.moduleName = "io.opentelemetry.examples.grpc" | ||||||
| group 'io.opentelemetry' |  | ||||||
| version '0.1.0-SNAPSHOT' |  | ||||||
| 
 |  | ||||||
| def opentelemetryVersion = '0.3.0' |  | ||||||
| 
 | 
 | ||||||
| 
 | 
 | ||||||
| def grpcVersion = '1.24.0' // CURRENT_GRPC_VERSION |  | ||||||
| def protobufVersion = '3.10.0' |  | ||||||
| def protocVersion = protobufVersion |  | ||||||
| 
 |  | ||||||
| repositories { |  | ||||||
|     mavenCentral() |  | ||||||
| } |  | ||||||
| 
 | 
 | ||||||
| dependencies { | dependencies { | ||||||
|     compile "io.opentelemetry:opentelemetry-api:${opentelemetryVersion}" |     compile "io.opentelemetry:opentelemetry-api:${opentelemetryVersion}" | ||||||
|     compile "io.opentelemetry:opentelemetry-sdk:${opentelemetryVersion}" |     compile "io.opentelemetry:opentelemetry-sdk:${opentelemetryVersion}" | ||||||
|     compile "io.opentelemetry:opentelemetry-exporters-logging:${opentelemetryVersion}" |     compile "io.opentelemetry:opentelemetry-exporters-logging:${opentelemetryVersion}" | ||||||
| 
 |  | ||||||
|     compile "io.grpc:grpc-protobuf:${grpcVersion}" |     compile "io.grpc:grpc-protobuf:${grpcVersion}" | ||||||
|     compile "io.grpc:grpc-stub:${grpcVersion}" |     compile "io.grpc:grpc-stub:${grpcVersion}" | ||||||
|     compile "io.grpc:grpc-netty-shaded:${grpcVersion}" |     compile "io.grpc:grpc-netty-shaded:${grpcVersion}" | ||||||
| 
 |  | ||||||
|     testCompile group: 'junit', name: 'junit', version: '4.12' |  | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| protobuf { | 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 |  | ||||||
| } |  | ||||||
| 
 |  | ||||||
|  |  | ||||||
|  | @ -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 |  | ||||||
|  | @ -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 |  | ||||||
|  | @ -1,2 +0,0 @@ | ||||||
| rootProject.name = 'opentelemetry-example-grpc' |  | ||||||
| 
 |  | ||||||
|  | @ -38,7 +38,6 @@ import io.opentelemetry.sdk.trace.export.SimpleSpansProcessor; | ||||||
| import io.opentelemetry.trace.Span; | import io.opentelemetry.trace.Span; | ||||||
| import io.opentelemetry.trace.Status; | import io.opentelemetry.trace.Status; | ||||||
| import io.opentelemetry.trace.Tracer; | import io.opentelemetry.trace.Tracer; | ||||||
| 
 |  | ||||||
| import java.util.concurrent.TimeUnit; | import java.util.concurrent.TimeUnit; | ||||||
| import java.util.logging.Level; | import java.util.logging.Level; | ||||||
| import java.util.logging.Logger; | import java.util.logging.Logger; | ||||||
|  |  | ||||||
|  | @ -39,7 +39,6 @@ import io.opentelemetry.sdk.trace.export.SimpleSpansProcessor; | ||||||
| import io.opentelemetry.trace.Span; | import io.opentelemetry.trace.Span; | ||||||
| import io.opentelemetry.trace.Status; | import io.opentelemetry.trace.Status; | ||||||
| import io.opentelemetry.trace.Tracer; | import io.opentelemetry.trace.Tracer; | ||||||
| 
 |  | ||||||
| import java.util.Arrays; | import java.util.Arrays; | ||||||
| import java.util.List; | import java.util.List; | ||||||
| import java.util.concurrent.TimeUnit; | import java.util.concurrent.TimeUnit; | ||||||
|  | @ -61,7 +60,8 @@ public class HelloWorldClientStream { | ||||||
|   // Share context via text headers |   // Share context via text headers | ||||||
|   HttpTextFormat textFormat = OpenTelemetry.getPropagators().getHttpTextFormat(); |   HttpTextFormat textFormat = OpenTelemetry.getPropagators().getHttpTextFormat(); | ||||||
|   // Inject context into the gRPC request metadata |   // Inject context into the gRPC request metadata | ||||||
|   HttpTextFormat.Setter<Metadata> setter = new HttpTextFormat.Setter<Metadata>() { |   HttpTextFormat.Setter<Metadata> setter = | ||||||
|  |       new HttpTextFormat.Setter<Metadata>() { | ||||||
|         @Override |         @Override | ||||||
|         public void set(Metadata carrier, String key, String value) { |         public void set(Metadata carrier, String key, String value) { | ||||||
|           carrier.put(Metadata.Key.of(key, Metadata.ASCII_STRING_MARSHALLER), value); |           carrier.put(Metadata.Key.of(key, Metadata.ASCII_STRING_MARSHALLER), value); | ||||||
|  | @ -114,7 +114,7 @@ public class HelloWorldClientStream { | ||||||
|     try (Scope scope = tracer.withSpan(span)) { |     try (Scope scope = tracer.withSpan(span)) { | ||||||
|       HelloReplyStreamObserver replyObserver = new HelloReplyStreamObserver(); |       HelloReplyStreamObserver replyObserver = new HelloReplyStreamObserver(); | ||||||
|       requestObserver = asyncStub.sayHelloStream(replyObserver); |       requestObserver = asyncStub.sayHelloStream(replyObserver); | ||||||
|       for(String name : names){ |       for (String name : names) { | ||||||
|         try { |         try { | ||||||
|           requestObserver.onNext(HelloRequest.newBuilder().setName(name).build()); |           requestObserver.onNext(HelloRequest.newBuilder().setName(name).build()); | ||||||
|           // Sleep for a bit before sending the next one. |           // Sleep for a bit before sending the next one. | ||||||
|  | @ -127,7 +127,7 @@ public class HelloWorldClientStream { | ||||||
|       requestObserver.onCompleted(); |       requestObserver.onCompleted(); | ||||||
|       span.addEvent("Done sending"); |       span.addEvent("Done sending"); | ||||||
|       span.setStatus(Status.OK); |       span.setStatus(Status.OK); | ||||||
|     } catch (StatusRuntimeException e){ |     } catch (StatusRuntimeException e) { | ||||||
|       logger.log(Level.WARNING, "RPC failed: {0}", e.getStatus()); |       logger.log(Level.WARNING, "RPC failed: {0}", e.getStatus()); | ||||||
|       // TODO create mapping for io.grpc.Status<->io.opentelemetry.trace.Status |       // TODO create mapping for io.grpc.Status<->io.opentelemetry.trace.Status | ||||||
|       span.setStatus(Status.UNKNOWN.withDescription("gRPC status: " + e.getStatus())); |       span.setStatus(Status.UNKNOWN.withDescription("gRPC status: " + e.getStatus())); | ||||||
|  | @ -160,8 +160,8 @@ public class HelloWorldClientStream { | ||||||
| 
 | 
 | ||||||
|     @Override |     @Override | ||||||
|     public void onCompleted() { |     public void onCompleted() { | ||||||
|       //Since onCompleted is async and the span.end() is called 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. |       // it is recommended to set the span Status in the main thread. | ||||||
|     } |     } | ||||||
|   } |   } | ||||||
| 
 | 
 | ||||||
|  |  | ||||||
|  | @ -37,7 +37,6 @@ import io.opentelemetry.sdk.trace.export.SimpleSpansProcessor; | ||||||
| import io.opentelemetry.trace.Span; | import io.opentelemetry.trace.Span; | ||||||
| import io.opentelemetry.trace.Status; | import io.opentelemetry.trace.Status; | ||||||
| import io.opentelemetry.trace.Tracer; | import io.opentelemetry.trace.Tracer; | ||||||
| 
 |  | ||||||
| import java.io.IOException; | import java.io.IOException; | ||||||
| import java.net.InetSocketAddress; | import java.net.InetSocketAddress; | ||||||
| import java.util.logging.Logger; | import java.util.logging.Logger; | ||||||
|  | @ -49,7 +48,8 @@ public class HelloWorldServer { | ||||||
|   private final int port = 50051; |   private final int port = 50051; | ||||||
| 
 | 
 | ||||||
|   // OTel API |   // OTel API | ||||||
|   Tracer tracer = OpenTelemetry.getTracerProvider().get("io.opentelemetry.example.HelloWorldServer"); |   Tracer tracer = | ||||||
|  |       OpenTelemetry.getTracerProvider().get("io.opentelemetry.example.HelloWorldServer"); | ||||||
|   // Export traces as log |   // Export traces as log | ||||||
|   LoggingSpanExporter exporter = new LoggingSpanExporter(); |   LoggingSpanExporter exporter = new LoggingSpanExporter(); | ||||||
|   // Share context via text |   // Share context via text | ||||||
|  | @ -133,13 +133,13 @@ public class HelloWorldServer { | ||||||
| 
 | 
 | ||||||
|     // We serve a stream gRPC call |     // We serve a stream gRPC call | ||||||
|     @Override |     @Override | ||||||
|     public StreamObserver<HelloRequest> sayHelloStream(final StreamObserver<HelloReply> responseObserver) { |     public StreamObserver<HelloRequest> sayHelloStream( | ||||||
|  |         final StreamObserver<HelloReply> responseObserver) { | ||||||
|       return new StreamObserver<HelloRequest>() { |       return new StreamObserver<HelloRequest>() { | ||||||
|         @Override |         @Override | ||||||
|         public void onNext(HelloRequest value) { |         public void onNext(HelloRequest value) { | ||||||
|           responseObserver.onNext( |           responseObserver.onNext( | ||||||
|                   HelloReply.newBuilder().setMessage("Hello " + value.getName()).build() |               HelloReply.newBuilder().setMessage("Hello " + value.getName()).build()); | ||||||
|           ); |  | ||||||
|         } |         } | ||||||
| 
 | 
 | ||||||
|         @Override |         @Override | ||||||
|  | @ -161,7 +161,7 @@ public class HelloWorldServer { | ||||||
|     public <ReqT, RespT> ServerCall.Listener<ReqT> interceptCall( |     public <ReqT, RespT> ServerCall.Listener<ReqT> interceptCall( | ||||||
|         ServerCall<ReqT, RespT> call, Metadata headers, ServerCallHandler<ReqT, RespT> next) { |         ServerCall<ReqT, RespT> call, Metadata headers, ServerCallHandler<ReqT, RespT> next) { | ||||||
|       // Extract the Span Context from the metadata of the gRPC request |       // 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 clientInfo = | ||||||
|           (InetSocketAddress) call.getAttributes().get(Grpc.TRANSPORT_ATTR_REMOTE_ADDR); |           (InetSocketAddress) call.getAttributes().get(Grpc.TRANSPORT_ATTR_REMOTE_ADDR); | ||||||
|       // Build a span based on the received context |       // Build a span based on the received context | ||||||
|  |  | ||||||
|  | @ -15,16 +15,16 @@ and create a **Child Span** with attached a **Span Event**. | ||||||
| * Be on the project root folder | * Be on the project root folder | ||||||
| 
 | 
 | ||||||
| ## 1 - Compile  | ## 1 - Compile  | ||||||
| ```bash | ```shell script | ||||||
| gradlew fatJar | ../gradlew fatJar | ||||||
| ``` | ``` | ||||||
| 
 | 
 | ||||||
| ## 2 - Start the Server | ## 2 - Start the Server | ||||||
| ```bash | ```shell script | ||||||
| java -cp ./build/libs/opentelemetry-example-http-all-0.2.0.jar io.opentelemetry.example.http.HttpServer | java -cp ./build/libs/opentelemetry-examples-http-all-0.1.0-SNAPSHOT.jar io.opentelemetry.example.http.HttpServer | ||||||
| ``` | ``` | ||||||
|   |   | ||||||
| ## 3 - Start the Client | ## 3 - Start the Client | ||||||
| ```bash | ```shell script | ||||||
| java -cp ./build/libs/opentelemetry-example-http-all-0.2.0.jar io.opentelemetry.example.http.HttpClient | java -cp ./build/libs/opentelemetry-examples-http-all-0.1.0-SNAPSHOT.jar io.opentelemetry.example.http.HttpClient | ||||||
| ``` | ``` | ||||||
|  | @ -2,27 +2,11 @@ plugins { | ||||||
|     id 'java' |     id 'java' | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| group 'io.opentelemetry' | description = 'OpenTelemetry Examples for HTTP' | ||||||
| version '0.1.0-SNAPSHOT' | ext.moduleName = "io.opentelemetry.examples.http" | ||||||
| 
 |  | ||||||
| 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() |  | ||||||
| } |  | ||||||
| 
 | 
 | ||||||
| dependencies { | dependencies { | ||||||
|     compile("io.opentelemetry:opentelemetry-api:${opentelemetryVersion}") |     compile("io.opentelemetry:opentelemetry-api:${opentelemetryVersion}") | ||||||
|     compile("io.opentelemetry:opentelemetry-sdk:${opentelemetryVersion}") |     compile("io.opentelemetry:opentelemetry-sdk:${opentelemetryVersion}") | ||||||
|     compile("io.opentelemetry:opentelemetry-exporters-logging:${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' |  | ||||||
| } | } | ||||||
|  |  | ||||||
										
											Binary file not shown.
										
									
								
							|  | @ -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" "$@" |  | ||||||
|  | @ -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 |  | ||||||
|  | @ -1,2 +0,0 @@ | ||||||
| rootProject.name = 'opentelemetry-example-http' |  | ||||||
| 
 |  | ||||||
|  | @ -27,7 +27,6 @@ import io.opentelemetry.sdk.trace.export.SimpleSpansProcessor; | ||||||
| import io.opentelemetry.trace.Span; | import io.opentelemetry.trace.Span; | ||||||
| import io.opentelemetry.trace.Status; | import io.opentelemetry.trace.Status; | ||||||
| import io.opentelemetry.trace.Tracer; | import io.opentelemetry.trace.Tracer; | ||||||
| 
 |  | ||||||
| import java.io.BufferedReader; | import java.io.BufferedReader; | ||||||
| import java.io.InputStreamReader; | import java.io.InputStreamReader; | ||||||
| import java.net.HttpURLConnection; | import java.net.HttpURLConnection; | ||||||
|  | @ -94,7 +93,8 @@ public class HttpClient { | ||||||
|         con.setRequestMethod("GET"); |         con.setRequestMethod("GET"); | ||||||
|         status = con.getResponseCode(); |         status = con.getResponseCode(); | ||||||
|         BufferedReader in = |         BufferedReader in = | ||||||
|             new BufferedReader(new InputStreamReader(con.getInputStream(), Charset.defaultCharset())); |             new BufferedReader( | ||||||
|  |                 new InputStreamReader(con.getInputStream(), Charset.defaultCharset())); | ||||||
|         String inputLine; |         String inputLine; | ||||||
|         while ((inputLine = in.readLine()) != null) { |         while ((inputLine = in.readLine()) != null) { | ||||||
|           content.append(inputLine); |           content.append(inputLine); | ||||||
|  |  | ||||||
|  | @ -16,9 +16,9 @@ | ||||||
| 
 | 
 | ||||||
| package io.opentelemetry.example.http; | package io.opentelemetry.example.http; | ||||||
| 
 | 
 | ||||||
| import io.grpc.Context; |  | ||||||
| import com.sun.net.httpserver.HttpExchange; | import com.sun.net.httpserver.HttpExchange; | ||||||
| import com.sun.net.httpserver.HttpHandler; | import com.sun.net.httpserver.HttpHandler; | ||||||
|  | import io.grpc.Context; | ||||||
| import io.opentelemetry.OpenTelemetry; | import io.opentelemetry.OpenTelemetry; | ||||||
| import io.opentelemetry.common.AttributeValue; | import io.opentelemetry.common.AttributeValue; | ||||||
| import io.opentelemetry.context.ContextUtils; | 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.TracerSdkProvider; | ||||||
| import io.opentelemetry.sdk.trace.export.SimpleSpansProcessor; | import io.opentelemetry.sdk.trace.export.SimpleSpansProcessor; | ||||||
| import io.opentelemetry.trace.*; | import io.opentelemetry.trace.*; | ||||||
| 
 |  | ||||||
| import java.io.IOException; | import java.io.IOException; | ||||||
| import java.io.OutputStream; | import java.io.OutputStream; | ||||||
| import java.net.InetSocketAddress; | import java.net.InetSocketAddress; | ||||||
|  | @ -49,7 +48,8 @@ public class HttpServer { | ||||||
|       Span span = null; |       Span span = null; | ||||||
| 
 | 
 | ||||||
|       // Extract the context from the HTTP request |       // 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)) { |       try (Scope scope = ContextUtils.withScopedContext(ctx)) { | ||||||
|         // Build a span automatically using the received context |         // Build a span automatically using the received context | ||||||
|         span = spanBuilder.startSpan(); |         span = spanBuilder.startSpan(); | ||||||
|  |  | ||||||
|  | @ -12,12 +12,12 @@ to instrument a simple application using Jaeger as trace exporter. | ||||||
| 
 | 
 | ||||||
| 
 | 
 | ||||||
| ## 1 - Compile  | ## 1 - Compile  | ||||||
| ```bash | ```shell script | ||||||
| gradlew fatJar | ../gradlew fatJar | ||||||
| ``` | ``` | ||||||
| ## 2 - Run Jaeger | ## 2 - Run Jaeger | ||||||
| 
 | 
 | ||||||
| ```bash | ```shell script | ||||||
| docker run --rm -it --name jaeger\ | docker run --rm -it --name jaeger\ | ||||||
|   -p 16686:16686 \ |   -p 16686:16686 \ | ||||||
|   -p 14250:14250 \ |   -p 14250:14250 \ | ||||||
|  | @ -26,8 +26,8 @@ docker run --rm -it --name jaeger\ | ||||||
| 
 | 
 | ||||||
| 
 | 
 | ||||||
| ## 3 - Start the Application | ## 3 - Start the Application | ||||||
| ```bash | ```shell script | ||||||
| java -cp build/libs/opentelemetry-example-jaeger-all-0.2.0.jar io.opentelemetry.example.JaegerExample localhost 14250 | java -cp build/libs/opentelemetry-examples-jaeger-all-0.1.0-SNAPSHOT.jar io.opentelemetry.example.JaegerExample localhost 14250 | ||||||
| ``` | ``` | ||||||
| ## 4 - Open the Jaeger UI | ## 4 - Open the Jaeger UI | ||||||
| 
 | 
 | ||||||
|  |  | ||||||
|  | @ -2,21 +2,8 @@ plugins { | ||||||
|     id 'java' |     id 'java' | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| group 'io.opentelemetry' | description = 'OpenTelemetry Examples for Jaeger Exporter' | ||||||
| version '0.1.0-SNAPSHOT' | ext.moduleName = "io.opentelemetry.examples.jaeger" | ||||||
| 
 |  | ||||||
| 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() |  | ||||||
| } |  | ||||||
| 
 | 
 | ||||||
| dependencies { | dependencies { | ||||||
|     compile("io.opentelemetry:opentelemetry-api:${opentelemetryVersion}") |     compile("io.opentelemetry:opentelemetry-api:${opentelemetryVersion}") | ||||||
|  | @ -24,5 +11,4 @@ dependencies { | ||||||
|     compile("io.opentelemetry:opentelemetry-exporters-jaeger:${opentelemetryVersion}") |     compile("io.opentelemetry:opentelemetry-exporters-jaeger:${opentelemetryVersion}") | ||||||
|     compile("io.grpc:grpc-protobuf:1.28.0") |     compile("io.grpc:grpc-protobuf:1.28.0") | ||||||
|     compile("io.grpc:grpc-netty-shaded:1.28.0") |     compile("io.grpc:grpc-netty-shaded:1.28.0") | ||||||
|     testCompile group: 'junit', name: 'junit', version: '4.12' |  | ||||||
| } | } | ||||||
|  |  | ||||||
										
											Binary file not shown.
										
									
								
							|  | @ -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 |  | ||||||
|  | @ -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" "$@" |  | ||||||
|  | @ -1,2 +0,0 @@ | ||||||
| rootProject.name = 'opentelemetry-example-jaeger' |  | ||||||
| 
 |  | ||||||
|  | @ -27,7 +27,8 @@ public class JaegerExample { | ||||||
| 
 | 
 | ||||||
|   private void setupJaegerExporter() { |   private void setupJaegerExporter() { | ||||||
|     // Create a channel towards Jaeger end point |     // 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 |     // Export traces to Jaeger | ||||||
|     this.jaegerExporter = |     this.jaegerExporter = | ||||||
|         JaegerGrpcSpanExporter.newBuilder() |         JaegerGrpcSpanExporter.newBuilder() | ||||||
|  |  | ||||||
|  | @ -9,15 +9,15 @@ This is a simple example that demonstrates how to use and configure the OpenTele | ||||||
| ## Compile | ## Compile | ||||||
| Compile with  | Compile with  | ||||||
| ```shell script | ```shell script | ||||||
| ./gradlew fatJar | ../gradlew fatJar | ||||||
| ``` | ``` | ||||||
| 
 | 
 | ||||||
| ## Run | ## Run | ||||||
| 
 | 
 | ||||||
| The following commands are used to run the examples. | The following commands are used to run the examples. | ||||||
| ```shell script | ```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 | ```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 | ||||||
| ``` | ``` | ||||||
|  | @ -1,38 +1,11 @@ | ||||||
| plugins { | plugins { | ||||||
|     id 'java' |     id 'java' | ||||||
|     id 'com.github.sherter.google-java-format' version '0.8' |  | ||||||
|     id "com.jfrog.artifactory" version "4.14.1" |  | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| group 'io.opentelemetry' | description = 'OpenTelemetry Examples for SDK Usage' | ||||||
| version '0.1.0-SNAPSHOT' | ext.moduleName = "io.opentelemetry.examples.sdk.usage" | ||||||
| 
 |  | ||||||
| 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" |  | ||||||
|     } |  | ||||||
| } |  | ||||||
| 
 | 
 | ||||||
| dependencies { | dependencies { | ||||||
|     compile "io.opentelemetry:opentelemetry-sdk:${opentelemetryVersion}" |     compile "io.opentelemetry:opentelemetry-sdk:${opentelemetryVersion}" | ||||||
|     compile "io.opentelemetry:opentelemetry-exporters-logging:${opentelemetryVersion}" |     compile "io.opentelemetry:opentelemetry-exporters-logging:${opentelemetryVersion}" | ||||||
|     testCompile group: 'junit', name: 'junit', version: '4.12' |  | ||||||
| } | } | ||||||
|  |  | ||||||
										
											Binary file not shown.
										
									
								
							|  | @ -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 |  | ||||||
|  | @ -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" "$@" |  | ||||||
|  | @ -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 |  | ||||||
|  | @ -1,2 +0,0 @@ | ||||||
| rootProject.name = 'opentelemetry-example-sdk-usage' |  | ||||||
| 
 |  | ||||||
|  | @ -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 | ||||||
|  | } | ||||||
		Loading…
	
		Reference in New Issue