Skip to content

Commit

Permalink
[*] tests
Browse files Browse the repository at this point in the history
  • Loading branch information
alex-karpovich committed Aug 29, 2023
1 parent 27bcca2 commit ad71d9d
Showing 1 changed file with 14 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,8 @@
* License for the specific language governing permissions and limitations under
* the License.
*/
package com.epam.deltix.tbwg.webapp.services;

package com.epam.deltix.tbwg.webapp.services;

import io.micrometer.core.instrument.MeterRegistry;
import io.micrometer.core.instrument.Tag;
Expand All @@ -28,7 +29,7 @@
@Service
public class MetricsService {

private final MeterRegistry meterRegistry;
// private final MeterRegistry meterRegistry;
private final Map<String, Map<String, AtomicLong>> endpointGauges = new ConcurrentHashMap<>();
private final Map<String, AtomicLong> gauges = new ConcurrentHashMap<>();

Expand Down Expand Up @@ -56,27 +57,29 @@ public void decrement() {
}
}

public MetricsService(MeterRegistry meterRegistry) {
this.meterRegistry = meterRegistry;
}
// public MetricsService(MeterRegistry meterRegistry) {
// this.meterRegistry = meterRegistry;
// }

public EndpointCounter endpointCounter(String name, String endpoint) {
return endpoint != null ?
new EndpointCounter(longEndpointGauge(name), longEndpointGauge(name, endpoint)) :
new EndpointCounter(longEndpointGauge(name));
new EndpointCounter(longEndpointGauge(name), longEndpointGauge(name, endpoint)) :
new EndpointCounter(longEndpointGauge(name));
}

public AtomicLong longEndpointGauge(String name) {
return longEndpointGauge(name, "/**");
}

public AtomicLong longEndpointGauge(String name, String endpoint) {
return endpointGauges.computeIfAbsent(name, k -> new ConcurrentHashMap<>())
.computeIfAbsent(endpoint, k -> meterRegistry.gauge(name, List.of(Tag.of("uri", endpoint)), new AtomicLong()));
// return endpointGauges.computeIfAbsent(name, k -> new ConcurrentHashMap<>())
// .computeIfAbsent(endpoint, k -> meterRegistry.gauge(name, List.of(Tag.of("uri", endpoint)), new AtomicLong()));
return new AtomicLong();
}

public AtomicLong longGauge(String name) {
return gauges.computeIfAbsent(name, k -> meterRegistry.gauge(name, new AtomicLong()));
// return gauges.computeIfAbsent(name, k -> meterRegistry.gauge(name, new AtomicLong()));
return new AtomicLong();
}

}
}

0 comments on commit ad71d9d

Please sign in to comment.