Merge pull request #6379 from Adrian Cole
* gh-6379: Improves metrics performance by not guarding map.get
This commit is contained in:
commit
8319291efd
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright 2012-2015 the original author or authors.
|
||||
* Copyright 2012-2016 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
|
|
@ -58,8 +58,9 @@ public class BufferCounterService implements CounterService {
|
|||
}
|
||||
|
||||
private String wrap(String metricName) {
|
||||
if (this.names.containsKey(metricName)) {
|
||||
return this.names.get(metricName);
|
||||
String cached = this.names.get(metricName);
|
||||
if (cached != null) {
|
||||
return cached;
|
||||
}
|
||||
if (metricName.startsWith("counter") || metricName.startsWith("meter")) {
|
||||
return metricName;
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright 2012-2015 the original author or authors.
|
||||
* Copyright 2012-2016 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
|
|
@ -128,8 +128,9 @@ public class DropwizardMetricServices implements CounterService, GaugeService {
|
|||
}
|
||||
|
||||
private String wrapName(String metricName, String prefix) {
|
||||
if (this.names.containsKey(metricName)) {
|
||||
return this.names.get(metricName);
|
||||
String cached = this.names.get(metricName);
|
||||
if (cached != null) {
|
||||
return cached;
|
||||
}
|
||||
if (metricName.startsWith(prefix)) {
|
||||
return metricName;
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright 2012-2015 the original author or authors.
|
||||
* Copyright 2012-2016 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
|
|
@ -55,8 +55,9 @@ public class DefaultCounterService implements CounterService {
|
|||
}
|
||||
|
||||
private String wrap(String metricName) {
|
||||
if (this.names.containsKey(metricName)) {
|
||||
return this.names.get(metricName);
|
||||
String cached = this.names.get(metricName);
|
||||
if (cached != null) {
|
||||
return cached;
|
||||
}
|
||||
if (metricName.startsWith("counter.") || metricName.startsWith("meter.")) {
|
||||
return metricName;
|
||||
|
|
|
|||
Loading…
Reference in New Issue