Skip to content

Commit

Permalink
Merge pull request #31 from Jojoooo1/release/9.0
Browse files Browse the repository at this point in the history
Release - 9.0
  • Loading branch information
Jojoooo1 authored Sep 14, 2023
2 parents 3b3fc80 + 1550122 commit 6ccd577
Show file tree
Hide file tree
Showing 2 changed files with 40 additions and 1 deletion.
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
<!-- Metrics -->
<hibernate-micrometer.version>6.3.0.Final</hibernate-micrometer.version>
<datasource-micrometer.version>1.0.2</datasource-micrometer.version>
<opentelemetry-exporter-otlp.version>1.28.0</opentelemetry-exporter-otlp.version>
<opentelemetry-exporter-otlp.version>1.30.1</opentelemetry-exporter-otlp.version>

<!-- Lombok & Mapstruct -->
<projectlombok.version>1.18.28</projectlombok.version>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
package com.mycompany.microservice.api.infra.otlp;

import io.opentelemetry.exporter.otlp.trace.OtlpGrpcSpanExporter;
import io.opentelemetry.exporter.otlp.trace.OtlpGrpcSpanExporterBuilder;
import java.util.Map.Entry;
import org.apache.commons.lang3.StringUtils;
import org.springframework.boot.actuate.autoconfigure.tracing.otlp.OtlpProperties;
import org.springframework.boot.context.properties.EnableConfigurationProperties;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

@Configuration
@EnableConfigurationProperties(OtlpProperties.class)
public class OtlpConfiguration {

// For some reason breaking change was introduced, and we need to pass a default value
private static final String OTLP_DEFAULT = "http://localhost:4318/api/traces";

// OtlpAutoConfiguration use HTTP by default, we update it to use GRPC
// https://github.com/spring-projects/spring-boot/blob/main/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/tracing/otlp/OtlpAutoConfiguration.java
@Bean
public OtlpGrpcSpanExporter otlpExporter(final OtlpProperties properties) {

final OtlpGrpcSpanExporterBuilder builder =
OtlpGrpcSpanExporter.builder()
.setEndpoint(
StringUtils.isNotBlank(properties.getEndpoint())
? properties.getEndpoint()
: OTLP_DEFAULT)
.setTimeout(properties.getTimeout())
.setCompression(String.valueOf(properties.getCompression()).toLowerCase());

for (final Entry<String, String> header : properties.getHeaders().entrySet()) {
builder.addHeader(header.getKey(), header.getValue());
}

return builder.build();
}
}

0 comments on commit 6ccd577

Please sign in to comment.