Skip to content

Commit

Permalink
Merge branch '1.7.x' into 1.8.x
Browse files Browse the repository at this point in the history
  • Loading branch information
shakuzen committed Mar 17, 2022
2 parents 15fe824 + 5262c0f commit f3b707f
Show file tree
Hide file tree
Showing 24 changed files with 85 additions and 217 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@
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;

public class SpectatorCounter extends AbstractMeter implements Counter {
private com.netflix.spectator.api.Counter counter;
Expand All @@ -37,15 +36,4 @@ public void increment(double amount) {
public double count() {
return counter.count();
}

@SuppressWarnings("EqualsWhichDoesntCheckParameterClass")
@Override
public boolean equals(Object o) {
return MeterEquivalence.equals(this, o);
}

@Override
public int hashCode() {
return MeterEquivalence.hashCode(this);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,6 @@
import io.micrometer.core.instrument.AbstractDistributionSummary;
import io.micrometer.core.instrument.Clock;
import io.micrometer.core.instrument.distribution.DistributionStatisticConfig;
import io.micrometer.core.instrument.util.MeterEquivalence;
import io.micrometer.core.lang.Nullable;

import static java.util.stream.StreamSupport.stream;

Expand Down Expand Up @@ -68,15 +66,4 @@ public double max() {

return Double.NaN;
}

@SuppressWarnings("EqualsWhichDoesntCheckParameterClass")
@Override
public boolean equals(@Nullable Object o) {
return MeterEquivalence.equals(this, o);
}

@Override
public int hashCode() {
return MeterEquivalence.hashCode(this);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@

import io.micrometer.core.instrument.AbstractMeter;
import io.micrometer.core.instrument.Gauge;
import io.micrometer.core.instrument.util.MeterEquivalence;

public class SpectatorGauge extends AbstractMeter implements Gauge {
private com.netflix.spectator.api.Gauge gauge;
Expand All @@ -31,15 +30,4 @@ public class SpectatorGauge extends AbstractMeter implements Gauge {
public double value() {
return gauge.value();
}

@SuppressWarnings("EqualsWhichDoesntCheckParameterClass")
@Override
public boolean equals(Object o) {
return MeterEquivalence.equals(this, o);
}

@Override
public int hashCode() {
return MeterEquivalence.hashCode(this);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@
import io.micrometer.core.instrument.Meter;
import io.micrometer.core.instrument.distribution.DistributionStatisticConfig;
import io.micrometer.core.instrument.internal.DefaultLongTaskTimer;
import io.micrometer.core.instrument.util.MeterEquivalence;
import io.micrometer.core.instrument.util.TimeUtils;

import java.util.concurrent.TimeUnit;
Expand Down Expand Up @@ -49,17 +48,6 @@ public int activeTasks() {
return timer.activeTasks();
}

@SuppressWarnings("EqualsWhichDoesntCheckParameterClass")
@Override
public boolean equals(Object o) {
return MeterEquivalence.equals(this, o);
}

@Override
public int hashCode() {
return MeterEquivalence.hashCode(this);
}

class SpectatorSample extends Sample {
private final Sample delegate;
private final long taskId;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@
import io.micrometer.core.instrument.AbstractDistributionSummary;
import io.micrometer.core.instrument.Clock;
import io.micrometer.core.instrument.distribution.*;
import io.micrometer.core.instrument.util.MeterEquivalence;
import io.micrometer.core.lang.Nullable;

import java.time.Duration;
Expand Down Expand Up @@ -96,17 +95,6 @@ public double max() {
return max.poll();
}

@SuppressWarnings("EqualsWhichDoesntCheckParameterClass")
@Override
public boolean equals(@Nullable Object o) {
return MeterEquivalence.equals(this, o);
}

@Override
public int hashCode() {
return MeterEquivalence.hashCode(this);
}

/**
* For Prometheus we cannot use the histogram counts from HistogramSnapshot, as it is based on a
* rolling histogram. Prometheus requires a histogram that accumulates values over the lifetime of the app.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@
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;

Expand All @@ -39,15 +38,4 @@ public void increment(double amount) {
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);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@
import io.micrometer.core.instrument.AbstractDistributionSummary;
import io.micrometer.core.instrument.Clock;
import io.micrometer.core.instrument.distribution.*;
import io.micrometer.core.instrument.util.MeterEquivalence;
import io.micrometer.core.lang.Nullable;

import java.time.Duration;
Expand Down Expand Up @@ -97,17 +96,6 @@ public HistogramFlavor histogramFlavor() {
return histogramFlavor;
}

@SuppressWarnings("EqualsWhichDoesntCheckParameterClass")
@Override
public boolean equals(@Nullable Object o) {
return MeterEquivalence.equals(this, o);
}

@Override
public int hashCode() {
return MeterEquivalence.hashCode(this);
}

/**
* For Prometheus we cannot use the histogram counts from HistogramSnapshot, as it is based on a
* rolling histogram. Prometheus requires a histogram that accumulates values over the lifetime of the app.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@

import io.micrometer.core.instrument.AbstractMeter;
import io.micrometer.core.instrument.Counter;
import io.micrometer.core.instrument.util.MeterEquivalence;
import reactor.core.publisher.FluxSink;

import java.util.concurrent.atomic.DoubleAdder;
Expand Down Expand Up @@ -50,17 +49,6 @@ 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);
}

void shutdown() {
this.shutdown = true;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,6 @@
import io.micrometer.core.instrument.Clock;
import io.micrometer.core.instrument.distribution.DistributionStatisticConfig;
import io.micrometer.core.instrument.distribution.TimeWindowMax;
import io.micrometer.core.instrument.util.MeterEquivalence;
import io.micrometer.core.lang.Nullable;
import reactor.core.publisher.FluxSink;

import java.util.concurrent.atomic.DoubleAdder;
Expand Down Expand Up @@ -71,17 +69,6 @@ public double max() {
return max.poll();
}

@SuppressWarnings("EqualsWhichDoesntCheckParameterClass")
@Override
public boolean equals(@Nullable Object o) {
return MeterEquivalence.equals(this, o);
}

@Override
public int hashCode() {
return MeterEquivalence.hashCode(this);
}

void shutdown() {
this.shutdown = true;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@

import io.micrometer.core.instrument.AbstractMeter;
import io.micrometer.core.instrument.Gauge;
import io.micrometer.core.instrument.util.MeterEquivalence;
import io.micrometer.core.lang.Nullable;
import reactor.core.publisher.FluxSink;

Expand Down Expand Up @@ -57,15 +56,4 @@ public void poll() {
}
}

@SuppressWarnings("EqualsWhichDoesntCheckParameterClass")
@Override
public boolean equals(Object o) {
return MeterEquivalence.equals(this, o);
}

@Override
public int hashCode() {
return MeterEquivalence.hashCode(this);
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,6 @@
package io.micrometer.core.instrument;

import io.micrometer.core.instrument.distribution.*;
import io.micrometer.core.instrument.util.MeterEquivalence;
import io.micrometer.core.lang.Nullable;

public abstract class AbstractDistributionSummary extends AbstractMeter implements DistributionSummary {
protected final Histogram histogram;
Expand Down Expand Up @@ -56,15 +54,4 @@ public final void record(double amount) {
public HistogramSnapshot takeSnapshot() {
return histogram.takeSnapshot(count(), totalAmount(), max());
}

@SuppressWarnings("EqualsWhichDoesntCheckParameterClass")
@Override
public boolean equals(@Nullable Object o) {
return MeterEquivalence.equals(this, o);
}

@Override
public int hashCode() {
return MeterEquivalence.hashCode(this);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,15 @@
*/
package io.micrometer.core.instrument;

import io.micrometer.core.instrument.util.MeterEquivalence;
import io.micrometer.core.lang.Nullable;

/**
* Base class for {@link Meter} implementations.
*
* @author Jon Schneider
* @author Johnny Lim
*/
public abstract class AbstractMeter implements Meter {
private final Meter.Id id;

Expand All @@ -26,4 +35,15 @@ public AbstractMeter(Id id) {
public Id getId() {
return id;
}

@SuppressWarnings("EqualsWhichDoesntCheckParameterClass")
@Override
public boolean equals(@Nullable Object o) {
return MeterEquivalence.equals(this, o);
}

@Override
public int hashCode() {
return MeterEquivalence.hashCode(this);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@
import io.micrometer.core.instrument.distribution.*;
import io.micrometer.core.instrument.distribution.pause.ClockDriftPauseDetector;
import io.micrometer.core.instrument.distribution.pause.PauseDetector;
import io.micrometer.core.instrument.util.MeterEquivalence;
import io.micrometer.core.lang.Nullable;
import org.LatencyUtils.IntervalEstimator;
import org.LatencyUtils.SimplePauseDetector;
Expand Down Expand Up @@ -188,17 +187,6 @@ public TimeUnit baseTimeUnit() {
return baseTimeUnit;
}

@SuppressWarnings("EqualsWhichDoesntCheckParameterClass")
@Override
public boolean equals(@Nullable Object o) {
return MeterEquivalence.equals(this, o);
}

@Override
public int hashCode() {
return MeterEquivalence.hashCode(this);
}

@Override
public void close() {
histogram.close();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,9 @@
import java.util.Iterator;
import java.util.Map;
import java.util.concurrent.atomic.AtomicBoolean;
import java.util.function.Consumer;

abstract class AbstractCompositeMeter<T extends Meter> extends AbstractMeter implements CompositeMeter {
private AtomicBoolean childrenGuard = new AtomicBoolean();
private final AtomicBoolean childrenGuard = new AtomicBoolean();
private Map<MeterRegistry, T> children = Collections.emptyMap();

@Nullable
Expand All @@ -43,8 +42,8 @@ abstract class AbstractCompositeMeter<T extends Meter> extends AbstractMeter imp
@Nullable
abstract T registerNewMeter(MeterRegistry registry);

final void forEachChild(Consumer<T> task) {
children.values().forEach(task);
final Iterable<T> getChildren() {
return children.values();
}

T firstChild() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,9 @@ class CompositeCounter extends AbstractCompositeMeter<Counter> implements Counte

@Override
public void increment(double amount) {
forEachChild(c -> c.increment(amount));
for (Counter c : getChildren()) {
c.increment(amount);
}
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,9 @@ class CompositeDistributionSummary extends AbstractCompositeMeter<DistributionSu

@Override
public void record(double amount) {
forEachChild(ds -> ds.record(amount));
for (DistributionSummary ds : getChildren()) {
ds.record(amount);
}
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,9 @@ class CompositeLongTaskTimer extends AbstractCompositeMeter<LongTaskTimer> imple
@Override
public Sample start() {
List<Sample> samples = new ArrayList<>();
forEachChild(ltt -> samples.add(ltt.start()));
for (LongTaskTimer ltt : getChildren()) {
samples.add(ltt.start());
}
return new CompositeSample(samples);
}

Expand Down
Loading

0 comments on commit f3b707f

Please sign in to comment.