All Downloads are FREE. Search and download functionalities are using the official Maven repository.

io.micrometer.prometheus.PrometheusCounter Maven / Gradle / Ivy

Go to download

MeterRegistry implementation for Prometheus using io.prometheus:prometheus-metrics-core. If you have compatibility issues with this module, you can go back to io.micrometer:micrometer-registry-prometheus-simpleclient that uses io.prometheus:simpleclient_common.

There is a newer version: 1.14.2
Show newest version
/**
 * Copyright 2017 Pivotal Software, Inc.
 * 

* Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at *

* http://www.apache.org/licenses/LICENSE-2.0 *

* Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package io.micrometer.prometheus; import io.micrometer.core.instrument.AbstractMeter; import io.micrometer.core.instrument.Counter; import io.micrometer.core.instrument.Meter; import io.micrometer.core.instrument.util.MeterEquivalence; import java.util.concurrent.atomic.DoubleAdder; public class PrometheusCounter extends AbstractMeter implements Counter { private DoubleAdder count = new DoubleAdder(); PrometheusCounter(Meter.Id id) { super(id); } @Override public void increment(double amount) { if(amount > 0) count.add(amount); } @Override public double count() { return count.doubleValue(); } @SuppressWarnings("EqualsWhichDoesntCheckParameterClass") @Override public boolean equals(Object o) { return MeterEquivalence.equals(this, o); } @Override public int hashCode() { return MeterEquivalence.hashCode(this); } }





© 2015 - 2025 Weber Informatics LLC | Privacy Policy