Skip to content

Commit

Permalink
Remove deprecated code about reporting metrics in single csv file
Browse files Browse the repository at this point in the history
  • Loading branch information
davidegrohmann committed Dec 9, 2015
1 parent a0f45fa commit fdac7ca
Show file tree
Hide file tree
Showing 9 changed files with 37 additions and 481 deletions.
1 change: 0 additions & 1 deletion enterprise/metrics/src/docs/ops/metrics.asciidoc
Expand Up @@ -69,7 +69,6 @@ For storing metrics in local CSV files add the following settings to _neo4j.prop
---- ----
metrics.csv.enabled=true // default is 'false' metrics.csv.enabled=true // default is 'false'
metrics.csv.path=<file or directory path, defaults to "metrics/" in the store directory> metrics.csv.path=<file or directory path, defaults to "metrics/" in the store directory>
metrics.csv.file=<single/split, if split then each metric gets its own file in given directory>
metrics.csv.interval=<how often to store data, defaults to 3s> metrics.csv.interval=<how often to store data, defaults to 3s>
---- ----


Expand Down
Expand Up @@ -35,12 +35,6 @@
@Description( "Metrics settings" ) @Description( "Metrics settings" )
public class MetricsSettings public class MetricsSettings
{ {
public enum CsvFile
{
single, // Use a single file for all metrics, with one metric per column
split // Use one file per metric
}

// Common settings // Common settings
@Description( "A common prefix for the reported metrics field names. By default, this is either be 'neo4j', " + @Description( "A common prefix for the reported metrics field names. By default, this is either be 'neo4j', " +
"or a computed value based on the cluster and instance names, when running in an HA configuration." ) "or a computed value based on the cluster and instance names, when running in an HA configuration." )
Expand Down Expand Up @@ -97,20 +91,11 @@ public enum CsvFile
// CSV settings // CSV settings
@Description( "Set to `true` to enable exporting metrics to CSV files" ) @Description( "Set to `true` to enable exporting metrics to CSV files" )
public static Setting<Boolean> csvEnabled = setting( "metrics.csv.enabled", Settings.BOOLEAN, Settings.FALSE ); public static Setting<Boolean> csvEnabled = setting( "metrics.csv.enabled", Settings.BOOLEAN, Settings.FALSE );
@Description( "The target location of the CSV files. Depending on the metrics.csv.file setting, this is either " + @Description( "The target location of the CSV files: a path to a directory wherein a CSV file per reported " +
"the path to an individual CSV file, that have each of the reported metrics fields as columns, or " + "field will be written. Relative paths will be interpreted relative to the configured Neo4j " +
"it is a path to a directory wherein a CSV file per reported field will be written. Relative paths " + "store directory." )
"will be intepreted relative to the configured Neo4j store directory." )
public static Setting<File> csvPath = setting( "metrics.csv.path", Settings.PATH, Settings.NO_DEFAULT ); public static Setting<File> csvPath = setting( "metrics.csv.path", Settings.PATH, Settings.NO_DEFAULT );


@Deprecated
@Obsoleted( "This setting will be removed in the next major release." )
@Description( "Write to a single CSV file or to multiple files. " +
"Set to `single` (the default) for reporting the metrics in a single CSV file (given by " +
"metrics.csv.path), with a column per metrics field. Or set to `split` to produce a CSV file for " +
"each metrics field, in a directory given by metrics.csv.path." )
public static Setting<CsvFile> csvFile = setting(
"metrics.csv.file", Settings.options( CsvFile.class ), CsvFile.single.name() );
@Description( "The reporting interval for the CSV files. That is, how often new rows with numbers are appended to " + @Description( "The reporting interval for the CSV files. That is, how often new rows with numbers are appended to " +
"the CSV files." ) "the CSV files." )
public static Setting<Long> csvInterval = setting( "metrics.csv.interval", Settings.DURATION, "3s" ); public static Setting<Long> csvInterval = setting( "metrics.csv.interval", Settings.DURATION, "3s" );
Expand Down
Expand Up @@ -32,7 +32,6 @@
import org.neo4j.kernel.impl.spi.KernelContext; import org.neo4j.kernel.impl.spi.KernelContext;
import org.neo4j.kernel.lifecycle.LifecycleAdapter; import org.neo4j.kernel.lifecycle.LifecycleAdapter;
import org.neo4j.logging.Log; import org.neo4j.logging.Log;
import org.neo4j.metrics.MetricsSettings;


import static org.neo4j.kernel.configuration.Config.absoluteFileOrRelativeTo; import static org.neo4j.kernel.configuration.Config.absoluteFileOrRelativeTo;
import static org.neo4j.metrics.MetricsSettings.csvEnabled; import static org.neo4j.metrics.MetricsSettings.csvEnabled;
Expand All @@ -46,7 +45,7 @@ public class CsvOutput extends LifecycleAdapter
private final Log logger; private final Log logger;
private final KernelContext kernelContext; private final KernelContext kernelContext;
private ScheduledReporter csvReporter; private ScheduledReporter csvReporter;
private File outputFile; private File outputPath;


public CsvOutput( Config config, MetricRegistry registry, Log logger, KernelContext kernelContext ) public CsvOutput( Config config, MetricRegistry registry, Log logger, KernelContext kernelContext )
{ {
Expand All @@ -66,29 +65,14 @@ public void init()
if ( configuredPath == null ) if ( configuredPath == null )
{ {
throw new IllegalArgumentException( csvPath.name() + " configuration is required since " + throw new IllegalArgumentException( csvPath.name() + " configuration is required since " +
csvEnabled.name() + " is enabled" ); csvEnabled.name() + " is enabled" );
}
outputFile = absoluteFileOrRelativeTo( kernelContext.storeDir(), configuredPath );
MetricsSettings.CsvFile csvFile = config.get( MetricsSettings.csvFile );
switch ( csvFile )
{
case single:
csvReporter = CsvReporterSingle.forRegistry( registry )
.convertRatesTo( TimeUnit.SECONDS )
.convertDurationsTo( TimeUnit.MILLISECONDS )
.filter( MetricFilter.ALL )
.build( outputFile );
break;
case split:
csvReporter = CsvReporter.forRegistry( registry )
.convertRatesTo( TimeUnit.SECONDS )
.convertDurationsTo( TimeUnit.MILLISECONDS )
.filter( MetricFilter.ALL )
.build( ensureDirectoryExists( outputFile ) );
break;
default: throw new IllegalArgumentException(
"Unsupported " + MetricsSettings.csvFile.name() + " setting: " + csvFile );
} }
outputPath = absoluteFileOrRelativeTo( kernelContext.storeDir(), configuredPath );
csvReporter = CsvReporter.forRegistry( registry )
.convertRatesTo( TimeUnit.SECONDS )
.convertDurationsTo( TimeUnit.MILLISECONDS )
.filter( MetricFilter.ALL )
.build( ensureDirectoryExists( outputPath ) );
} }
} }


Expand Down Expand Up @@ -117,7 +101,7 @@ public void start()
if ( csvReporter != null ) if ( csvReporter != null )
{ {
csvReporter.start( config.get( csvInterval ), TimeUnit.MILLISECONDS ); csvReporter.start( config.get( csvInterval ), TimeUnit.MILLISECONDS );
logger.info( "Sending metrics to CSV file at " + outputFile ); logger.info( "Sending metrics to CSV file at " + outputPath );
} }
} }


Expand Down

0 comments on commit fdac7ca

Please sign in to comment.