All Downloads are FREE. Search and download functionalities are using the official Maven repository.

io.dropwizard.metrics.ConsoleReporterFactory Maven / Gradle / Ivy

There is a newer version: 0.40.13
Show newest version
package io.dropwizard.metrics;

import com.codahale.metrics.ConsoleReporter;
import com.codahale.metrics.MetricRegistry;
import com.codahale.metrics.ScheduledReporter;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.annotation.JsonTypeName;

import javax.validation.constraints.NotNull;
import java.io.PrintStream;
import java.util.TimeZone;

/**
 * A factory for configuring and building {@link ConsoleReporter} instances.
 * 

* Configuration Parameters: *

* * * * * * * * * * * * * * * * * * * * * *
NameDefaultDescription
timeZoneUTCThe timezone to display dates/times for.
outputstdoutThe stream to write to. One of {@code stdout} or {@code stderr}.
See {@link BaseFormattedReporterFactory} for more options.
See {@link BaseReporterFactory} for more options.
*/ @JsonTypeName("console") public class ConsoleReporterFactory extends BaseFormattedReporterFactory { @SuppressWarnings("UnusedDeclaration") public enum ConsoleStream { STDOUT(System.out), STDERR(System.err); private final PrintStream printStream; ConsoleStream(PrintStream printStream) { this.printStream = printStream; } public PrintStream get() { return printStream; } } @NotNull private TimeZone timeZone = TimeZone.getTimeZone("UTC"); @NotNull private ConsoleStream output = ConsoleStream.STDOUT; @JsonProperty public TimeZone getTimeZone() { return timeZone; } @JsonProperty public void setTimeZone(TimeZone timeZone) { this.timeZone = timeZone; } @JsonProperty public ConsoleStream getOutput() { return output; } @JsonProperty public void setOutput(ConsoleStream stream) { this.output = stream; } public ScheduledReporter build(MetricRegistry registry) { return ConsoleReporter.forRegistry(registry) .convertDurationsTo(getDurationUnit()) .convertRatesTo(getRateUnit()) .filter(getFilter()) .formattedFor(getLocale()) .formattedFor(getTimeZone()) .outputTo(getOutput().get()) .build(); } }




© 2015 - 2025 Weber Informatics LLC | Privacy Policy