Skip to content

Commit

Permalink
Add HTTP response to HttpClientMetricsTagsContributor.Context
Browse files Browse the repository at this point in the history
  • Loading branch information
geoand committed Jan 21, 2025
1 parent 9ac63d5 commit bd0b5e1
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import io.micrometer.core.instrument.Tags;
import io.micrometer.core.instrument.config.MeterFilter;
import io.vertx.core.spi.observability.HttpRequest;
import io.vertx.core.spi.observability.HttpResponse;

/**
* Allows code to add additional Micrometer {@link Tags} to the metrics collected for completed HTTP client requests.
Expand All @@ -20,5 +21,7 @@ public interface HttpClientMetricsTagsContributor {

interface Context {
HttpRequest request();

HttpResponse response();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,7 @@ public void responseEnd(RequestTracker tracker, long bytesRead) {
.and(HttpCommonTags.status(tracker.response.statusCode()))
.and(HttpCommonTags.outcome(tracker.response.statusCode()));
if (!httpClientMetricsTagsContributors.isEmpty()) {
HttpClientMetricsTagsContributor.Context context = new DefaultContext(tracker.request);
HttpClientMetricsTagsContributor.Context context = new DefaultContext(tracker.request, tracker.response);
for (int i = 0; i < httpClientMetricsTagsContributors.size(); i++) {
try {
Tags additionalTags = httpClientMetricsTagsContributors.get(i).contribute(context);
Expand Down Expand Up @@ -254,6 +254,7 @@ public String getNormalizedUriPath(Map<Pattern, String> serverMatchPatterns, Lis
}
}

private record DefaultContext(HttpRequest request) implements HttpClientMetricsTagsContributor.Context {
private record DefaultContext(HttpRequest request,
HttpResponse response) implements HttpClientMetricsTagsContributor.Context {
}
}

0 comments on commit bd0b5e1

Please sign in to comment.