in components-starter/camel-micrometer-starter/src/main/java/org/apache/camel/component/micrometer/springboot/MicrometerTagsAutoConfiguration.java [48:89]
ServerRequestObservationConvention serverRequestObservationConvention(Optional<CamelServlet> servlet,
CamelMetricsConfiguration configuration) {
return new DefaultServerRequestObservationConvention() {
@Override
public KeyValues getLowCardinalityKeyValues(ServerRequestObservationContext context) {
// here, we just want to have an additional KeyValue to the observation, keeping the default values
return super.getLowCardinalityKeyValues(context).and(custom(context));
}
protected KeyValue custom(ServerRequestObservationContext context) {
HttpServletRequest request = context.getCarrier();
String uri = null;
if (servlet.isPresent() && !configuration.isUriTagDynamic()) {
HttpConsumer consumer = servlet.get().getServletResolveConsumerStrategy().resolve(request,
servlet.get().getConsumers());
if (consumer != null) {
uri = consumer.getPath();
}
}
// the request may not be for camel servlet, so we need to capture uri from request
if (uri == null || uri.isEmpty()) {
// dynamic uri with the actual value from the http request
uri = request.getServletPath();
if (uri == null || uri.isEmpty()) {
uri = request.getPathInfo();
} else {
String p = request.getPathInfo();
if (p != null) {
uri = uri + p;
}
}
}
if (uri == null) {
uri = "";
}
return KeyValue.of("uri", uri);
}
};
}