Skip to content
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
5 changes: 3 additions & 2 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ jobs:

steps:
- name: Generate a token
if: github.event_name == 'push'
id: generate_token
uses: tibdex/github-app-token@v2
with:
Expand Down Expand Up @@ -51,11 +52,11 @@ jobs:
if: ${{ env.COMPONENT_VERSION == '' }}
run: echo "COMPONENT_VERSION=${{ steps.short_sha.outputs.version_tag }}-SNAPSHOT" >> $GITHUB_ENV

- name: Set up JDK 17
- name: Set up JDK 21
uses: actions/setup-java@v4
with:
distribution: temurin
java-version: 17
java-version: 21

- name: Grant execute permission for gradlew
run: chmod +x ./gradlew
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -52,11 +52,11 @@ jobs:
name: Release Bot
email: release-bot@bancolombia.com.co

- name: Set up JDK 17
- name: Set up JDK 21
uses: actions/setup-java@v4
with:
distribution: 'temurin'
java-version: 17
java-version: 21

- name: Grant execute permission for gradlew
run: chmod +x gradlew
Expand Down
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ The library is composed of four main modules:

## **Prerequisites**

**Java:** Version 17 or higher.
**Java:** Version 21 or higher.
**Gradle:** For dependency management.

## Getting Started
Expand Down Expand Up @@ -71,8 +71,8 @@ subprojects {
compileJava.dependsOn validateStructure

java {
sourceCompatibility = JavaVersion.VERSION_17
targetCompatibility = JavaVersion.VERSION_17
sourceCompatibility = JavaVersion.VERSION_21
targetCompatibility = JavaVersion.VERSION_21
}

//build.dependsOn 'pitest'
Expand Down
7 changes: 4 additions & 3 deletions build.gradle
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
buildscript {
ext {
cleanArchitectureVersion = '3.20.15'
springBootVersion = '3.5.5'
springCoreVersion = '6.2.11'
cleanArchitectureVersion = '4.0.4'
springBootVersion = '4.0.2'
sonarVersion = '6.0.1.5171'
jacocoVersion = '0.8.12'
pitestVersion = '1.15.0'
Expand All @@ -13,6 +12,8 @@ buildscript {
log4jVersion = '2.24.3'
commonslang3= '3.18.0'
nettyVersion = '4.1.127.Final'
logbackVersion = '1.5.19'
tomcatEmbedCoreVersion = "10.1.47"
}

}
Expand Down
7 changes: 5 additions & 2 deletions dependencyMgmt.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,11 @@ configurations.configureEach {
if (details.requested.group == 'io.netty' && details.requested.name == 'netty-codec-http') {
details.useVersion("${nettyVersion}")
}
if (details.requested.group == 'org.springframework' && details.requested.name == 'spring-core') {
details.useVersion("${springCoreVersion}")
if (details.requested.group == 'ch.qos.logback') {
details.useVersion("${logbackVersion}")
}
if (details.requested.group == 'org.apache.tomcat.embed' && details.requested.name == 'tomcat-embed-core') {
details.useVersion("${tomcatEmbedCoreVersion}")
}
}
}
5 changes: 1 addition & 4 deletions ecs-core/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,7 @@ dependencies {
implementation "org.apache.logging.log4j:log4j-core:${log4jVersion}"

// Spring configuration
implementation("org.springframework.boot:spring-boot-autoconfigure:${springBootVersion}") {
// Exclude to minimize transitive dependencies if not needed
exclude group: 'org.springframework.boot', module: 'spring-boot-starter'
}
implementation("org.springframework.boot:spring-boot")
}

ext {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,19 +1,25 @@
package co.com.bancolombia.ecs.infra.config;

import co.com.bancolombia.ecs.helpers.SamplingHelper;
import lombok.extern.log4j.Log4j2;
import org.springframework.context.annotation.Configuration;

import java.util.Arrays;
import java.util.Map;
import java.util.stream.Collectors;

@Configuration
@Log4j2
public class LoggerEcsInitializer {

private static final String START_CODE_40X = "40";
private static final String START_CODE_20X = "20";
private static final String VERSION_MESSAGE = "This application is built with Spring Boot {} and requires Java {}";
private static final String SB_VERSION = "4.0.2";
private static final String JAVA_VERSION = "21";

public LoggerEcsInitializer(SamplingConfig samplingConfig) {
log.info(VERSION_MESSAGE, SB_VERSION, JAVA_VERSION);
Map<String, SamplingConfig.SamplingRule> rulesMap = buildRulesMap(samplingConfig);
SamplingHelper.init(rulesMap);
}
Expand Down
2 changes: 2 additions & 0 deletions ecs-imperative/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@ dependencies {
}

testImplementation "org.springframework.boot:spring-boot-starter-test:${springBootVersion}"

implementation "com.fasterxml.jackson.core:jackson-databind"
}

ext {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@

@Order(Ordered.HIGHEST_PRECEDENCE)
public class ImperativeLogsHandler extends OncePerRequestFilter {
private static final int MAX_PAYLOAD_SIZE = 1024 * 1024;
private static final Set<String> CONSUMER_ACRONYMS = Set.of("consumer-acronym", "code", "channel");
private static final String HANDLED_EXCEPTION_PROPERTY = "handledException";
private static final int MIN_REQUEST_ERROR_CODE = 400;
Expand Down Expand Up @@ -69,7 +70,7 @@ protected void doFilterInternal(@NonNull HttpServletRequest request, @NonNull Ht
return;
}

var wrappedRequest = new ContentCachingRequestWrapper(request);
var wrappedRequest = new ContentCachingRequestWrapper(request, MAX_PAYLOAD_SIZE);
var wrappedResponse = new ContentCachingResponseWrapper(response);

try {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,11 +55,13 @@ class ImperativeLogsHandlerTest {
private ContentCachingRequestWrapper wrappedRequest;
private ContentCachingResponseWrapper wrappedResponse;

private static final int MAX_PAYLOAD_SIZE = 1024 * 1024;

@BeforeEach
void setUp() {
mockRequest = new MockHttpServletRequest();
mockResponse = new MockHttpServletResponse();
wrappedRequest = new ContentCachingRequestWrapper(mockRequest);
wrappedRequest = new ContentCachingRequestWrapper(mockRequest, MAX_PAYLOAD_SIZE);
wrappedResponse = new ContentCachingResponseWrapper(mockResponse);
imperativeLogsHandler = new ImperativeLogsHandler(ecsPropertiesConfig);
}
Expand Down
2 changes: 2 additions & 0 deletions ecs-reactive/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ dependencies {
// Reactor project
implementation "io.projectreactor:reactor-core:${reactorVersion}"
testImplementation "io.projectreactor:reactor-test:${reactorVersion}"

implementation "com.fasterxml.jackson.core:jackson-databind"
}

ext {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,11 @@
import reactor.core.scheduler.Schedulers;
import reactor.util.annotation.NonNull;

import java.util.List;
import java.util.Map;
import java.util.Objects;
import java.util.Set;
import java.util.stream.Collectors;

@Order(Ordered.HIGHEST_PRECEDENCE)
public class ReactiveLogsHandler implements WebFilter {
Expand Down Expand Up @@ -162,11 +164,22 @@ private void setRequestParameters(RequestLoggingDecorator decoratedRequest, LogR
requestInfo.setMethod(decoratedRequest.getMethod().name());
requestInfo.setUrl(decoratedRequest.getURI().getPath());

Map<String, String> headers = DataSanitizer.sanitizeHeaders(decoratedRequest.getHeaders().entrySet(),
ecsPropertiesConfig.getAllowRequestHeaders());
setConsumer(requestInfo, headers);
requestInfo.setMessageId(headers.get(MESSAGE_ID));
requestInfo.setHeaders(headers);
Set<Map.Entry<String, List<String>>> headers =
decoratedRequest.getHeaders()
.toSingleValueMap()
.entrySet()
.stream()
.collect(Collectors.toMap(
Map.Entry::getKey,
e -> List.of(e.getValue())
))
.entrySet();

Map<String, String> sanitizeHeaders = DataSanitizer.sanitizeHeaders(headers,
ecsPropertiesConfig.getAllowRequestHeaders());
setConsumer(requestInfo, sanitizeHeaders);
requestInfo.setMessageId(sanitizeHeaders.get(MESSAGE_ID));
requestInfo.setHeaders(sanitizeHeaders);
}

private HttpStatus resolveHttpStatus(Throwable ex) {
Expand Down
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,5 @@ metrics=true
language=java
org.gradle.parallel=true
systemProp.sonar.gradle.skipCompile=true
version=1.0.1
version=2.0.0
onlyUpdater=true
8 changes: 7 additions & 1 deletion main.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,11 @@ subprojects {
}
}
developers {
developer {
id "avendanodanny"
name "Danny Farid Avendaño Ojeda"
email "dannyfuv@gmail.com"
}
developer {
id "RicharLeon"
name "Richar Daniel Diaz Leon"
Expand Down Expand Up @@ -118,7 +123,8 @@ subprojects {
java {
withJavadocJar()
withSourcesJar()
sourceCompatibility = JavaVersion.VERSION_17
sourceCompatibility = JavaVersion.VERSION_21
targetCompatibility = JavaVersion.VERSION_21
}

javadoc {
Expand Down