Skip to content

Commit

Permalink
[enhancement] log duration of the feign response/exception execution …
Browse files Browse the repository at this point in the history
…in seconds
  • Loading branch information
mosidev authored and Abdollahi committed Feb 13, 2024
1 parent ecd752d commit 4a51b78
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 24 deletions.
22 changes: 6 additions & 16 deletions pom.xml
Original file line number Diff line number Diff line change
@@ -1,18 +1,18 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.tosan.client.http</groupId>
<artifactId>tosan-httpclient-spring-boot-root</artifactId>
<version>3.1.6-SNAPSHOT</version>
<packaging>pom</packaging>

<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>3.2.0</version>
<version>3.2.2</version>
<relativePath />
</parent>

<groupId>com.tosan.client.http</groupId>
<artifactId>tosan-httpclient-spring-boot-root</artifactId>
<version>3.1.6-SNAPSHOT</version>
<packaging>pom</packaging>

<name>tosan-httpclient-spring-boot-starter</name>
<description>
This project provides a Spring-Boot Starter that enables the additional configuration of the used
Expand Down Expand Up @@ -81,16 +81,6 @@
<build>
<pluginManagement>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.11.0</version>
<configuration>
<release>${java.version}</release>
<showWarnings>true</showWarnings>
<fork>true</fork>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,6 @@ public HttpStatusCode getStatusCode() throws IOException {
return this.response.getStatusCode();
}

@Override
public int getRawStatusCode() throws IOException {
return this.response.getRawStatusCode();
}

@Override
public String getStatusText() throws IOException {
return this.response.getStatusText();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ protected Response logAndRebufferResponse(String configKey, Level logLevel, Resp
responseData.put("invoked", webServiceName);
int status = response.status();
responseData.put("service", getServiceName(methodTag(configKey)));
responseData.put("duration", elapsedTime + "ms");
responseData.put("duration", elapsedTime / 1000.0 + "s");
responseData.put("status", status);
if (logLevel.ordinal() >= Level.HEADERS.ordinal()) {
if (!response.headers().isEmpty()) {
Expand Down Expand Up @@ -120,7 +120,7 @@ protected IOException logIOException(String configKey, Level logLevel, IOExcepti
Map<String, Object> exceptionData = new LinkedHashMap<>();
exceptionData.put("invoked", webServiceName);
exceptionData.put("service", getServiceName(methodTag(configKey)));
exceptionData.put("duration", elapsedTime + "ms");
exceptionData.put("duration", elapsedTime / 1000.0 + "s");
exceptionData.put("exception", ioe.getClass().getSimpleName());
exceptionData.put("message", ioe.getMessage());
if (logLevel.ordinal() >= Level.FULL.ordinal() && logger.isDebugEnabled()) {
Expand Down Expand Up @@ -183,7 +183,7 @@ private Map<String, Collection<String>> getMaskedHeaders(Map<String, Collection<
Collection<String> headerValues = entry.getValue();
Collection<String> maskedHeaderValues = new ArrayList<>();
headerValues.forEach(headerValue -> {
if (headerValue != null && headerValue.length() > 0) {
if (headerValue != null && !headerValue.isEmpty()) {
JsonReplaceResultDto jsonReplaceResultDto = replaceHelperDecider.checkJsonAndReplace(headerValue);
if (!jsonReplaceResultDto.isJson()) {
maskedHeaderValues.add(replaceHelperDecider.replace(headerName, headerValue));
Expand Down

0 comments on commit 4a51b78

Please sign in to comment.