From ad6ec53683ca34abc387b2ab59257798fe142a9d Mon Sep 17 00:00:00 2001 From: Brian Harrington Date: Fri, 20 Oct 2023 21:05:46 -0500 Subject: [PATCH] fix micrometer test --- .../netflix/spectator/micrometer/MicrometerRegistry.java | 6 ++++-- .../netflix/spectator/micrometer/MicrometerTimer.java | 9 ++++++++- 2 files changed, 12 insertions(+), 3 deletions(-) diff --git a/spectator-reg-micrometer/src/main/java/com/netflix/spectator/micrometer/MicrometerRegistry.java b/spectator-reg-micrometer/src/main/java/com/netflix/spectator/micrometer/MicrometerRegistry.java index b29ff0c43..289b13f9b 100644 --- a/spectator-reg-micrometer/src/main/java/com/netflix/spectator/micrometer/MicrometerRegistry.java +++ b/spectator-reg-micrometer/src/main/java/com/netflix/spectator/micrometer/MicrometerRegistry.java @@ -44,12 +44,14 @@ public final class MicrometerRegistry implements Registry { private final MeterRegistry impl; + private final Clock clock; private final ConcurrentHashMap 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) { @@ -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) { @@ -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) { diff --git a/spectator-reg-micrometer/src/main/java/com/netflix/spectator/micrometer/MicrometerTimer.java b/spectator-reg-micrometer/src/main/java/com/netflix/spectator/micrometer/MicrometerTimer.java index ceb1e8c24..db459fbe6 100644 --- a/spectator-reg-micrometer/src/main/java/com/netflix/spectator/micrometer/MicrometerTimer.java +++ b/spectator-reg-micrometer/src/main/java/com/netflix/spectator/micrometer/MicrometerTimer.java @@ -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; @@ -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) {