// Copyright 2021 The Terasology Foundation
// SPDX-License-Identifier: Apache-2.0

package org.terasology.engine.monitoring;

import io.micrometer.core.instrument.Clock;
import io.micrometer.core.instrument.step.StepMeterRegistry;
import io.micrometer.core.instrument.step.StepRegistryConfig;

import java.time.Duration;
import java.util.concurrent.TimeUnit;

public class DisplayMetricsMonitor extends StepMeterRegistry {
    public static final DisplayMetricsMonitor metricRegistry = new DisplayMetricsMonitor();
    public static final Duration captureDuration = Duration.ofSeconds(1);

    public DisplayMetricsMonitor() {
        // micrometer doesn't provide concrete implementations of these Config classes.
        // We don't need to vary this configuration or load it from an external source,
        // so we define it using an anonymous class here.
        super(new StepRegistryConfig() {
            @Override
            public String prefix() {
                return "display";
            }

            @Override
            public String get(String key) {
                return null;
            }

            @Override
            public Duration step() {
                return captureDuration;
            }
        }, Clock.SYSTEM);
    }

    @Override
    protected void publish() {
        // We don't need to push records anywhere. The view polls the current values; past steps are discarded.
    }

    @Override
    protected TimeUnit getBaseTimeUnit() {
        return TimeUnit.MILLISECONDS;
    }
}

@@ -205,30 +205,31 @@
 ent.
-step.StepMeter
+logging.Logging
 Registry
 ;%0Aim
@@ -224,16 +224,22 @@
 Registry
+Config
 ;%0Aimport
@@ -274,32 +274,37 @@
 nt.step.Step
+Meter
 Registry
 Config;%0A%0Aimp
@@ -291,22 +291,16 @@
 Registry
-Config
 ;%0A%0Aimpor
@@ -639,382 +639,43 @@
     
-// micrometer doesn't provide concrete implementations of these Config classes.%0A        // We don't need to vary this configuration or load it from an external source,%0A        // so we define it using an anonymous class here.%0A        super(new StepRegistryConfig() %7B%0A            @Override%0A            public String prefix() %7B%0A                return %22display%22;%0A            %7D%0A
+super(new LoggingRegistryConfig() %7B
 %0A   
@@ -976,119 +976,8 @@
 ) %7B%0A
-        // We don't need to push records anywhere. The view polls the current values; past steps are discarded.
 %0A   

Revert "doc(DisplayMetricsMonitor): comments on use of micrometer interfaces"