Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix Java OTEL SDK example #729

Merged
merged 2 commits into from
Dec 22, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
77 changes: 7 additions & 70 deletions docs/shipping/Code/java.md
Original file line number Diff line number Diff line change
Expand Up @@ -513,28 +513,14 @@ If you need an example aplication to test this integration, please refer to our

### Configure the instrumentation

Add the following dependencies to `pom.xml`:

```xml
<?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/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
:::note
The below guide is using LogBack appender. OpenTelemetry also support [Log4J Appender](https://github.com/open-telemetry/opentelemetry-java-instrumentation/blob/main/instrumentation/log4j/log4j-appender-2.17/library/README.md).
:::

<groupId>com.logzio.otel</groupId>
<artifactId>otel-log</artifactId>
<version>1.0-SNAPSHOT</version>
<name>otel-log</name>
<packaging>jar</packaging>

<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<maven.compiler.release>17</maven.compiler.release>
<spring-boot.version>3.0.6</spring-boot.version>
</properties>
Add the following dependencies to `pom.xml`:

```xml
<dependencyManagement>
<dependencies>
<dependency>
Expand Down Expand Up @@ -577,18 +563,6 @@ Add the following dependencies to `pom.xml`:
<artifactId>opentelemetry-exporter-otlp-logs</artifactId>
</dependency>

<!-- Spring Boot dependencies -->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter</artifactId>
<version>${spring-boot.version}</version>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
<version>${spring-boot.version}</version>
</dependency>

<!-- Logback dependencies -->
<dependency>
<groupId>ch.qos.logback</groupId>
Expand All @@ -613,43 +587,6 @@ Add the following dependencies to `pom.xml`:
<version>1.25.1-alpha</version>
</dependency>
</dependencies>

<build>
<plugins>
<!-- Spring Boot Maven plugin -->
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<version>${spring-boot.version}</version>
</plugin>

<plugin>
<artifactId>maven-assembly-plugin</artifactId>
<version>3.5.0</version>
<configuration>
<descriptorRefs>
<descriptorRef>jar-with-dependencies</descriptorRef>
</descriptorRefs>
<archive>
<manifest>
<mainClass>com.logzio.otel.DiceApplication</mainClass>
</manifest>
</archive>
</configuration>
<executions>
<execution>
<id>make-assembly</id>
<phase>package</phase>
<goals>
<goal>single</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>

```


Expand All @@ -672,7 +609,7 @@ import io.opentelemetry.api.common.Attributes;
public class OpenTelemetryConfig {

private static final String DEFAULT_ENDPOINT = "https://otlp-listener.logz.io/v1/logs";
private static final String LOGZ_IO_TOKEN = "<LOG-SHIPPING-TOKEN>";
private static final String LOGZ_IO_TOKEN = "<<LOG-SHIPPING-TOKEN>>";
private static final String SERVICE_NAME = "java-otlp";

public void initializeOpenTelemetry() {
Expand Down Expand Up @@ -711,7 +648,7 @@ public class OpenTelemetryConfig {

Update the `listener.logz.io` part in `https://otlp-listener.logz.io/v1/logs` with the URL for [your hosting region](https://docs.logz.io/docs/user-guide/admin/hosting-regions/account-region).

#### Add the Logback
#### Configure Logback

```xml
<?xml version="1.0" encoding="UTF-8"?>
Expand Down
Loading