Skip to content

Add Sampling for Logs #151

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

Merged
merged 3 commits into from
Jul 10, 2025
Merged
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
Original file line number Diff line number Diff line change
Expand Up @@ -70,14 +70,12 @@ Mono<ServerResponse> finalizeResult(final Mono<ServerResponse> mono,
private Mono<ServerResponse> handleErrorMetrics(final Throwable error, final ServerRequest request) {
if (error instanceof RepositoryException) {
recordMetric(MeasurementTag.ERROR_DB);
} else if (error instanceof ResourceNotFoundException) {
} else if (error instanceof ResourceNotFoundException || error instanceof BadRequestException) {
conditionalLogger.info(
error.getMessage()
+ ". Refererring URLs: " + request.headers().header(HttpHeaders.REFERER)
+ ". Request URI: " + request.uri(),
samplingRate);
} else if (error instanceof BadRequestException) {
log.error(error.getMessage());
} else if (error instanceof TimeoutException) {
metricsRecorder.markMeterForTag(this.metricTagPrefix, MeasurementTag.ERROR_TIMED_OUT);
} else if (error instanceof DataBufferLimitException) {
Expand All @@ -86,8 +84,9 @@ private Mono<ServerResponse> handleErrorMetrics(final Throwable error, final Ser
"Request length: `" + contentLength + "` exceeds maximum size limit",
samplingRate);
} else {
log.error("Error occurred while processing the request: '{}', cause: '{}'",
ExceptionUtils.getMessage(error), ExceptionUtils.getMessage(error));
conditionalLogger.error("Error occurred while processing the request: '%s', cause: '%s'".formatted(
ExceptionUtils.getMessage(error), ExceptionUtils.getMessage(error)),
samplingRate);
}

return builder.error(Mono.just(error), request)
Expand Down
Loading