Skip to content

Conversation

@AntoxaAntoxic
Copy link
Collaborator

No description provided.

@AntoxaAntoxic AntoxaAntoxic force-pushed the aerospike-module-storage branch from a9127ea to a01b2e3 Compare August 19, 2025 09:17
meterForTag(prefix, measurementTag).increment();
}

public MetricsRecorderTimer createRequestTimerForTag(final String prefix) {
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

choose one of these two createRequestTimerForTag and createRequestTimerForServiceType and use it everywhere it's needed

TEXT("pbc.${prefix}.text"),
XML("pbc.${prefix}.xml"),
ERROR_SECONDARY_WRITE("pbc.err.secondaryWrite"),
ERROR_EXISTING_ID("pbc.err.existingId"),
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

mark ERROR_EXISTING_ID as deprecated

return ServerResponse.status(HttpStatus.UNAUTHORIZED).build();
}

metricsRecorder.recordMetric(MeasurementTag.REQUEST);
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it's better to log this metric right before the moduleRepository.save call because it might be the case when the body is empty and it should be MeasurementTag.ERROR_BAD_REQUEST instead

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@AntoxaAntoxic It depends on whether we want to count all requests or only valid ones

}

metricsRecorder.recordMetric(MeasurementTag.REQUEST);
final var timerContext = metricsRecorder.createRequestTimer();
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

replace var with class name

Comment on lines +78 to +89
if (wrapper.getPayload().getType().equals(PayloadType.JSON.toString())) {
metricsRecorder.recordMetric(MeasurementTag.JSON);
return ServerResponse.ok().body(fromValue(wrapper.getPayload()));
} else if (wrapper.getPayload().getType().equals(PayloadType.XML.toString())) {
metricsRecorder.recordMetric(MeasurementTag.XML);
return ServerResponse.ok().body(fromValue(wrapper.getPayload()));
} else if (wrapper.getPayload().getType().equals(PayloadType.TEXT.toString())) {
metricsRecorder.recordMetric(MeasurementTag.TEXT);
return ServerResponse.ok().body(fromValue(wrapper.getPayload()));
}

return Mono.error(new UnsupportedMediaTypeException("Unsupported Media Type."));
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

switch operator?

return ServerResponse.status(HttpStatus.UNAUTHORIZED).build();
}

metricsRecorder.recordMetric(MeasurementTag.REQUEST);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@AntoxaAntoxic It depends on whether we want to count all requests or only valid ones

Comment on lines +27 to +37
if (error instanceof DuplicateKeyException) {
recordMetric(MeasurementTag.ERROR_DUPLICATE_KEY);
} else if (error instanceof RepositoryException) {
recordMetric(MeasurementTag.ERROR_DB);
} else if (error instanceof ResourceNotFoundException || error instanceof BadRequestException) {
recordMetric(MeasurementTag.ERROR_BAD_REQUEST);
} else if (error instanceof TimeoutException) {
recordMetric(MeasurementTag.ERROR_TIMED_OUT);
} else {
recordMetric(MeasurementTag.ERROR_UNKNOWN);
}
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

switch operator, if we are using java 21+

private final MetricsRecorder metricsRecorder;
private final String prefix;

public Mono<ServerResponse> handleErrorMetrics(final Throwable error, final ServerRequest request) {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

remove final modifiers from method params, also check for other occurrences

Comment on lines +47 to +53
} else if (response.statusCode() == HttpStatus.INTERNAL_SERVER_ERROR) {
recordMetric(MeasurementTag.ERROR_UNKNOWN);
} else if (response.statusCode() == HttpStatus.BAD_REQUEST) {
recordMetric(MeasurementTag.ERROR_BAD_REQUEST);
} else if (response.statusCode() == HttpStatus.NOT_FOUND) {
recordMetric(MeasurementTag.ERROR_MISSING_ID);
}
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

switch

Comment on lines +39 to +40
return responseBuilder.error(Mono.just(error), request)
.doOnNext(response -> handleErrorStatusCodes(request, response));
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't like an idea to "hide" response construction in some cases inside StorageMetricsRecorder

@And1sS And1sS closed this Sep 24, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants