Skip to content

Commit c22041e

Browse files
author
Jonathan Henrique Medeiros
committed
feature: upgrade spring
1 parent 45ccea0 commit c22041e

File tree

6 files changed

+17
-42
lines changed

6 files changed

+17
-42
lines changed

Makefile

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -26,9 +26,7 @@ restart:
2626
@docker-compose restart
2727

2828
upgrade_otel_agent:
29-
@echo "Update local version for OTEL Java Agent..."
29+
@echo "Download the OTEL Java Agent..."
3030
@mkdir -p agents
31-
@curl -o agents/opentelemetry-javaagent.jar -L https://github.com/open-telemetry/opentelemetry-java-instrumentation/releases/latest/download/opentelemetry-javaagent.jar
32-
@curl -sL https://github.com/open-telemetry/opentelemetry-java-instrumentation/releases | grep -oE 'releases/tag/v[0-9]+\.[0-9]+\.[0-9]+' | cut -d'/' -f3 | sort -V | tail -n 1 > agents/version.txt
33-
@VERSION=$$(cat agents/version.txt) && echo "OTEL Java Agent local was updated to $$VERSION"
31+
@curl -o agents/opentelemetry-javaagent.jar -L https://github.com/open-telemetry/opentelemetry-java-instrumentation/releases/download/v1.33.3/opentelemetry-javaagent.jar
3432
@rm -rf agents/version.txt

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ Esta arquitetura consiste em diminuir a concorrência entre transações da API
1717
</br>
1818

1919
[![node](https://img.shields.io/badge/Azul_Zulu_OpenJDK-21-red.svg)](https://www.azul.com/downloads/?package=jdk#zulu)
20-
[![node](https://img.shields.io/badge/Spring_Boot-3.2.5-green.svg)](https://spring.io/)
20+
[![node](https://img.shields.io/badge/Spring_Boot-3.3.0-green.svg)](https://spring.io/)
2121
[![node](https://img.shields.io/badge/MySQL-8.0.28-blue.svg)](https://www.mysql.com/)
2222

2323

agents/opentelemetry-javaagent.jar

442 KB
Binary file not shown.

pom.xml

Lines changed: 4 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
<parent>
66
<groupId>org.springframework.boot</groupId>
77
<artifactId>spring-boot-starter-parent</artifactId>
8-
<version>3.2.5</version>
8+
<version>3.3.0</version>
99
<relativePath/>
1010
</parent>
1111

@@ -21,10 +21,7 @@
2121
<mapstruct.version>1.5.5.Final</mapstruct.version>
2222
<logstash-logback-encoder.version>7.4</logstash-logback-encoder.version>
2323
<springdoc-openapi-starter-webmvc-ui.version>2.5.0</springdoc-openapi-starter-webmvc-ui.version>
24-
<snakeyaml.version>2.2</snakeyaml.version>
25-
<h2.version>2.2.224</h2.version>
26-
<opentelemetry.version>1.35.0</opentelemetry.version>
27-
<json-path.version>2.9.0</json-path.version>
24+
<opentelemetry.version>1.38.0</opentelemetry.version>
2825
</properties>
2926

3027
<dependencyManagement>
@@ -38,7 +35,7 @@
3835
</dependency>
3936
</dependencies>
4037
</dependencyManagement>
41-
38+
4239
<dependencies>
4340
<dependency>
4441
<groupId>org.springframework.boot</groupId>
@@ -109,33 +106,15 @@
109106
<artifactId>springdoc-openapi-starter-webmvc-ui</artifactId>
110107
<version>${springdoc-openapi-starter-webmvc-ui.version}</version>
111108
</dependency>
112-
<!-- Solves the https://cve.mitre.org/cgi-bin/cvename.cgi?name=CVE-2022-1471 in spring boot dependencies -->
113-
<dependency>
114-
<groupId>org.yaml</groupId>
115-
<artifactId>snakeyaml</artifactId>
116-
<version>${snakeyaml.version}</version>
117-
</dependency>
118109
<dependency>
119110
<groupId>com.h2database</groupId>
120111
<artifactId>h2</artifactId>
121-
<version>${h2.version}</version>
112+
<scope>test</scope>
122113
</dependency>
123114
<dependency>
124115
<groupId>org.springframework.boot</groupId>
125116
<artifactId>spring-boot-starter-test</artifactId>
126117
<scope>test</scope>
127-
<exclusions>
128-
<exclusion>
129-
<groupId>com.jayway.jsonpath</groupId>
130-
<artifactId>json-path</artifactId>
131-
</exclusion>
132-
</exclusions>
133-
</dependency>
134-
<!-- Solves the https://devhub.checkmarx.com/cve-details/CVE-2023-51074 -->
135-
<dependency>
136-
<groupId>com.jayway.jsonpath</groupId>
137-
<artifactId>json-path</artifactId>
138-
<version>${json-path.version}</version>
139118
</dependency>
140119
<dependency>
141120
<groupId>io.opentelemetry</groupId>

src/main/java/br/com/multidatasources/config/aop/OTelSpannerCustomAspect.java

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -27,18 +27,18 @@ public OTelSpannerCustomAspect(final ObjectMapper objectMapper) {
2727

2828
@Around("@within(OTelSpannerCustom)")
2929
public Object execute(final ProceedingJoinPoint joinPoint) throws Throwable {
30-
final long start = System.currentTimeMillis();
30+
final long start = System.nanoTime();
3131

3232
final Object proceed = joinPoint.proceed();
3333

34-
final long executionTime = System.currentTimeMillis() - start;
34+
final long executionTime = System.nanoTime() - start;
3535
final String methodName = Objects.isNull(joinPoint.getSignature()) ? "Unrecognized" : joinPoint.getSignature().toShortString();
3636
final var response = objectMapper.writeValueAsString(proceed);
3737

3838
final Span span = Span.current();
39-
span.setAttribute("response", Objects.isNull(response) ? "method called is void" : response);
40-
span.setAttribute("executionTime", executionTime);
41-
span.setAttribute("methodCalled", methodName);
39+
span.setAttribute("method_response_value", Objects.isNull(response) ? "method called is void" : response);
40+
span.setAttribute("execution_time_nanos", executionTime);
41+
span.setAttribute("method_called_name", methodName);
4242

4343
return proceed;
4444
}

src/main/java/br/com/multidatasources/config/datasource/TransactionRoutingDataSource.java

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -17,21 +17,19 @@ public class TransactionRoutingDataSource extends AbstractRoutingDataSource {
1717
protected Object determineCurrentLookupKey() {
1818
if (TransactionSynchronizationManager.isCurrentTransactionReadOnly()) {
1919
LOGGER.info("Routed to: {}", READ_ONLY);
20-
enrichSpan(READ_ONLY.name(), READ_ONLY.poolName());
21-
20+
enrichSpan(READ_ONLY);
2221
return READ_ONLY;
2322
}
2423

2524
LOGGER.info("Routed to: {}", READ_WRITE);
26-
enrichSpan(READ_WRITE.name(), READ_WRITE.poolName());
27-
25+
enrichSpan(READ_WRITE);
2826
return READ_WRITE;
2927
}
3028

31-
private void enrichSpan(final String dbType, final String pollName) {
29+
private void enrichSpan(final DataSourceType dataSourceType) {
3230
final var currentSpan = Span.current();
33-
currentSpan.setAttribute("db.type", dbType);
34-
currentSpan.setAttribute("db.poll", pollName);
31+
currentSpan.setAttribute("db.type", dataSourceType.name());
32+
currentSpan.setAttribute("db.poll", dataSourceType.poolName());
3533
}
3634

3735
}

0 commit comments

Comments
 (0)