-
Notifications
You must be signed in to change notification settings - Fork 8
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
Showing
10 changed files
with
466 additions
and
17 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
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
26 changes: 26 additions & 0 deletions
26
exercises/manual-instrumentation-java/initial/todoui-thymeleaf/Dockerfile
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,26 @@ | ||
FROM docker.io/maven:3-eclipse-temurin-21 as build | ||
WORKDIR /workspace/app | ||
|
||
COPY pom.xml . | ||
COPY src src | ||
|
||
RUN --mount=type=cache,target=/root/.m2 mvn install -DskipTests | ||
# RUN mvn install -DskipTests | ||
RUN mkdir -p target/dependency && (cd target/dependency; jar -xf ../*.jar) | ||
|
||
FROM docker.io/eclipse-temurin:21-jdk-alpine | ||
RUN mkdir -p /opt/todoui | ||
WORKDIR /opt/todoui | ||
# RUN addgroup -S demo && adduser -S demo -G demo | ||
# USER demo | ||
VOLUME /tmp | ||
ARG DEPENDENCY=/workspace/app/target/dependency | ||
COPY --from=build ${DEPENDENCY}/BOOT-INF/lib /opt/todoui/app/lib | ||
COPY --from=build ${DEPENDENCY}/META-INF /opt/todoui/app/META-INF | ||
COPY --from=build ${DEPENDENCY}/BOOT-INF/classes /opt/todoui/app | ||
|
||
ADD https://github.com/open-telemetry/opentelemetry-java-instrumentation/releases/latest/download/opentelemetry-javaagent.jar /opt/todoui | ||
|
||
ENTRYPOINT ["java","-cp","/opt/todoui/app:/opt/todoui/app/lib/*", "-javaagent:/opt/todoui/opentelemetry-javaagent.jar", "io.novatec.todoui.TodouiApplication"] | ||
#ENTRYPOINT ["java", "-cp", "/opt/todobackend/app:/opt/todobackend/app/lib/*", "-javaagent:/opt/todobackend/opentelemetry-javaagent.jar","io.novatec.todobackend.TodobackendApplication"] | ||
|
91 changes: 91 additions & 0 deletions
91
exercises/manual-instrumentation-java/initial/todoui-thymeleaf/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,91 @@ | ||
<?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> | ||
|
||
<groupId>io.novatec</groupId> | ||
<artifactId>todoui-manual</artifactId> | ||
<version>0.0.1-SNAPSHOT</version> | ||
<packaging>jar</packaging> | ||
|
||
<name>todoui-manual</name> | ||
<description>Demo project for Spring Boot</description> | ||
|
||
<parent> | ||
<groupId>org.springframework.boot</groupId> | ||
<artifactId>spring-boot-starter-parent</artifactId> | ||
<version>2.7.16</version> | ||
<relativePath/> <!-- lookup parent from repository --> | ||
</parent> | ||
|
||
<properties> | ||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> | ||
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding> | ||
<java.version>17</java.version> | ||
</properties> | ||
|
||
<dependencies> | ||
<dependency> | ||
<groupId>org.springframework.boot</groupId> | ||
<artifactId>spring-boot-starter-actuator</artifactId> | ||
</dependency> | ||
<dependency> | ||
<groupId>org.springframework.boot</groupId> | ||
<artifactId>spring-boot-starter-thymeleaf</artifactId> | ||
</dependency> | ||
<dependency> | ||
<groupId>org.springframework.boot</groupId> | ||
<artifactId>spring-boot-starter-web</artifactId> | ||
</dependency> | ||
<dependency> | ||
<groupId>org.springframework.boot</groupId> | ||
<artifactId>spring-boot-starter-test</artifactId> | ||
<scope>test</scope> | ||
</dependency> | ||
<dependency> | ||
<groupId>io.opentelemetry</groupId> | ||
<artifactId>opentelemetry-api</artifactId> | ||
</dependency> | ||
<dependency> | ||
<groupId>io.opentelemetry</groupId> | ||
<artifactId>opentelemetry-sdk</artifactId> | ||
</dependency> | ||
<dependency> | ||
<groupId>io.opentelemetry</groupId> | ||
<artifactId>opentelemetry-exporter-logging</artifactId> | ||
</dependency> | ||
<dependency> | ||
<groupId>io.opentelemetry</groupId> | ||
<artifactId>opentelemetry-exporter-otlp</artifactId> | ||
</dependency> | ||
<dependency> | ||
<!-- Not managed by opentelemetry-bom --> | ||
<groupId>io.opentelemetry.semconv</groupId> | ||
<artifactId>opentelemetry-semconv</artifactId> | ||
<version>1.26.0-alpha</version> | ||
</dependency> | ||
</dependencies> | ||
|
||
<dependencyManagement> | ||
<dependencies> | ||
<dependency> | ||
<groupId>io.opentelemetry</groupId> | ||
<artifactId>opentelemetry-bom</artifactId> | ||
<version>1.40.0</version> | ||
<type>pom</type> | ||
<scope>import</scope> | ||
</dependency> | ||
</dependencies> | ||
</dependencyManagement> | ||
|
||
<build> | ||
<plugins> | ||
<plugin> | ||
<groupId>org.springframework.boot</groupId> | ||
<artifactId>spring-boot-maven-plugin</artifactId> | ||
</plugin> | ||
</plugins> | ||
</build> | ||
|
||
|
||
</project> |
60 changes: 60 additions & 0 deletions
60
.../initial/todoui-thymeleaf/src/main/java/io/novatec/todoui/OpenTelemetryConfiguration.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,60 @@ | ||
package io.novatec.todoui; | ||
|
||
import java.util.concurrent.TimeUnit; | ||
|
||
import org.springframework.beans.factory.config.ConfigurableBeanFactory; | ||
import org.springframework.context.annotation.Bean; | ||
import org.springframework.context.annotation.Configuration; | ||
import org.springframework.context.annotation.Scope; | ||
|
||
//Basic Otel API & SDK | ||
import io.opentelemetry.api.OpenTelemetry; | ||
import io.opentelemetry.sdk.OpenTelemetrySdk; | ||
import io.opentelemetry.sdk.resources.Resource; | ||
import io.opentelemetry.semconv.ResourceAttributes; | ||
|
||
//Tracing and Spans | ||
import io.opentelemetry.sdk.trace.SdkTracerProvider; | ||
import io.opentelemetry.sdk.trace.export.SimpleSpanProcessor; | ||
|
||
import io.opentelemetry.exporter.logging.LoggingSpanExporter; | ||
import io.opentelemetry.exporter.otlp.trace.OtlpGrpcSpanExporter; | ||
|
||
import io.opentelemetry.api.trace.propagation.W3CTraceContextPropagator; | ||
import io.opentelemetry.context.propagation.ContextPropagators; | ||
|
||
|
||
@SuppressWarnings("deprecation") | ||
@Configuration | ||
public class OpenTelemetryConfiguration { | ||
|
||
@Bean | ||
@Scope(value = ConfigurableBeanFactory.SCOPE_SINGLETON) | ||
public OpenTelemetry openTelemetry(){ | ||
|
||
Resource resource = Resource.getDefault().toBuilder().put(ResourceAttributes.SERVICE_NAME, "tododui").put(ResourceAttributes.SERVICE_VERSION, "0.1.0").build(); | ||
|
||
OtlpGrpcSpanExporter jaegerOtlpExporter = | ||
OtlpGrpcSpanExporter.builder() | ||
.setEndpoint("http://localhost:4317") | ||
.setTimeout(30, TimeUnit.SECONDS) | ||
.build(); | ||
|
||
SdkTracerProvider sdkTracerProvider = SdkTracerProvider.builder() | ||
.addSpanProcessor(SimpleSpanProcessor.create(LoggingSpanExporter.create())) | ||
.addSpanProcessor(SimpleSpanProcessor.create(jaegerOtlpExporter)) | ||
// .addSpanProcessor(BatchSpanProcessor.builder(LoggingSpanExporter.create()).build()) // same results for now | ||
.setResource(resource) | ||
.build(); | ||
// .buildAndRegisterGlobal(); | ||
|
||
|
||
OpenTelemetry openTelemetry = OpenTelemetrySdk.builder() | ||
.setTracerProvider(sdkTracerProvider) | ||
.setPropagators(ContextPropagators.create(W3CTraceContextPropagator.getInstance())) | ||
.build(); | ||
|
||
return openTelemetry; | ||
} | ||
|
||
} |
Oops, something went wrong.