-
Notifications
You must be signed in to change notification settings - Fork 73
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
3b12a19
commit c1d45e1
Showing
19 changed files
with
333 additions
and
12 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,25 @@ | ||
# Dependencies | ||
|
||
```bash | ||
go get \ | ||
github.com/gorilla/mux v1.8.1 \ | ||
go.opentelemetry.io/contrib/instrumentation/github.com/gorilla/mux/otelmux v0.56.0 \ | ||
go.opentelemetry.io/otel v1.31.0 \ | ||
go.opentelemetry.io/otel/exporters/otlp/otlptrace v1.31.0 \ | ||
go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracehttp v1.31.0 \ | ||
go.opentelemetry.io/otel/sdk v1.31.0 \ | ||
go.opentelemetry.io/otel/trace v1.31.0 | ||
``` | ||
# Step-by-step | ||
|
||
1. Install Dependencies | ||
|
||
```bash | ||
go get \ | ||
github.com/gorilla/mux v1.8.1 \ | ||
go.opentelemetry.io/contrib/instrumentation/github.com/gorilla/mux/otelmux v0.56.0 \ | ||
go.opentelemetry.io/otel v1.31.0 \ | ||
go.opentelemetry.io/otel/exporters/otlp/otlptrace v1.31.0 \ | ||
go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracehttp v1.31.0 \ | ||
go.opentelemetry.io/otel/sdk v1.31.0 \ | ||
go.opentelemetry.io/otel/trace v1.31.0 | ||
``` | ||
|
||
2. Start the App | ||
|
||
```bash | ||
export OTEL_SERVICE_NAME=my-service-name | ||
export OTEL_EXPORTER_OTLP_PROTOCOL=http/protobuf | ||
export OTEL_EXPORTER_OTLP_ENDPOINT="http://localhost:4318" | ||
export OTEL_EXPORTER_OTLP_HEADERS="x-tracetest-token=bla" | ||
go run . | ||
``` |
38 changes: 38 additions & 0 deletions
38
examples/getting-started/java/hello-world-api/dependency-reduced-pom.xml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd"> | ||
<modelVersion>4.0.0</modelVersion> | ||
<groupId>com.example</groupId> | ||
<artifactId>hello-world-api</artifactId> | ||
<version>1.0-SNAPSHOT</version> | ||
<build> | ||
<plugins> | ||
<plugin> | ||
<artifactId>maven-shade-plugin</artifactId> | ||
<version>3.2.4</version> | ||
<executions> | ||
<execution> | ||
<phase>package</phase> | ||
<goals> | ||
<goal>shade</goal> | ||
</goals> | ||
<configuration> | ||
<transformers> | ||
<transformer> | ||
<mainClass>com.example.HelloWorldApi</mainClass> | ||
</transformer> | ||
</transformers> | ||
</configuration> | ||
</execution> | ||
</executions> | ||
</plugin> | ||
</plugins> | ||
</build> | ||
<dependencies> | ||
<dependency> | ||
<groupId>junit</groupId> | ||
<artifactId>junit</artifactId> | ||
<version>3.8.1</version> | ||
<scope>test</scope> | ||
</dependency> | ||
</dependencies> | ||
</project> |
Binary file added
BIN
+20.6 MB
examples/getting-started/java/hello-world-api/opentelemetry-javaagent.jar
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
<project xmlns="http://maven.apache.org/POM/4.0.0" | ||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | ||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> | ||
<modelVersion>4.0.0</modelVersion> | ||
|
||
<groupId>com.example</groupId> | ||
<artifactId>hello-world-api</artifactId> | ||
<version>1.0-SNAPSHOT</version> | ||
|
||
<dependencies> | ||
<dependency> | ||
<groupId>junit</groupId> | ||
<artifactId>junit</artifactId> | ||
<version>3.8.1</version> | ||
<scope>test</scope> | ||
</dependency> | ||
<!-- Spark dependency --> | ||
<dependency> | ||
<groupId>com.sparkjava</groupId> | ||
<artifactId>spark-core</artifactId> | ||
<version>2.9.4</version> | ||
</dependency> | ||
</dependencies> | ||
|
||
<build> | ||
<plugins> | ||
<!-- Maven Shade Plugin to create a "fat JAR" --> | ||
<plugin> | ||
<groupId>org.apache.maven.plugins</groupId> | ||
<artifactId>maven-shade-plugin</artifactId> | ||
<version>3.2.4</version> | ||
<executions> | ||
<execution> | ||
<phase>package</phase> | ||
<goals> | ||
<goal>shade</goal> | ||
</goals> | ||
<configuration> | ||
<transformers> | ||
<transformer implementation="org.apache.maven.plugins.shade.resource.ManifestResourceTransformer"> | ||
<mainClass>com.example.HelloWorldApi</mainClass> | ||
</transformer> | ||
</transformers> | ||
</configuration> | ||
</execution> | ||
</executions> | ||
</plugin> | ||
</plugins> | ||
</build> | ||
</project> |
13 changes: 13 additions & 0 deletions
13
examples/getting-started/java/hello-world-api/src/main/java/com/example/HelloWorldApi.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
package com.example; | ||
|
||
import static spark.Spark.*; | ||
|
||
public class HelloWorldApi { | ||
public static void main(String[] args) { | ||
// Start a basic HTTP server on port 4567 | ||
port(4567); | ||
|
||
// Define a simple route that returns "Hello, World!" | ||
get("/hello", (req, res) -> "Hello, World!"); | ||
} | ||
} |
38 changes: 38 additions & 0 deletions
38
examples/getting-started/java/hello-world-api/src/test/java/com/example/AppTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
package com.example; | ||
|
||
import junit.framework.Test; | ||
import junit.framework.TestCase; | ||
import junit.framework.TestSuite; | ||
|
||
/** | ||
* Unit test for simple App. | ||
*/ | ||
public class AppTest | ||
extends TestCase | ||
{ | ||
/** | ||
* Create the test case | ||
* | ||
* @param testName name of the test case | ||
*/ | ||
public AppTest( String testName ) | ||
{ | ||
super( testName ); | ||
} | ||
|
||
/** | ||
* @return the suite of tests being tested | ||
*/ | ||
public static Test suite() | ||
{ | ||
return new TestSuite( AppTest.class ); | ||
} | ||
|
||
/** | ||
* Rigourous Test :-) | ||
*/ | ||
public void testApp() | ||
{ | ||
assertTrue( true ); | ||
} | ||
} |
Binary file added
BIN
+1.25 KB
examples/getting-started/java/hello-world-api/target/classes/com/example/HelloWorldApi.class
Binary file not shown.
Binary file added
BIN
+3 MB
examples/getting-started/java/hello-world-api/target/hello-world-api-1.0-SNAPSHOT.jar
Binary file not shown.
3 changes: 3 additions & 0 deletions
3
examples/getting-started/java/hello-world-api/target/maven-archiver/pom.properties
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
artifactId=hello-world-api | ||
groupId=com.example | ||
version=1.0-SNAPSHOT |
1 change: 1 addition & 0 deletions
1
...ld-api/target/maven-status/maven-compiler-plugin/compile/default-compile/createdFiles.lst
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
com/example/HelloWorldApi.class |
1 change: 1 addition & 0 deletions
1
...orld-api/target/maven-status/maven-compiler-plugin/compile/default-compile/inputFiles.lst
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
/Users/adnanrahic/Code/kubeshop/tracetest/examples/getting-started/java/hello-world-api/src/main/java/com/example/HelloWorldApi.java |
1 change: 1 addition & 0 deletions
1
...arget/maven-status/maven-compiler-plugin/testCompile/default-testCompile/createdFiles.lst
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
com/example/AppTest.class |
1 change: 1 addition & 0 deletions
1
.../target/maven-status/maven-compiler-plugin/testCompile/default-testCompile/inputFiles.lst
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
/Users/adnanrahic/Code/kubeshop/tracetest/examples/getting-started/java/hello-world-api/src/test/java/com/example/AppTest.java |
Binary file added
BIN
+2.63 KB
...les/getting-started/java/hello-world-api/target/original-hello-world-api-1.0-SNAPSHOT.jar
Binary file not shown.
61 changes: 61 additions & 0 deletions
61
...getting-started/java/hello-world-api/target/surefire-reports/TEST-com.example.AppTest.xml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<testsuite xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="https://maven.apache.org/surefire/maven-surefire-plugin/xsd/surefire-test-report-3.0.xsd" version="3.0" name="com.example.AppTest" time="0.02" tests="1" errors="0" skipped="0" failures="0"> | ||
<properties> | ||
<property name="java.specification.version" value="23"/> | ||
<property name="sun.jnu.encoding" value="UTF-8"/> | ||
<property name="java.class.path" value="/Users/adnanrahic/Code/kubeshop/tracetest/examples/getting-started/java/hello-world-api/target/test-classes:/Users/adnanrahic/Code/kubeshop/tracetest/examples/getting-started/java/hello-world-api/target/classes:/Users/adnanrahic/.m2/repository/junit/junit/3.8.1/junit-3.8.1.jar:/Users/adnanrahic/.m2/repository/com/sparkjava/spark-core/2.9.4/spark-core-2.9.4.jar:/Users/adnanrahic/.m2/repository/org/slf4j/slf4j-api/1.7.25/slf4j-api-1.7.25.jar:/Users/adnanrahic/.m2/repository/org/eclipse/jetty/jetty-server/9.4.48.v20220622/jetty-server-9.4.48.v20220622.jar:/Users/adnanrahic/.m2/repository/javax/servlet/javax.servlet-api/3.1.0/javax.servlet-api-3.1.0.jar:/Users/adnanrahic/.m2/repository/org/eclipse/jetty/jetty-http/9.4.48.v20220622/jetty-http-9.4.48.v20220622.jar:/Users/adnanrahic/.m2/repository/org/eclipse/jetty/jetty-util/9.4.48.v20220622/jetty-util-9.4.48.v20220622.jar:/Users/adnanrahic/.m2/repository/org/eclipse/jetty/jetty-io/9.4.48.v20220622/jetty-io-9.4.48.v20220622.jar:/Users/adnanrahic/.m2/repository/org/eclipse/jetty/jetty-webapp/9.4.48.v20220622/jetty-webapp-9.4.48.v20220622.jar:/Users/adnanrahic/.m2/repository/org/eclipse/jetty/jetty-xml/9.4.48.v20220622/jetty-xml-9.4.48.v20220622.jar:/Users/adnanrahic/.m2/repository/org/eclipse/jetty/jetty-servlet/9.4.48.v20220622/jetty-servlet-9.4.48.v20220622.jar:/Users/adnanrahic/.m2/repository/org/eclipse/jetty/jetty-security/9.4.48.v20220622/jetty-security-9.4.48.v20220622.jar:/Users/adnanrahic/.m2/repository/org/eclipse/jetty/jetty-util-ajax/9.4.48.v20220622/jetty-util-ajax-9.4.48.v20220622.jar:/Users/adnanrahic/.m2/repository/org/eclipse/jetty/websocket/websocket-server/9.4.48.v20220622/websocket-server-9.4.48.v20220622.jar:/Users/adnanrahic/.m2/repository/org/eclipse/jetty/websocket/websocket-common/9.4.48.v20220622/websocket-common-9.4.48.v20220622.jar:/Users/adnanrahic/.m2/repository/org/eclipse/jetty/websocket/websocket-client/9.4.48.v20220622/websocket-client-9.4.48.v20220622.jar:/Users/adnanrahic/.m2/repository/org/eclipse/jetty/jetty-client/9.4.48.v20220622/jetty-client-9.4.48.v20220622.jar:/Users/adnanrahic/.m2/repository/org/eclipse/jetty/websocket/websocket-servlet/9.4.48.v20220622/websocket-servlet-9.4.48.v20220622.jar:/Users/adnanrahic/.m2/repository/org/eclipse/jetty/websocket/websocket-api/9.4.48.v20220622/websocket-api-9.4.48.v20220622.jar:"/> | ||
<property name="java.vm.vendor" value="Oracle Corporation"/> | ||
<property name="sun.arch.data.model" value="64"/> | ||
<property name="java.vendor.url" value="https://java.oracle.com/"/> | ||
<property name="os.name" value="Mac OS X"/> | ||
<property name="java.vm.specification.version" value="23"/> | ||
<property name="sun.java.launcher" value="SUN_STANDARD"/> | ||
<property name="user.country" value="US"/> | ||
<property name="sun.boot.library.path" value="/Library/Java/JavaVirtualMachines/jdk-23.jdk/Contents/Home/lib"/> | ||
<property name="sun.java.command" value="/Users/adnanrahic/Code/kubeshop/tracetest/examples/getting-started/java/hello-world-api/target/surefire/surefirebooter-20241015104917420_3.jar /Users/adnanrahic/Code/kubeshop/tracetest/examples/getting-started/java/hello-world-api/target/surefire 2024-10-15T10-49-17_377-jvmRun1 surefire-20241015104917420_1tmp surefire_0-20241015104917420_2tmp"/> | ||
<property name="http.nonProxyHosts" value="local|*.local|169.254/16|*.169.254/16"/> | ||
<property name="jdk.debug" value="release"/> | ||
<property name="surefire.test.class.path" value="/Users/adnanrahic/Code/kubeshop/tracetest/examples/getting-started/java/hello-world-api/target/test-classes:/Users/adnanrahic/Code/kubeshop/tracetest/examples/getting-started/java/hello-world-api/target/classes:/Users/adnanrahic/.m2/repository/junit/junit/3.8.1/junit-3.8.1.jar:/Users/adnanrahic/.m2/repository/com/sparkjava/spark-core/2.9.4/spark-core-2.9.4.jar:/Users/adnanrahic/.m2/repository/org/slf4j/slf4j-api/1.7.25/slf4j-api-1.7.25.jar:/Users/adnanrahic/.m2/repository/org/eclipse/jetty/jetty-server/9.4.48.v20220622/jetty-server-9.4.48.v20220622.jar:/Users/adnanrahic/.m2/repository/javax/servlet/javax.servlet-api/3.1.0/javax.servlet-api-3.1.0.jar:/Users/adnanrahic/.m2/repository/org/eclipse/jetty/jetty-http/9.4.48.v20220622/jetty-http-9.4.48.v20220622.jar:/Users/adnanrahic/.m2/repository/org/eclipse/jetty/jetty-util/9.4.48.v20220622/jetty-util-9.4.48.v20220622.jar:/Users/adnanrahic/.m2/repository/org/eclipse/jetty/jetty-io/9.4.48.v20220622/jetty-io-9.4.48.v20220622.jar:/Users/adnanrahic/.m2/repository/org/eclipse/jetty/jetty-webapp/9.4.48.v20220622/jetty-webapp-9.4.48.v20220622.jar:/Users/adnanrahic/.m2/repository/org/eclipse/jetty/jetty-xml/9.4.48.v20220622/jetty-xml-9.4.48.v20220622.jar:/Users/adnanrahic/.m2/repository/org/eclipse/jetty/jetty-servlet/9.4.48.v20220622/jetty-servlet-9.4.48.v20220622.jar:/Users/adnanrahic/.m2/repository/org/eclipse/jetty/jetty-security/9.4.48.v20220622/jetty-security-9.4.48.v20220622.jar:/Users/adnanrahic/.m2/repository/org/eclipse/jetty/jetty-util-ajax/9.4.48.v20220622/jetty-util-ajax-9.4.48.v20220622.jar:/Users/adnanrahic/.m2/repository/org/eclipse/jetty/websocket/websocket-server/9.4.48.v20220622/websocket-server-9.4.48.v20220622.jar:/Users/adnanrahic/.m2/repository/org/eclipse/jetty/websocket/websocket-common/9.4.48.v20220622/websocket-common-9.4.48.v20220622.jar:/Users/adnanrahic/.m2/repository/org/eclipse/jetty/websocket/websocket-client/9.4.48.v20220622/websocket-client-9.4.48.v20220622.jar:/Users/adnanrahic/.m2/repository/org/eclipse/jetty/jetty-client/9.4.48.v20220622/jetty-client-9.4.48.v20220622.jar:/Users/adnanrahic/.m2/repository/org/eclipse/jetty/websocket/websocket-servlet/9.4.48.v20220622/websocket-servlet-9.4.48.v20220622.jar:/Users/adnanrahic/.m2/repository/org/eclipse/jetty/websocket/websocket-api/9.4.48.v20220622/websocket-api-9.4.48.v20220622.jar:"/> | ||
<property name="sun.cpu.endian" value="little"/> | ||
<property name="user.home" value="/Users/adnanrahic"/> | ||
<property name="user.language" value="en"/> | ||
<property name="java.specification.vendor" value="Oracle Corporation"/> | ||
<property name="java.version.date" value="2024-09-17"/> | ||
<property name="java.home" value="/Library/Java/JavaVirtualMachines/jdk-23.jdk/Contents/Home"/> | ||
<property name="file.separator" value="/"/> | ||
<property name="basedir" value="/Users/adnanrahic/Code/kubeshop/tracetest/examples/getting-started/java/hello-world-api"/> | ||
<property name="java.vm.compressedOopsMode" value="Zero based"/> | ||
<property name="line.separator" value=" "/> | ||
<property name="java.vm.specification.vendor" value="Oracle Corporation"/> | ||
<property name="java.specification.name" value="Java Platform API Specification"/> | ||
<property name="apple.awt.application.name" value="ForkedBooter"/> | ||
<property name="surefire.real.class.path" value="/Users/adnanrahic/Code/kubeshop/tracetest/examples/getting-started/java/hello-world-api/target/surefire/surefirebooter-20241015104917420_3.jar"/> | ||
<property name="sun.management.compiler" value="HotSpot 64-Bit Tiered Compilers"/> | ||
<property name="ftp.nonProxyHosts" value="local|*.local|169.254/16|*.169.254/16"/> | ||
<property name="java.runtime.version" value="23+37-2369"/> | ||
<property name="user.name" value="adnanrahic"/> | ||
<property name="stdout.encoding" value="UTF-8"/> | ||
<property name="path.separator" value=":"/> | ||
<property name="os.version" value="14.6.1"/> | ||
<property name="java.runtime.name" value="Java(TM) SE Runtime Environment"/> | ||
<property name="file.encoding" value="UTF-8"/> | ||
<property name="java.vm.name" value="Java HotSpot(TM) 64-Bit Server VM"/> | ||
<property name="localRepository" value="/Users/adnanrahic/.m2/repository"/> | ||
<property name="java.vendor.url.bug" value="https://bugreport.java.com/bugreport/"/> | ||
<property name="java.io.tmpdir" value="/var/folders/dl/rd5s6nq573lcblb_dgfb5y0h0000gn/T/"/> | ||
<property name="java.version" value="23"/> | ||
<property name="user.dir" value="/Users/adnanrahic/Code/kubeshop/tracetest/examples/getting-started/java/hello-world-api"/> | ||
<property name="os.arch" value="aarch64"/> | ||
<property name="java.vm.specification.name" value="Java Virtual Machine Specification"/> | ||
<property name="native.encoding" value="UTF-8"/> | ||
<property name="java.library.path" value="/Users/adnanrahic/Library/Java/Extensions:/Library/Java/Extensions:/Network/Library/Java/Extensions:/System/Library/Java/Extensions:/usr/lib/java:."/> | ||
<property name="java.vm.info" value="mixed mode, sharing"/> | ||
<property name="stderr.encoding" value="UTF-8"/> | ||
<property name="java.vendor" value="Oracle Corporation"/> | ||
<property name="java.vm.version" value="23+37-2369"/> | ||
<property name="sun.io.unicode.encoding" value="UnicodeBig"/> | ||
<property name="socksNonProxyHosts" value="local|*.local|169.254/16|*.169.254/16"/> | ||
<property name="java.class.version" value="67.0"/> | ||
</properties> | ||
<testcase name="testApp" classname="com.example.AppTest" time="0.001"/> | ||
</testsuite> |
4 changes: 4 additions & 0 deletions
4
...ples/getting-started/java/hello-world-api/target/surefire-reports/com.example.AppTest.txt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
------------------------------------------------------------------------------- | ||
Test set: com.example.AppTest | ||
------------------------------------------------------------------------------- | ||
Tests run: 1, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0.020 s -- in com.example.AppTest |
Binary file added
BIN
+601 Bytes
examples/getting-started/java/hello-world-api/target/test-classes/com/example/AppTest.class
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
# Step-by-step | ||
|
||
1. Create Maven Project | ||
|
||
```bash | ||
mvn archetype:generate -DgroupId=com.example -DartifactId=hello-world-api -DarchetypeArtifactId=maven-archetype-quickstart -DinteractiveMode=false | ||
``` | ||
|
||
2. Enter `hello-world-api` Directory | ||
|
||
```bash | ||
cd ./hello-world-api | ||
``` | ||
|
||
3. Add Spark Dependency in `pom.xml` | ||
|
||
```xml | ||
<dependency> | ||
<groupId>com.sparkjava</groupId> | ||
<artifactId>spark-core</artifactId> | ||
<version>2.9.4</version> | ||
</dependency> | ||
``` | ||
|
||
4. Install Maven Dependencies and Start App | ||
|
||
```bash | ||
mvn clean install | ||
mvn exec:java -Dexec.mainClass="com.example.HelloWorldApi" | ||
``` | ||
|
||
5. Run with Jar | ||
|
||
```bash | ||
mvn clean package | ||
``` | ||
|
||
```bash | ||
java -jar target/hello-world-api-1.0-SNAPSHOT.jar | ||
``` | ||
|
||
6. Download OpenTelemetry Java Agent | ||
|
||
```bash | ||
curl -L -O https://github.com/open-telemetry/opentelemetry-java-instrumentation/releases/latest/download/opentelemetry-javaagent.jar | ||
``` | ||
|
||
7. Run with Jar and Include the OpenTelemetry Java Agent | ||
|
||
```bash | ||
mvn clean package | ||
``` | ||
|
||
```bash | ||
export OTEL_SERVICE_NAME=my-service-name | ||
export OTEL_EXPORTER_OTLP_PROTOCOL=http/protobuf | ||
export OTEL_EXPORTER_OTLP_ENDPOINT="http://localhost:4318" | ||
export OTEL_EXPORTER_OTLP_HEADERS="x-token=bla" | ||
java -javaagent:opentelemetry-javaagent.jar -jar target/hello-world-api-1.0-SNAPSHOT.jar | ||
``` |