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

com.flozano.metrics.client.log.NonRepeatingGaugeLogMetricsClient Maven / Gradle / Ivy

The newest version!
package com.flozano.metrics.client.log;

import static java.util.Objects.requireNonNull;

import java.util.function.BiFunction;

import org.slf4j.Logger;

import com.flozano.metrics.client.GaugeValue;
import com.flozano.metrics.client.MetricValue;

public class NonRepeatingGaugeLogMetricsClient extends LogMetricsClient {
	private BiFunction valuesHolder;

	public NonRepeatingGaugeLogMetricsClient(Logger logger, BiFunction valuesHolder) {
		super(logger);
		this.valuesHolder = requireNonNull(valuesHolder);
	}

	@Override
	protected void apply(MetricValue m, String key, String value) {
		assert value != null;
		if ((m instanceof GaugeValue) && skipLog(key, value)) {
			return;
		}
		super.apply(m, key, value);

	}

	private boolean skipLog(String key, String value) {
		return value.equals(valuesHolder.apply(key, value));
	}

}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy