Skip to content

Commit

Permalink
Fixed a small bug in StorageForwarder metrics where expiry headers de…
Browse files Browse the repository at this point in the history
…fined in the routing rule where ignored.
  • Loading branch information
mcweba committed Feb 28, 2025
1 parent 0744c1a commit 799ac0e
Showing 1 changed file with 5 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
import io.vertx.core.eventbus.EventBus;
import io.vertx.core.eventbus.Message;
import io.vertx.core.http.HttpMethod;
import io.vertx.core.http.HttpServerRequest;
import io.vertx.core.http.HttpServerResponse;
import io.vertx.core.http.impl.headers.HeadersMultiMap;
import io.vertx.core.json.JsonArray;
Expand Down Expand Up @@ -119,8 +118,6 @@ public void handle(final RoutingContext ctx) {
timerSample = Timer.start(meterRegistry);
}

handleStorageWriteMetrics(ctx.request());

if (monitoringHandler != null) {
monitoringHandler.updateRequestsMeter("localhost", ctx.request().uri());
monitoringHandler.updateRequestPerRuleMonitoring(ctx.request(), rule.getMetricName());
Expand All @@ -142,6 +139,7 @@ public void handle(final RoutingContext ctx) {
}

setUniqueIdHeader(requestHeaders);
handleStorageWriteMetrics(ctx.request().method(), requestHeaders);

final Buffer header = Buffer.buffer(new HttpRequest(ctx.request().method(), targetUri, requestHeaders, null).toJsonObject().encode());
final Buffer requestBuffer = Buffer.buffer();
Expand Down Expand Up @@ -227,12 +225,11 @@ public void handle(final RoutingContext ctx) {
}));
}

private void handleStorageWriteMetrics(HttpServerRequest request) {
if (request.method() != HttpMethod.PUT) {
return;
private void handleStorageWriteMetrics(HttpMethod method, MultiMap headers) {
if (method == HttpMethod.PUT) {
Integer expiry = ExpiryCheckHandler.getExpireAfter(headers);
incrementStorageWrite(expiry != null);
}
Integer expiry = ExpiryCheckHandler.getExpireAfter(request.headers());
incrementStorageWrite(expiry != null);
}

private void incrementStorageWrite(boolean withExpiry) {
Expand Down

0 comments on commit 799ac0e

Please sign in to comment.