From f92c34bab4ac62c96894bfbc98c3e4b57c98ed4d Mon Sep 17 00:00:00 2001 From: Eric Deandrea Date: Fri, 29 Mar 2024 15:00:05 -0400 Subject: [PATCH] Update gateway application and some other minor updates to others Signed-off-by: Eric Deandrea --- .../src/main/resources/application.properties | 2 ++ .../src/main/resources/application.properties | 1 + orders/pom.xml | 13 ++++++++ .../orders/config/OtelDataSourceConfig.java | 30 +++++++++++++++++++ .../src/main/resources/application.properties | 2 ++ 5 files changed, 48 insertions(+) create mode 100644 orders/src/main/java/io/konveyor/demo/orders/config/OtelDataSourceConfig.java diff --git a/gateway/src/main/resources/application.properties b/gateway/src/main/resources/application.properties index 9dd1532..1fd9de8 100644 --- a/gateway/src/main/resources/application.properties +++ b/gateway/src/main/resources/application.properties @@ -1,3 +1,5 @@ +spring.application.name=gateway + services.orders.url=http://orders:8080/orders services.inventory.url=http://inventory:8080/products services.customers.url=http://customers:8080/customers-tomcat-1.0.0-SNAPSHOT/customers diff --git a/inventory/src/main/resources/application.properties b/inventory/src/main/resources/application.properties index ad02d02..0d31bab 100644 --- a/inventory/src/main/resources/application.properties +++ b/inventory/src/main/resources/application.properties @@ -1,3 +1,4 @@ +quarkus.application.name=inventory # Dev Spaces configurations %dev.quarkus.dev-ui.cors.enabled=false diff --git a/orders/pom.xml b/orders/pom.xml index 3e03f15..372000c 100644 --- a/orders/pom.xml +++ b/orders/pom.xml @@ -11,6 +11,7 @@ 3.13.0 17 3.2.5 + 2.2.0-alpha 3.2.4 2.11.5.redhat-00017 @@ -31,6 +32,13 @@ pom import + + io.opentelemetry.instrumentation + opentelemetry-instrumentation-bom-alpha + ${otel.version} + pom + import + @@ -68,6 +76,11 @@ opentelemetry-exporter-otlp + + io.opentelemetry.instrumentation + opentelemetry-jdbc + + org.springframework.boot diff --git a/orders/src/main/java/io/konveyor/demo/orders/config/OtelDataSourceConfig.java b/orders/src/main/java/io/konveyor/demo/orders/config/OtelDataSourceConfig.java new file mode 100644 index 0000000..1d60c5a --- /dev/null +++ b/orders/src/main/java/io/konveyor/demo/orders/config/OtelDataSourceConfig.java @@ -0,0 +1,30 @@ +package io.konveyor.demo.orders.config; + +import javax.sql.DataSource; + +import org.springframework.boot.autoconfigure.jdbc.DataSourceProperties; +import org.springframework.boot.jdbc.DataSourceBuilder; +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.Configuration; + +import io.opentelemetry.api.OpenTelemetry; +import io.opentelemetry.instrumentation.jdbc.datasource.JdbcTelemetry; + +/** + * This class is needed to allow tracing down to the JDBC level. + * Taken from https://opentelemetry.io/docs/languages/java/automatic/spring-boot/#jdbc-instrumentation + */ +@Configuration +public class OtelDataSourceConfig { + @Bean + public DataSource dataSource(DataSourceProperties dataSourceProperties, OpenTelemetry openTelemetry) { + var dataSource = DataSourceBuilder.create() + .driverClassName(dataSourceProperties.determineDriverClassName()) + .url(dataSourceProperties.determineUrl()) + .username(dataSourceProperties.getUsername()) + .password(dataSourceProperties.getPassword()) + .build(); + + return JdbcTelemetry.create(openTelemetry).wrap(dataSource); + } +} \ No newline at end of file diff --git a/orders/src/main/resources/application.properties b/orders/src/main/resources/application.properties index b0951a9..55e2064 100644 --- a/orders/src/main/resources/application.properties +++ b/orders/src/main/resources/application.properties @@ -1,3 +1,5 @@ +spring.application.name=orders + spring.datasource.url=jdbc:h2:mem:orders;DB_CLOSE_ON_EXIT=FALSE spring.datasource.username=orders spring.datasource.password=orders