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

Removing Otel stuff in favor of moving to the module #17

Merged
merged 1 commit into from
Apr 16, 2024
Merged
Show file tree
Hide file tree
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
16 changes: 8 additions & 8 deletions gateway/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -58,15 +58,15 @@
</dependency>

<!--Distributed tracing -->
<dependency>
<groupId>io.micrometer</groupId>
<artifactId>micrometer-tracing-bridge-otel</artifactId>
</dependency>
<!-- <dependency>-->
<!-- <groupId>io.micrometer</groupId>-->
<!-- <artifactId>micrometer-tracing-bridge-otel</artifactId>-->
<!-- </dependency>-->

<dependency>
<groupId>io.opentelemetry</groupId>
<artifactId>opentelemetry-exporter-otlp</artifactId>
</dependency>
<!-- <dependency>-->
<!-- <groupId>io.opentelemetry</groupId>-->
<!-- <artifactId>opentelemetry-exporter-otlp</artifactId>-->
<!-- </dependency>-->

<dependency>
<groupId>org.springframework.cloud</groupId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,6 @@
import io.github.resilience4j.retry.annotation.Retry;
import io.konveyor.demo.gateway.model.Customer;
import io.konveyor.demo.util.PaginatedResponse;
import io.micrometer.tracing.annotation.NewSpan;
import io.micrometer.tracing.annotation.SpanTag;
import lombok.extern.slf4j.Slf4j;

@Repository
Expand All @@ -32,8 +30,8 @@ public CustomerRepository(RestClient.Builder restClientBuilder, @Value("${servic

@CircuitBreaker(name = "Customers", fallbackMethod = "getFallbackCustomer")
@Retry(name = "Customers", fallbackMethod = "getFallbackCustomer")
@NewSpan
public Customer getCustomerById(@SpanTag Long id) {
// @NewSpan
public Customer getCustomerById(Long id) {
log.debug("Entering OrdersService.getCustomerById()");

var c = this.restClient.get()
Expand All @@ -52,8 +50,8 @@ public Customer getCustomerById(@SpanTag Long id) {

@CircuitBreaker(name = "AllCustomers", fallbackMethod = "getFallbackCustomers")
@Retry(name = "AllCustomers", fallbackMethod = "getFallbackCustomer")
@NewSpan
public List<Customer> findAll(@SpanTag Pageable pageable) {
// @NewSpan
public List<Customer> findAll(Pageable pageable) {
log.debug("Entering CustomerRepository.findAll()");

return this.restClient.get()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,6 @@
import io.github.resilience4j.retry.annotation.Retry;
import io.konveyor.demo.gateway.model.OrderItem;
import io.konveyor.demo.gateway.model.Product;
import io.micrometer.tracing.annotation.NewSpan;
import io.micrometer.tracing.annotation.SpanTag;
import lombok.extern.slf4j.Slf4j;

@Repository
Expand All @@ -42,8 +40,8 @@ public Product getProduct(OrderItem item) {
.body(Product.class);
}

@NewSpan
public List<OrderItem> getProductDetails(@SpanTag List<OrderItem> items) {
// @NewSpan
public List<OrderItem> getProductDetails(List<OrderItem> items) {
log.debug("Entering InventoryRepository.getProductDetails()");

return items.stream()
Expand All @@ -65,8 +63,8 @@ public List<OrderItem> getProductDetails(@SpanTag List<OrderItem> items) {

@CircuitBreaker(name = "AllProducts", fallbackMethod = "getFallbackProducts")
@Retry(name = "AllProducts", fallbackMethod = "getFallbackProducts")
@NewSpan
public List<Product> findAll(@SpanTag Pageable pageable) {
// @NewSpan
public List<Product> findAll(Pageable pageable) {
log.debug("Entering InventoryRepository.findAll()");

return this.restClient.get()
Expand All @@ -82,8 +80,8 @@ public List<Product> findAll(@SpanTag Pageable pageable) {

@CircuitBreaker(name = "Products", fallbackMethod = "getFallbackProduct")
@Retry(name = "Products", fallbackMethod = "getFallbackProduct")
@NewSpan
public Product getProductById(@SpanTag Long id) {
// @NewSpan
public Product getProductById(Long id) {
log.debug("Entering InventoryRepository.getProductById()");

var p = this.restClient.get()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,6 @@
import io.github.resilience4j.circuitbreaker.annotation.CircuitBreaker;
import io.github.resilience4j.retry.annotation.Retry;
import io.konveyor.demo.gateway.model.Order;
import io.micrometer.tracing.annotation.NewSpan;
import io.micrometer.tracing.annotation.SpanTag;
import lombok.extern.slf4j.Slf4j;

@Repository
Expand All @@ -31,8 +29,8 @@ public OrderRepository(RestClient.Builder restClientBuilder, @Value("${services.

@CircuitBreaker(name = "Orders", fallbackMethod = "getFallbackOrder")
@Retry(name = "Orders", fallbackMethod = "getFallbackOrder")
@NewSpan
public Order getOrderById(@SpanTag Long id) {
// @NewSpan
public Order getOrderById(Long id) {
log.debug("Entering OrderRepository.getOrderById()");

var o = this.restClient.get()
Expand All @@ -54,8 +52,8 @@ public Order getOrderById(@SpanTag Long id) {

@CircuitBreaker(name = "AllOrders", fallbackMethod = "getFallbackOrders")
@Retry(name = "AllOrders", fallbackMethod = "getFallbackOrders")
@NewSpan
public List<Order> findAll(@SpanTag Pageable pageable) {
// @NewSpan
public List<Order> findAll(Pageable pageable) {
log.debug("Entering OrderRepository.findAll()");

return this.restClient.get()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,6 @@

import io.konveyor.demo.gateway.model.Customer;
import io.konveyor.demo.gateway.repository.CustomerRepository;
import io.micrometer.tracing.annotation.NewSpan;
import io.micrometer.tracing.annotation.SpanTag;
import lombok.extern.slf4j.Slf4j;

@Service
Expand All @@ -18,16 +16,16 @@ public class CustomersService {
@Autowired
private CustomerRepository customerRepository;

@NewSpan
public Page<Customer> findAll(@SpanTag Pageable pageable) {
// @NewSpan
public Page<Customer> findAll(Pageable pageable) {
log.debug("Entering OrdersService.findAll()");

var orders = customerRepository.findAll(pageable);
return new PageImpl<Customer>(orders, pageable, orders.size());
}

@NewSpan
public Customer getById(@SpanTag Long id) {
// @NewSpan
public Customer getById(Long id) {
log.debug("Entering CustomersService.getById()");
return customerRepository.getCustomerById(id);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,6 @@

import io.konveyor.demo.gateway.model.Product;
import io.konveyor.demo.gateway.repository.InventoryRepository;
import io.micrometer.tracing.annotation.NewSpan;
import io.micrometer.tracing.annotation.SpanTag;
import lombok.extern.slf4j.Slf4j;

@Service
Expand All @@ -18,16 +16,16 @@ public class InventoryService {
@Autowired
private InventoryRepository inventoryRepository;

@NewSpan
public Page<Product> findAll(@SpanTag Pageable pageable) {
// @NewSpan
public Page<Product> findAll(Pageable pageable) {
log.debug("Entering OrdersService.findAll()");

var orders = inventoryRepository.findAll(pageable);
return new PageImpl<Product>(orders, pageable, orders.size());
}

@NewSpan
public Product getById(@SpanTag Long id) {
// @NewSpan
public Product getById(Long id) {
log.debug("Entering CustomersService.getById()");
return inventoryRepository.getProductById(id);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,6 @@
import io.konveyor.demo.gateway.repository.CustomerRepository;
import io.konveyor.demo.gateway.repository.InventoryRepository;
import io.konveyor.demo.gateway.repository.OrderRepository;
import io.micrometer.tracing.annotation.NewSpan;
import io.micrometer.tracing.annotation.SpanTag;
import lombok.extern.slf4j.Slf4j;

@Service
Expand All @@ -26,8 +24,8 @@ public class OrdersService {
@Autowired
private InventoryRepository inventoryRepository;

@NewSpan
public Order getById(@SpanTag Long id) {
// @NewSpan
public Order getById(Long id) {
log.debug("Entering OrdersService.getById()");
Order o = orderRepository.getOrderById(id);

Expand All @@ -39,8 +37,8 @@ public Order getById(@SpanTag Long id) {
return o;
}

@NewSpan
public Page<Order> findAll(@SpanTag Pageable pageable) {
// @NewSpan
public Page<Order> findAll(Pageable pageable) {
log.debug("Entering OrdersService.findAll()");
var orders = orderRepository.findAll(pageable);

Expand Down
8 changes: 5 additions & 3 deletions gateway/src/main/resources/application.properties
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ management.endponts.web.exposure.include=*
management.endpoint.health.show-details=always
management.health.circuitbreakers.enabled=true
management.info.git.mode=full
management.observations.annotations.enabled=true
management.otlp.tracing.endpoint=http://otel-collector:4318/v1/traces
management.tracing.sampling.probability=1.0

# Observability/tracing
#management.observations.annotations.enabled=true
#management.otlp.tracing.endpoint=http://otel-collector:4318/v1/traces
#management.tracing.sampling.probability=1.0
19 changes: 11 additions & 8 deletions inventory/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -61,14 +61,17 @@
<groupId>io.quarkus</groupId>
<artifactId>quarkus-micrometer-registry-prometheus</artifactId>
</dependency>
<dependency>
<groupId>io.quarkus</groupId>
<artifactId>quarkus-opentelemetry</artifactId>
</dependency>
<dependency>
<groupId>io.opentelemetry.instrumentation</groupId>
<artifactId>opentelemetry-jdbc</artifactId>
</dependency>

<!--Distributed tracing -->
<!-- <dependency>-->
<!-- <groupId>io.quarkus</groupId>-->
<!-- <artifactId>quarkus-opentelemetry</artifactId>-->
<!-- </dependency>-->
<!-- <dependency>-->
<!-- <groupId>io.opentelemetry.instrumentation</groupId>-->
<!-- <artifactId>opentelemetry-jdbc</artifactId>-->
<!-- </dependency>-->

<dependency>
<groupId>io.quarkus</groupId>
<artifactId>quarkus-junit5-mockito</artifactId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@

@ApplicationScoped
public class ProductRepository implements PanacheRepository<Product> {
// @WithSpan
public List<Product> findAll(Page page, Sort sort) {
Log.debug("Entering ProductRepository.findAll()");
return findAll(sort)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,16 +26,17 @@ public class ProductService implements IProductService {
* @param id The {@link Product} {@code id}
* @return The {@link Product} with the supplied {@code id}, {@literal null} if no {@link Product} is found.
*/
// @WithSpan
@Override
public Product findById(Long id) {
Log.debug("Entering ProductService.findById()");
return repository.findById(id);
}

// @WithSpan
@Override
public List<Product> findAll(Page page, Sort sort) {
Log.debug("Entering ProductService.findAll()");
return repository.findAll(page, sort);
}


}
6 changes: 3 additions & 3 deletions inventory/src/main/resources/application.properties
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,9 @@ quarkus.application.name=inventory
%prod.quarkus.hibernate-orm.sql-load-script=import.sql
%prod.quarkus.hibernate-orm.log.sql=true

# OpenTelemetry
%prod.quarkus.otel.exporter.otlp.traces.endpoint=http://otel-collector:4317
%prod.quarkus.datasource.jdbc.telemetry=true
# Observability/tracing
#quarkus.otel.exporter.otlp.traces.endpoint=http://otel-collector:4317
#quarkus.datasource.jdbc.telemetry=true

# OpenShift configurations
# %prod.quarkus.kubernetes-client.trust-certs=true
Expand Down
24 changes: 12 additions & 12 deletions orders/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -66,20 +66,20 @@
</dependency>

<!--Distributed tracing -->
<dependency>
<groupId>io.micrometer</groupId>
<artifactId>micrometer-tracing-bridge-otel</artifactId>
</dependency>
<!-- <dependency>-->
<!-- <groupId>io.micrometer</groupId>-->
<!-- <artifactId>micrometer-tracing-bridge-otel</artifactId>-->
<!-- </dependency>-->

<dependency>
<groupId>io.opentelemetry</groupId>
<artifactId>opentelemetry-exporter-otlp</artifactId>
</dependency>
<!-- <dependency>-->
<!-- <groupId>io.opentelemetry</groupId>-->
<!-- <artifactId>opentelemetry-exporter-otlp</artifactId>-->
<!-- </dependency>-->

<dependency>
<groupId>io.opentelemetry.instrumentation</groupId>
<artifactId>opentelemetry-jdbc</artifactId>
</dependency>
<!-- <dependency>-->
<!-- <groupId>io.opentelemetry.instrumentation</groupId>-->
<!-- <artifactId>opentelemetry-jdbc</artifactId>-->
<!-- </dependency>-->

<!-- Testing -->
<dependency>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,24 +7,21 @@
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);
}
// @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);
// }
}
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,6 @@

import io.konveyor.demo.orders.model.Order;
import io.konveyor.demo.orders.repository.OrderRepository;
import io.micrometer.tracing.annotation.NewSpan;
import io.micrometer.tracing.annotation.SpanTag;

@Service
@Transactional
Expand All @@ -23,12 +21,12 @@ public class OrderService {
* @param id The {@link Order} {@code id}
* @return The {@link Order} with the supplied {@code id}, {@literal null} if no {@link Order} is found.
*/
@NewSpan
public Order findById(@SpanTag("arg.id") Long id) {
// @NewSpan
public Order findById(Long id) {
return repository.findById(id).orElse(null);
}

@NewSpan
// @NewSpan
public Page<Order> findAll(Pageable pageable) {
return repository.findAll(pageable);
}
Expand Down
Loading