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

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

There is a newer version: 5.0.0-rc.1
Show newest version
package io.dropwizard.metrics;

import com.codahale.metrics.CsvReporter;
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.File;

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

* Configuration Parameters: *

* * * * * * * * * * * * * * * * *
NameDefaultDescription
fileNo default. You must define a directory.The directory where the csv metrics will be written. If the * directory does not exist on startup, an attempt will be made to * create it and any parent directories as necessary. If this * operation fails dropwizard will fail on startup, but it may * have succeeded in creating some of the necessary parent * directories.
See {@link BaseFormattedReporterFactory} for more options.
See {@link BaseReporterFactory} for more options.
*/ @JsonTypeName("csv") public class CsvReporterFactory extends BaseFormattedReporterFactory { @NotNull private File file; @JsonProperty public File getFile() { return file; } @JsonProperty public void setFile(File file) { this.file = file; } @Override public ScheduledReporter build(MetricRegistry registry) { final boolean creation = file.mkdirs(); if (!creation && !file.exists()) { throw new RuntimeException("Failed to create" + file.getAbsolutePath()); } return CsvReporter.forRegistry(registry) .convertDurationsTo(getDurationUnit()) .convertRatesTo(getRateUnit()) .filter(getFilter()) .formatFor(getLocale()) .build(getFile()); } }




© 2015 - 2025 Weber Informatics LLC | Privacy Policy