-
Notifications
You must be signed in to change notification settings - Fork 15
Aerospike Module Storage #184
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
Conversation
a9127ea to
a01b2e3
Compare
| meterForTag(prefix, measurementTag).increment(); | ||
| } | ||
|
|
||
| public MetricsRecorderTimer createRequestTimerForTag(final String prefix) { |
There was a problem hiding this comment.
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"), |
There was a problem hiding this comment.
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); |
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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(); |
There was a problem hiding this comment.
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
| 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.")); |
There was a problem hiding this comment.
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); |
There was a problem hiding this comment.
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
| 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); | ||
| } |
There was a problem hiding this comment.
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) { |
There was a problem hiding this comment.
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
| } 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); | ||
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
switch
| return responseBuilder.error(Mono.just(error), request) | ||
| .doOnNext(response -> handleErrorStatusCodes(request, response)); |
There was a problem hiding this comment.
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
No description provided.