mirror of
https://github.com/jlengrand/helidon.git
synced 2026-03-10 08:21:17 +00:00
Improve metrics interceptor performance; avoid MetricID creations - 2.x (#1602)
* For performance, avoid creating MetricID instances repeatedly when looking up the metric associated with each call to an intercepted call; instead, cache the metric with each annotation site
This commit is contained in:
@@ -473,7 +473,7 @@ public final class MetricsSupport implements Service {
|
||||
.ifPresentOrElse(entry -> {
|
||||
if (req.headers().isAccepted(MediaType.APPLICATION_JSON)) {
|
||||
JsonObjectBuilder builder = JSON.createObjectBuilder();
|
||||
entry.getKey().jsonMeta(builder, entry.getValue());
|
||||
HelidonMetric.class.cast(entry.getKey()).jsonMeta(builder, entry.getValue());
|
||||
res.send(builder.build());
|
||||
} else {
|
||||
res.status(Http.Status.NOT_ACCEPTABLE_406);
|
||||
|
||||
@@ -523,7 +523,7 @@ public class Registry extends MetricRegistry implements io.helidon.common.metric
|
||||
* @param metricName The metric name.
|
||||
* @return Optional map entry..
|
||||
*/
|
||||
synchronized Optional<Map.Entry<HelidonMetric, List<MetricID>>> getOptionalMetricWithIDsEntry(String metricName) {
|
||||
public synchronized Optional<Map.Entry<? extends Metric, List<MetricID>>> getOptionalMetricWithIDsEntry(String metricName) {
|
||||
final List<MetricID> metricIDs = allMetricIDsByName.get(metricName);
|
||||
if (metricIDs == null || metricIDs.isEmpty()) {
|
||||
return Optional.empty();
|
||||
|
||||
Reference in New Issue
Block a user