Skip to content

Commit

Permalink
Prefer upstream LockFreeExponentiallyDecayingReservoir (#1705)
Browse files Browse the repository at this point in the history
Prefer upstream LockFreeExponentiallyDecayingReservoir
Our changes landed upstream in Dropwizard metrics 4.2.0 via dropwizard/metrics@53419ff and now that we can upgrade, we can now prefer the upstream version and deprecate our version.
  • Loading branch information
schlosna authored Apr 18, 2023
1 parent ae0ce71 commit 4e5ac88
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@
@SuppressWarnings({"designforextension", "NullAway"})
public class ReservoirBenchmarks {

@Param({"EXPO_DECAY", "LOCK_FREE_EXPO_DECAY"})
@Param({"EXPO_DECAY", "LOCK_FREE_EXPO_DECAY", "DW_LOCK_FREE_EXPO_DECAY"})
private ReservoirType reservoirType;

public enum ReservoirType {
Expand All @@ -55,9 +55,18 @@ Reservoir create() {
},
LOCK_FREE_EXPO_DECAY() {
@Override
@SuppressWarnings("deprecation") // explicitly testing
Reservoir create() {
return LockFreeExponentiallyDecayingReservoir.builder().build();
}
},

DW_LOCK_FREE_EXPO_DECAY() {
@Override
Reservoir create() {
return com.codahale.metrics.LockFreeExponentiallyDecayingReservoir.builder()
.build();
}
};

abstract Reservoir create();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
import com.codahale.metrics.Counter;
import com.codahale.metrics.Gauge;
import com.codahale.metrics.Histogram;
import com.codahale.metrics.LockFreeExponentiallyDecayingReservoir;
import com.codahale.metrics.Meter;
import com.codahale.metrics.Metric;
import com.codahale.metrics.MetricFilter;
Expand All @@ -41,7 +42,6 @@
import com.palantir.logsafe.exceptions.SafeIllegalArgumentException;
import com.palantir.logsafe.logger.SafeLogger;
import com.palantir.logsafe.logger.SafeLoggerFactory;
import com.palantir.tritium.metrics.registry.LockFreeExponentiallyDecayingReservoir;
import com.palantir.tritium.metrics.registry.MetricName;
import com.palantir.tritium.metrics.registry.TaggedMetricRegistry;
import java.time.ZoneOffset;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@

package com.palantir.tritium.metrics.registry;

import com.codahale.metrics.LockFreeExponentiallyDecayingReservoir;
import com.google.auto.service.AutoService;

@AutoService(TaggedMetricRegistry.class)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@
import com.codahale.metrics.Snapshot;
import com.codahale.metrics.WeightedSnapshot;
import com.codahale.metrics.WeightedSnapshot.WeightedSample;
import com.google.common.annotations.Beta;
import com.palantir.logsafe.Preconditions;
import com.palantir.logsafe.SafeArg;
import com.palantir.logsafe.exceptions.SafeIllegalArgumentException;
Expand Down Expand Up @@ -55,8 +54,10 @@
*
* See {@link com.codahale.metrics.ExponentiallyDecayingReservoir} Copyright 2010-2012 Coda Hale and Yammer, Inc.
* Licensed under the Apache License, Version 2.0. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
*
* @deprecated prefer upstream {@link com.codahale.metrics.LockFreeExponentiallyDecayingReservoir}.
*/
@Beta
@Deprecated
public final class LockFreeExponentiallyDecayingReservoir implements Reservoir {

private static final double SECONDS_PER_NANO = .000_000_001D;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@
* See {@code ExponentiallyDecayingReservoirTest.java} Licensed under the Apache License, Version 2.0. You may obtain
* a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
*/
@SuppressWarnings("deprecation") // explicitly testing internal version
class LockFreeExponentiallyDecayingReservoirTest {

@Test
Expand Down

0 comments on commit 4e5ac88

Please sign in to comment.