Skip to content

chore: Move user traffic data to trace level #498

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 7 commits into from
Closed
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
2 changes: 1 addition & 1 deletion core/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
<project.rootdir>${project.basedir}/../</project.rootdir>
<coverage.complexity>64%</coverage.complexity>
<coverage.line>78%</coverage.line>
<coverage.instruction>79%</coverage.instruction>
<coverage.instruction>78%</coverage.instruction>
<coverage.branch>60%</coverage.branch>
<coverage.method>77%</coverage.method>
<coverage.class>90%</coverage.class>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ public List<ServiceBinding> getServiceBindings() throws ServiceBindingAccessExce
log.debug("No service key found in environment variable {}", ENV_VAR_KEY);
return List.of();
}
log.info(
log.debug(
"""
Found a service key in environment variable {}.
Using a service key is recommended for local testing only.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -78,11 +78,11 @@ private T parseResponse(@Nonnull final ClassicHttpResponse response) throws E {
throw exceptionConstructor.apply("Response was empty.", null);
}
val content = getContent(responseEntity);
log.debug("Parsing response from JSON response: {}", content);
log.trace("Deserializing JSON response to type {}: {}", responseType.getSimpleName(), content);
try {
return objectMapper.readValue(content, responseType);
} catch (final JsonProcessingException e) {
log.error("Failed to parse the following response: {}", content);
log.debug("Failed to deserialize the response to type: {}", responseType.getSimpleName());
throw exceptionConstructor.apply("Failed to parse response", e);
}
}
Expand All @@ -103,10 +103,10 @@ private String getContent(@Nonnull final HttpEntity entity) {
*/
@SuppressWarnings("PMD.CloseResource")
public void buildExceptionAndThrow(@Nonnull final ClassicHttpResponse response) throws E {
val errorCode = response.getCode();
val exception =
exceptionConstructor.apply(
"Request failed with status %s %s"
.formatted(response.getCode(), response.getReasonPhrase()),
"Request failed with status %s %s".formatted(errorCode, response.getReasonPhrase()),
null);
val entity = response.getEntity();
if (entity == null) {
Expand All @@ -122,7 +122,8 @@ public void buildExceptionAndThrow(@Nonnull final ClassicHttpResponse response)
throw exception;
}

log.error("The service responded with an HTTP error and the following content: {}", content);
log.error("The service responded with HTTP error code {}", errorCode);
log.trace("The service responded with HTTP error code {} and content: {}", errorCode, content);
val contentType = ContentType.parse(entity.getContentType());
if (!ContentType.APPLICATION_JSON.isSameMimeType(contentType)) {
throw exception;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,9 +76,11 @@ public Stream<D> handleStreamingResponse(@Nonnull final ClassicHttpResponse resp
final String data = line.substring(5); // remove "data: "
try {
return objectMapper.readValue(data, responseType);
} catch (final IOException e) { // exception message e gets lost
log.error("Failed to parse the following response: {}", line);
throw exceptionConstructor.apply("Failed to parse delta message: " + line, e);
} catch (final IOException e) {
final String message = e.getMessage();
log.error("Failed to parse the streamed response: " + message);
log.trace("Failed to parse the following response: {}", line);
throw exceptionConstructor.apply("Failed to parse delta message: " + message, e);
}
});
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ <T> T execute(
@Nonnull final Class<T> responseType) {
try {
val json = JACKSON.writeValueAsString(payload);
log.debug("Serialized request into JSON payload: {}", json);
log.trace("Serialized request into JSON payload: {}", json);
val request = new HttpPost(path);
request.setEntity(new StringEntity(json, ContentType.APPLICATION_JSON));

Expand Down