Skip to content

Commit

Permalink
fix micrometer test
Browse files Browse the repository at this point in the history
  • Loading branch information
brharrington committed Oct 21, 2023
1 parent dbbc885 commit ad6ec53
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -44,12 +44,14 @@
public final class MicrometerRegistry implements Registry {

private final MeterRegistry impl;
private final Clock clock;

private final ConcurrentHashMap<Id, Object> state = new ConcurrentHashMap<>();

/** Create a new instance. */
public MicrometerRegistry(MeterRegistry impl) {
this.impl = impl;
this.clock = new MicrometerClock(impl.config().clock());
}

private io.micrometer.core.instrument.Tag convert(Tag t) {
Expand Down Expand Up @@ -88,7 +90,7 @@ private Meter convert(io.micrometer.core.instrument.Meter meter) {
}

@Override public Clock clock() {
return new MicrometerClock(impl.config().clock());
return clock;
}

@Override public Id createId(String name) {
Expand Down Expand Up @@ -116,7 +118,7 @@ private Meter convert(io.micrometer.core.instrument.Meter meter) {
}

@Override public Timer timer(Id id) {
return new MicrometerTimer(id, impl.timer(id.name(), convert(id.tags())));
return new MicrometerTimer(id, impl.timer(id.name(), convert(id.tags())), clock);
}

@Override public Gauge gauge(Id id) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
*/
package com.netflix.spectator.micrometer;

import com.netflix.spectator.api.Clock;
import com.netflix.spectator.api.Id;
import com.netflix.spectator.api.Measurement;
import com.netflix.spectator.api.Timer;
Expand All @@ -27,11 +28,17 @@
class MicrometerTimer extends MicrometerMeter implements Timer {

private final io.micrometer.core.instrument.Timer impl;
private final Clock clock;

/** Create a new instance. */
MicrometerTimer(Id id, io.micrometer.core.instrument.Timer impl) {
MicrometerTimer(Id id, io.micrometer.core.instrument.Timer impl, Clock clock) {
super(id);
this.impl = impl;
this.clock = clock;
}

@Override public Clock clock() {
return clock;
}

@Override public void record(long amount, TimeUnit unit) {
Expand Down

0 comments on commit ad6ec53

Please sign in to comment.