Include request method as a request counter dimension

This commit is contained in:
Jon Chambers
2023-05-09 11:54:10 -04:00
committed by Chris Eager
parent cb72e4f426
commit a83fd1d3fe
2 changed files with 13 additions and 4 deletions

View File

@@ -29,6 +29,9 @@ public class MetricsRequestEventListener implements RequestEventListener {
@VisibleForTesting
static final String PATH_TAG = "path";
@VisibleForTesting
static final String METHOD_TAG = "method";
@VisibleForTesting
static final String STATUS_CODE_TAG = "status";
@@ -52,8 +55,9 @@ public class MetricsRequestEventListener implements RequestEventListener {
public void onEvent(final RequestEvent event) {
if (event.getType() == RequestEvent.Type.FINISHED) {
if (!event.getUriInfo().getMatchedTemplates().isEmpty()) {
final List<Tag> tags = new ArrayList<>(4);
final List<Tag> tags = new ArrayList<>(5);
tags.add(Tag.of(PATH_TAG, UriInfoUtil.getPathTemplate(event.getUriInfo())));
tags.add(Tag.of(METHOD_TAG, event.getContainerRequest().getMethod()));
tags.add(Tag.of(STATUS_CODE_TAG, String.valueOf(event.getContainerResponse().getStatus())));
tags.add(Tag.of(TRAFFIC_SOURCE_TAG, trafficSource.name().toLowerCase()));