Share common metric dimensions with package-local subclasses
@@ -79,7 +79,7 @@ public abstract class ThreadedRequestHandler extends AbstractRequestHandler {
this.allowAsyncResponse = allowAsyncResponse;
}
- private Metric.Context contextFor(Request request) {
+ Metric.Context contextFor(Request request, Map<String, String> extraDimensions) {
BindingMatch match = request.getBindingMatch();
if (match == null) return null;
UriPattern matched = match.matched();
@@ -97,9 +97,12 @@ public abstract class ThreadedRequestHandler extends AbstractRequestHandler {
dimensions.put("port", Integer.toString(uri.getPort()));
String handlerClassName = getClass().getName();
dimensions.put("handler-name", handlerClassName);
+ dimensions.putAll(extraDimensions);
return this.metric.createContext(dimensions);
}
+ private Metric.Context contextFor(Request request) { return contextFor(request, Map.of()); }
+
/**
* Handles a request by assigning a worker thread to it.
*
