Skip to content

Commit

Permalink
feature: upgrade spring
Browse files Browse the repository at this point in the history
  • Loading branch information
Jonathan Henrique Medeiros committed May 31, 2024
1 parent 45ccea0 commit c22041e
Show file tree
Hide file tree
Showing 6 changed files with 17 additions and 42 deletions.
6 changes: 2 additions & 4 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,7 @@ restart:
@docker-compose restart

upgrade_otel_agent:
@echo "Update local version for OTEL Java Agent..."
@echo "Download the OTEL Java Agent..."
@mkdir -p agents
@curl -o agents/opentelemetry-javaagent.jar -L https://github.com/open-telemetry/opentelemetry-java-instrumentation/releases/latest/download/opentelemetry-javaagent.jar
@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
@VERSION=$$(cat agents/version.txt) && echo "OTEL Java Agent local was updated to $$VERSION"
@curl -o agents/opentelemetry-javaagent.jar -L https://github.com/open-telemetry/opentelemetry-java-instrumentation/releases/download/v1.33.3/opentelemetry-javaagent.jar
@rm -rf agents/version.txt
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ Esta arquitetura consiste em diminuir a concorrência entre transações da API
</br>

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


Expand Down
Binary file modified agents/opentelemetry-javaagent.jar
Binary file not shown.
29 changes: 4 additions & 25 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>3.2.5</version>
<version>3.3.0</version>
<relativePath/>
</parent>

Expand All @@ -21,10 +21,7 @@
<mapstruct.version>1.5.5.Final</mapstruct.version>
<logstash-logback-encoder.version>7.4</logstash-logback-encoder.version>
<springdoc-openapi-starter-webmvc-ui.version>2.5.0</springdoc-openapi-starter-webmvc-ui.version>
<snakeyaml.version>2.2</snakeyaml.version>
<h2.version>2.2.224</h2.version>
<opentelemetry.version>1.35.0</opentelemetry.version>
<json-path.version>2.9.0</json-path.version>
<opentelemetry.version>1.38.0</opentelemetry.version>
</properties>

<dependencyManagement>
Expand All @@ -38,7 +35,7 @@
</dependency>
</dependencies>
</dependencyManagement>

<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
Expand Down Expand Up @@ -109,33 +106,15 @@
<artifactId>springdoc-openapi-starter-webmvc-ui</artifactId>
<version>${springdoc-openapi-starter-webmvc-ui.version}</version>
</dependency>
<!-- Solves the https://cve.mitre.org/cgi-bin/cvename.cgi?name=CVE-2022-1471 in spring boot dependencies -->
<dependency>
<groupId>org.yaml</groupId>
<artifactId>snakeyaml</artifactId>
<version>${snakeyaml.version}</version>
</dependency>
<dependency>
<groupId>com.h2database</groupId>
<artifactId>h2</artifactId>
<version>${h2.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
<exclusions>
<exclusion>
<groupId>com.jayway.jsonpath</groupId>
<artifactId>json-path</artifactId>
</exclusion>
</exclusions>
</dependency>
<!-- Solves the https://devhub.checkmarx.com/cve-details/CVE-2023-51074 -->
<dependency>
<groupId>com.jayway.jsonpath</groupId>
<artifactId>json-path</artifactId>
<version>${json-path.version}</version>
</dependency>
<dependency>
<groupId>io.opentelemetry</groupId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,18 +27,18 @@ public OTelSpannerCustomAspect(final ObjectMapper objectMapper) {

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

final Object proceed = joinPoint.proceed();

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

final Span span = Span.current();
span.setAttribute("response", Objects.isNull(response) ? "method called is void" : response);
span.setAttribute("executionTime", executionTime);
span.setAttribute("methodCalled", methodName);
span.setAttribute("method_response_value", Objects.isNull(response) ? "method called is void" : response);
span.setAttribute("execution_time_nanos", executionTime);
span.setAttribute("method_called_name", methodName);

return proceed;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,21 +17,19 @@ public class TransactionRoutingDataSource extends AbstractRoutingDataSource {
protected Object determineCurrentLookupKey() {
if (TransactionSynchronizationManager.isCurrentTransactionReadOnly()) {
LOGGER.info("Routed to: {}", READ_ONLY);
enrichSpan(READ_ONLY.name(), READ_ONLY.poolName());

enrichSpan(READ_ONLY);
return READ_ONLY;
}

LOGGER.info("Routed to: {}", READ_WRITE);
enrichSpan(READ_WRITE.name(), READ_WRITE.poolName());

enrichSpan(READ_WRITE);
return READ_WRITE;
}

private void enrichSpan(final String dbType, final String pollName) {
private void enrichSpan(final DataSourceType dataSourceType) {
final var currentSpan = Span.current();
currentSpan.setAttribute("db.type", dbType);
currentSpan.setAttribute("db.poll", pollName);
currentSpan.setAttribute("db.type", dataSourceType.name());
currentSpan.setAttribute("db.poll", dataSourceType.poolName());
}

}

0 comments on commit c22041e

Please sign in to comment.