From fdac7cac4819dc162a5385d609d1e2f9bec74726 Mon Sep 17 00:00:00 2001 From: Davide Grohmann Date: Tue, 10 Nov 2015 16:58:07 +0100 Subject: [PATCH] Remove deprecated code about reporting metrics in single csv file --- .../metrics/src/docs/ops/metrics.asciidoc | 1 - .../org/neo4j/metrics/MetricsSettings.java | 21 +- .../org/neo4j/metrics/output/CsvOutput.java | 34 +- .../metrics/output/CsvReporterSingle.java | 415 ------------------ .../metrics/source/CheckPointingMetrics.java | 3 +- .../neo4j/metrics/source/ClusterMetrics.java | 1 + .../org/neo4j/metrics/source/JvmMetrics.java | 13 +- .../neo4j/metrics/source/NetworkMetrics.java | 1 + .../MetricsKernelExtensionFactoryIT.java | 29 +- 9 files changed, 37 insertions(+), 481 deletions(-) delete mode 100644 enterprise/metrics/src/main/java/org/neo4j/metrics/output/CsvReporterSingle.java diff --git a/enterprise/metrics/src/docs/ops/metrics.asciidoc b/enterprise/metrics/src/docs/ops/metrics.asciidoc index b70301c612766..194a06805f689 100644 --- a/enterprise/metrics/src/docs/ops/metrics.asciidoc +++ b/enterprise/metrics/src/docs/ops/metrics.asciidoc @@ -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.path= -metrics.csv.file= metrics.csv.interval= ---- diff --git a/enterprise/metrics/src/main/java/org/neo4j/metrics/MetricsSettings.java b/enterprise/metrics/src/main/java/org/neo4j/metrics/MetricsSettings.java index 634fa319dfd05..5d6d94975510d 100644 --- a/enterprise/metrics/src/main/java/org/neo4j/metrics/MetricsSettings.java +++ b/enterprise/metrics/src/main/java/org/neo4j/metrics/MetricsSettings.java @@ -35,12 +35,6 @@ @Description( "Metrics settings" ) 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 @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." ) @@ -97,20 +91,11 @@ public enum CsvFile // CSV settings @Description( "Set to `true` to enable exporting metrics to CSV files" ) public static Setting 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 " + - "the path to an individual CSV file, that have each of the reported metrics fields as columns, or " + - "it is a path to a directory wherein a CSV file per reported field will be written. Relative paths " + - "will be intepreted relative to the configured Neo4j store directory." ) + @Description( "The target location of the CSV files: a path to a directory wherein a CSV file per reported " + + "field will be written. Relative paths will be interpreted relative to the configured Neo4j " + + "store directory." ) public static Setting 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 = 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 " + "the CSV files." ) public static Setting csvInterval = setting( "metrics.csv.interval", Settings.DURATION, "3s" ); diff --git a/enterprise/metrics/src/main/java/org/neo4j/metrics/output/CsvOutput.java b/enterprise/metrics/src/main/java/org/neo4j/metrics/output/CsvOutput.java index 611986555d21e..c53eefab21baf 100644 --- a/enterprise/metrics/src/main/java/org/neo4j/metrics/output/CsvOutput.java +++ b/enterprise/metrics/src/main/java/org/neo4j/metrics/output/CsvOutput.java @@ -32,7 +32,6 @@ import org.neo4j.kernel.impl.spi.KernelContext; import org.neo4j.kernel.lifecycle.LifecycleAdapter; import org.neo4j.logging.Log; -import org.neo4j.metrics.MetricsSettings; import static org.neo4j.kernel.configuration.Config.absoluteFileOrRelativeTo; import static org.neo4j.metrics.MetricsSettings.csvEnabled; @@ -46,7 +45,7 @@ public class CsvOutput extends LifecycleAdapter private final Log logger; private final KernelContext kernelContext; private ScheduledReporter csvReporter; - private File outputFile; + private File outputPath; public CsvOutput( Config config, MetricRegistry registry, Log logger, KernelContext kernelContext ) { @@ -66,29 +65,14 @@ public void init() if ( configuredPath == null ) { throw new IllegalArgumentException( csvPath.name() + " configuration is required since " + - 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 ); + csvEnabled.name() + " is enabled" ); } + outputPath = absoluteFileOrRelativeTo( kernelContext.storeDir(), configuredPath ); + csvReporter = CsvReporter.forRegistry( registry ) + .convertRatesTo( TimeUnit.SECONDS ) + .convertDurationsTo( TimeUnit.MILLISECONDS ) + .filter( MetricFilter.ALL ) + .build( ensureDirectoryExists( outputPath ) ); } } @@ -117,7 +101,7 @@ public void start() if ( csvReporter != null ) { 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 ); } } diff --git a/enterprise/metrics/src/main/java/org/neo4j/metrics/output/CsvReporterSingle.java b/enterprise/metrics/src/main/java/org/neo4j/metrics/output/CsvReporterSingle.java deleted file mode 100644 index 433ed7d8ed4dc..0000000000000 --- a/enterprise/metrics/src/main/java/org/neo4j/metrics/output/CsvReporterSingle.java +++ /dev/null @@ -1,415 +0,0 @@ -/* - * Copyright (c) 2002-2015 "Neo Technology," - * Network Engine for Objects in Lund AB [http://neotechnology.com] - * - * This file is part of Neo4j. - * - * Neo4j is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as - * published by the Free Software Foundation, either version 3 of the - * License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - */ -package org.neo4j.metrics.output; - -import com.codahale.metrics.Clock; -import com.codahale.metrics.Counter; -import com.codahale.metrics.Gauge; -import com.codahale.metrics.Histogram; -import com.codahale.metrics.Meter; -import com.codahale.metrics.MetricFilter; -import com.codahale.metrics.MetricRegistry; -import com.codahale.metrics.ScheduledReporter; -import com.codahale.metrics.Snapshot; -import com.codahale.metrics.Timer; - -import java.io.File; -import java.io.IOException; -import java.io.PrintWriter; -import java.nio.charset.StandardCharsets; -import java.text.SimpleDateFormat; -import java.util.Date; -import java.util.Map; -import java.util.SortedMap; -import java.util.concurrent.TimeUnit; - -import org.neo4j.logging.Log; - -import static java.lang.String.format; - -/** - * Version of CSV reporter that logs all metrics into a single file. - * Restriction is that all metrics must be set up before starting it, - * as it cannot handle changing sets of metrics at runtime. - * - * @deprecated please use {@code com.codahale.metrics.CsvReporter} instead. This reporter is incompatible with the - * event based reporting that will be introduced in the next major release, hence it will be removed. - */ -@Deprecated -public class CsvReporterSingle extends ScheduledReporter -{ - // CSV separator - public static final char SEPARATOR = ','; - - /** - * Returns a new {@link Builder} for {@link CsvReporterSingle}. - * - * @param registry the registry to report - * @return a {@link Builder} instance for a {@link CsvReporterSingle} - */ - public static Builder forRegistry( MetricRegistry registry ) - { - return new Builder( registry ); - } - - /** - * A builder for {@link CsvReporterSingle} instances. Defaults to using the default locale, converting - * rates to events/second, converting durations to milliseconds, and not filtering metrics. - */ - public static class Builder - { - private final MetricRegistry registry; - private TimeUnit rateUnit; - private TimeUnit durationUnit; - private Clock clock; - private Log logger; - private MetricFilter filter; - - private Builder( MetricRegistry registry ) - { - this.registry = registry; - this.rateUnit = TimeUnit.SECONDS; - this.durationUnit = TimeUnit.MILLISECONDS; - this.clock = Clock.defaultClock(); - this.filter = MetricFilter.ALL; - } - - /** - * Convert rates to the given time unit. - * - * @param rateUnit a unit of time - * @return {@code this} - */ - public Builder convertRatesTo( TimeUnit rateUnit ) - { - this.rateUnit = rateUnit; - return this; - } - - /** - * Convert durations to the given time unit. - * - * @param durationUnit a unit of time - * @return {@code this} - */ - public Builder convertDurationsTo( TimeUnit durationUnit ) - { - this.durationUnit = durationUnit; - return this; - } - - /** - * Use the given {@link Clock} instance for the time. - * - * @param clock a {@link Clock} instance - * @return {@code this} - */ - public Builder withClock( Clock clock ) - { - this.clock = clock; - return this; - } - - /** - * Use the given {@link Log} for reporting any errors. - * - * @param logger A Log instance, never null. - * @return {@code this} - */ - public Builder withLogger( Log logger ) - { - this.logger = logger; - return this; - } - - /** - * Only report metrics which match the given filter. - * - * @param filter a {@link MetricFilter} - * @return {@code this} - */ - public Builder filter( MetricFilter filter ) - { - this.filter = filter; - return this; - } - - /** - * Builds a {@link CsvReporterSingle} with the given properties, writing {@code .csv} data to the - * given file. - * - * @param file the file in which the {@code .csv} data will be inserted - * @return a {@link CsvReporterSingle} - */ - public CsvReporterSingle build( File file ) - { - return new CsvReporterSingle( registry, - file, - rateUnit, - durationUnit, - clock, - logger, - filter ); - } - } - - private static final ThreadLocal ISO8601 = new ThreadLocal() - { - @Override - protected SimpleDateFormat initialValue() - { - return new SimpleDateFormat( "yyyy-MM-dd HH:mm:ss" ); - } - }; - - private final File file; - private final Clock clock; - private final Log logger; - private PrintWriter out; - - private CsvReporterSingle( MetricRegistry registry, - File file, - TimeUnit rateUnit, - TimeUnit durationUnit, - Clock clock, - Log logger, - MetricFilter filter ) - { - super( registry, "csv-reporter-single", filter, rateUnit, durationUnit ); - this.file = file; - this.clock = clock; - this.logger = logger; - } - - @Override - public void stop() - { - super.stop(); - - if ( out != null ) - { - out.close(); - } - } - - @Override - public void report( SortedMap gauges, - SortedMap counters, - SortedMap histograms, - SortedMap meters, - SortedMap timers ) - { - if ( out == null ) - { - try - { - startNewCsvFile( gauges, counters, histograms, meters, timers ); - } - catch ( Exception e ) - { - logger.warn( "Could not create output CSV file: " + file.getAbsolutePath(), e ); - } - } - - StringBuilder line = new StringBuilder(); - - final long timestamp = TimeUnit.MILLISECONDS.toSeconds( clock.getTime() ); - - line.append( timestamp ).append( SEPARATOR ).append( ISO8601.get().format( new Date( clock.getTime() ) ) ); - - for ( Map.Entry entry : gauges.entrySet() ) - { - reportGauge( entry.getValue(), line ); - } - - for ( Map.Entry entry : counters.entrySet() ) - { - reportCounter( entry.getValue(), line ); - } - - for ( Map.Entry entry : histograms.entrySet() ) - { - reportHistogram( entry.getValue(), line ); - } - - for ( Map.Entry entry : meters.entrySet() ) - { - reportMeter( entry.getValue(), line ); - } - - for ( Map.Entry entry : timers.entrySet() ) - { - reportTimer( entry.getValue(), line ); - } - - out.println( line.toString() ); - out.flush(); - } - - private void startNewCsvFile( SortedMap gauges, SortedMap counters, - SortedMap histograms, SortedMap meters, - SortedMap timers ) throws IOException - { - if ( file.exists() ) - { - archiveExistingLogFile(); - } - - out = new PrintWriter( file, StandardCharsets.UTF_8.name() ); - - StringBuilder header = new StringBuilder(); - header.append( "timestamp" ).append( SEPARATOR ).append( "datetime" ); - - for ( Map.Entry entry : gauges.entrySet() ) - { - header.append( SEPARATOR ).append( entry.getKey() ); - } - - for ( Map.Entry entry : counters.entrySet() ) - { - header.append( SEPARATOR ).append( entry.getKey() ); - } - - for ( Map.Entry entry : histograms.entrySet() ) - { - header - .append( SEPARATOR ).append( entry.getKey() ).append( ".count" ) - .append( SEPARATOR ).append( entry.getKey() ).append( ".max" ) - .append( SEPARATOR ).append( entry.getKey() ).append( ".mean" ) - .append( SEPARATOR ).append( entry.getKey() ).append( ".min" ) - .append( SEPARATOR ).append( entry.getKey() ).append( ".stddev" ) - .append( SEPARATOR ).append( entry.getKey() ).append( ".p50" ) - .append( SEPARATOR ).append( entry.getKey() ).append( ".p75" ) - .append( SEPARATOR ).append( entry.getKey() ).append( ".p95" ) - .append( SEPARATOR ).append( entry.getKey() ).append( ".p98" ) - .append( SEPARATOR ).append( entry.getKey() ).append( ".p99" ) - .append( SEPARATOR ).append( entry.getKey() ).append( ".p999" ); - } - - for ( Map.Entry entry : meters.entrySet() ) - { - header - .append( SEPARATOR ).append( entry.getKey() ).append( ".count" ) - .append( SEPARATOR ).append( entry.getKey() ).append( ".mean_rate" ) - .append( SEPARATOR ).append( entry.getKey() ).append( ".m1_rate" ) - .append( SEPARATOR ).append( entry.getKey() ).append( ".m5_rate" ) - .append( SEPARATOR ).append( entry.getKey() ).append( ".m15_rate" ) - .append( SEPARATOR ).append( entry.getKey() ).append( ".rate_unit" ); - } - - for ( Map.Entry entry : timers.entrySet() ) - { - header - .append( SEPARATOR ).append( entry.getKey() ).append( ".count" ) - .append( SEPARATOR ).append( entry.getKey() ).append( ".max" ) - .append( SEPARATOR ).append( entry.getKey() ).append( ".mean" ) - .append( SEPARATOR ).append( entry.getKey() ).append( ".min" ) - .append( SEPARATOR ).append( entry.getKey() ).append( ".stddev" ) - .append( SEPARATOR ).append( entry.getKey() ).append( ".p50" ) - .append( SEPARATOR ).append( entry.getKey() ).append( ".p75" ) - .append( SEPARATOR ).append( entry.getKey() ).append( ".p95" ) - .append( SEPARATOR ).append( entry.getKey() ).append( ".p98" ) - .append( SEPARATOR ).append( entry.getKey() ).append( ".p99" ) - .append( SEPARATOR ).append( entry.getKey() ).append( ".p999" ) - .append( SEPARATOR ).append( entry.getKey() ).append( ".mean_rate" ) - .append( SEPARATOR ).append( entry.getKey() ).append( ".m1_rate" ) - .append( SEPARATOR ).append( entry.getKey() ).append( ".m5_rate" ) - .append( SEPARATOR ).append( entry.getKey() ).append( ".m15_rate" ) - .append( SEPARATOR ).append( entry.getKey() ).append( ".rate_unit" ) - .append( SEPARATOR ).append( entry.getKey() ).append( ".duration_unit" ); - } - - out.println( header.toString() ); - } - - private void archiveExistingLogFile() - { - String fileName = file.getName(); - SimpleDateFormat archivePrefix = new SimpleDateFormat( "yyyy_MM_dd_HH_mm_ss" ); - fileName = archivePrefix.format( new Date( file.lastModified() ) ) + fileName; - File archiveFile = new File( file.getParentFile(), fileName ); - - if ( !file.renameTo( archiveFile ) ) - { - throw new IllegalStateException( "Could not move old metrics log to " + archiveFile ); - } - } - - private void reportTimer( Timer timer, StringBuilder line ) - { - final Snapshot snapshot = timer.getSnapshot(); - - line.append( format( ",%d,%f,%f,%f,%f,%f,%f,%f,%f,%f,%f,%f,%f,%f,%f,calls/%s,%s", timer.getCount(), - convertDuration( snapshot.getMax() ), - convertDuration( snapshot.getMean() ), - convertDuration( snapshot.getMin() ), - convertDuration( snapshot.getStdDev() ), - convertDuration( snapshot.getMedian() ), - convertDuration( snapshot.get75thPercentile() ), - convertDuration( snapshot.get95thPercentile() ), - convertDuration( snapshot.get98thPercentile() ), - convertDuration( snapshot.get99thPercentile() ), - convertDuration( snapshot.get999thPercentile() ), - convertRate( timer.getMeanRate() ), - convertRate( timer.getOneMinuteRate() ), - convertRate( timer.getFiveMinuteRate() ), - convertRate( timer.getFifteenMinuteRate() ), - getRateUnit(), - getDurationUnit() ) ); - } - - private void reportMeter( Meter meter, StringBuilder line ) - { - line.append( format( ",%d,%f,%f,%f,%f,events/%s", meter.getCount(), - convertRate( meter.getMeanRate() ), - convertRate( meter.getOneMinuteRate() ), - convertRate( meter.getFiveMinuteRate() ), - convertRate( meter.getFifteenMinuteRate() ), - getRateUnit() ) ); - } - - private void reportHistogram( Histogram histogram, StringBuilder line ) - { - final Snapshot snapshot = histogram.getSnapshot(); - - line.append( format( ",%d,%d,%f,%d,%f,%f,%f,%f,%f,%f,%f", - histogram.getCount(), - snapshot.getMax(), - snapshot.getMean(), - snapshot.getMin(), - snapshot.getStdDev(), - snapshot.getMedian(), - snapshot.get75thPercentile(), - snapshot.get95thPercentile(), - snapshot.get98thPercentile(), - snapshot.get99thPercentile(), - snapshot.get999thPercentile() ) ); - } - - private void reportCounter( Counter counter, StringBuilder line ) - { - line.append( SEPARATOR ).append( counter.getCount() ); - } - - private void reportGauge( Gauge gauge, StringBuilder line ) - { - line.append( SEPARATOR ).append( gauge.getValue().toString() ); - } -} diff --git a/enterprise/metrics/src/main/java/org/neo4j/metrics/source/CheckPointingMetrics.java b/enterprise/metrics/src/main/java/org/neo4j/metrics/source/CheckPointingMetrics.java index 4a30a6583ed83..42324bd582a7b 100644 --- a/enterprise/metrics/src/main/java/org/neo4j/metrics/source/CheckPointingMetrics.java +++ b/enterprise/metrics/src/main/java/org/neo4j/metrics/source/CheckPointingMetrics.java @@ -37,13 +37,14 @@ public class CheckPointingMetrics extends LifecycleAdapter { private static final String CHECK_POINT_PREFIX = "neo4j.check_point"; - private static final String LOG_ROTATION_PREFIX = "neo4j.log_rotation"; @Documented( "The total number of check point events executed so far" ) public static final String CHECK_POINT_EVENTS = name( CHECK_POINT_PREFIX, "events" ); @Documented( "The total time spent in check pointing so far" ) public static final String CHECK_POINT_TOTAL_TIME = name( CHECK_POINT_PREFIX, "total_time" ); + private static final String LOG_ROTATION_PREFIX = "neo4j.log_rotation"; + @Documented( "The total number of transaction log rotations executed so far" ) public static final String LOG_ROTATION_EVENTS = name( LOG_ROTATION_PREFIX, "events" ); @Documented( "The total time spent in rotating transaction logs so far" ) diff --git a/enterprise/metrics/src/main/java/org/neo4j/metrics/source/ClusterMetrics.java b/enterprise/metrics/src/main/java/org/neo4j/metrics/source/ClusterMetrics.java index 38613590ca32d..92aa8cbe1cb9b 100644 --- a/enterprise/metrics/src/main/java/org/neo4j/metrics/source/ClusterMetrics.java +++ b/enterprise/metrics/src/main/java/org/neo4j/metrics/source/ClusterMetrics.java @@ -45,6 +45,7 @@ public class ClusterMetrics extends LifecycleAdapter { private static final String NAME_PREFIX = "neo4j.cluster"; + @Documented( "The total number of update pulls executed by this instance" ) public static final String SLAVE_PULL_UPDATES = name( NAME_PREFIX, "slave_pull_updates" ); @Documented( "The highest transaction id that has been pulled in the last pull updates by this instance" ) diff --git a/enterprise/metrics/src/main/java/org/neo4j/metrics/source/JvmMetrics.java b/enterprise/metrics/src/main/java/org/neo4j/metrics/source/JvmMetrics.java index 248970b95b164..a380a2b14764d 100644 --- a/enterprise/metrics/src/main/java/org/neo4j/metrics/source/JvmMetrics.java +++ b/enterprise/metrics/src/main/java/org/neo4j/metrics/source/JvmMetrics.java @@ -45,12 +45,13 @@ public class JvmMetrics extends LifecycleAdapter { private static final String NAME_PREFIX = "vm"; - private static final String GC_PREFIX = name( NAME_PREFIX, "gc" ); - private static final String GC_TIME = name( GC_PREFIX, "time" ); - private static final String GC_COUNT = name( GC_PREFIX, "count" ); - private static final String MEMORY_POOL = name( NAME_PREFIX, "memory.pool" ); - private static final String MEMORY_BUFFER = name( NAME_PREFIX, "memory.buffer" ); - private static final String THREAD = name( NAME_PREFIX, "thread" ); + public static final String GC_PREFIX = name( NAME_PREFIX, "gc" ); + public static final String GC_TIME = name( GC_PREFIX, "time" ); + public static final String GC_COUNT = name( GC_PREFIX, "count" ); + public static final String MEMORY_POOL = name( NAME_PREFIX, "memory.pool" ); + public static final String MEMORY_BUFFER = name( NAME_PREFIX, "memory.buffer" ); + public static final String THREAD = name( NAME_PREFIX, "thread" ); + private final Config config; private final MetricRegistry registry; diff --git a/enterprise/metrics/src/main/java/org/neo4j/metrics/source/NetworkMetrics.java b/enterprise/metrics/src/main/java/org/neo4j/metrics/source/NetworkMetrics.java index 5bd6fed13c86a..aceca3e74c256 100644 --- a/enterprise/metrics/src/main/java/org/neo4j/metrics/source/NetworkMetrics.java +++ b/enterprise/metrics/src/main/java/org/neo4j/metrics/source/NetworkMetrics.java @@ -39,6 +39,7 @@ public class NetworkMetrics extends LifecycleAdapter { private static final String NAME_PREFIX = "neo4j.network"; + @Documented( "The amount of bytes transmitted on the network containing the transaction data from a slave " + "to the master in order to be committed" ) public static final String SLAVE_NETWORK_TX_WRITES = name( NAME_PREFIX, "slave_network_tx_writes" ); diff --git a/enterprise/metrics/src/test/java/org/neo4j/metrics/MetricsKernelExtensionFactoryIT.java b/enterprise/metrics/src/test/java/org/neo4j/metrics/MetricsKernelExtensionFactoryIT.java index 32e9c277f86d9..7ffc0dc93cd92 100644 --- a/enterprise/metrics/src/test/java/org/neo4j/metrics/MetricsKernelExtensionFactoryIT.java +++ b/enterprise/metrics/src/test/java/org/neo4j/metrics/MetricsKernelExtensionFactoryIT.java @@ -38,8 +38,7 @@ import org.neo4j.kernel.ha.HighlyAvailableGraphDatabase; import org.neo4j.kernel.impl.ha.ClusterManager; import org.neo4j.metrics.source.CypherMetrics; -import org.neo4j.graphdb.factory.GraphDatabaseFactory; -import org.neo4j.helpers.collection.MapUtil; +import org.neo4j.metrics.source.TransactionMetrics; import org.neo4j.test.TargetDirectory; import org.neo4j.test.ha.ClusterRule; @@ -49,10 +48,9 @@ import static org.junit.Assert.assertThat; import static org.neo4j.graphdb.factory.GraphDatabaseSettings.cypher_min_replan_interval; import static org.neo4j.kernel.impl.ha.ClusterManager.clusterOfSize; -import static org.neo4j.metrics.MetricsSettings.CsvFile.single; import static org.neo4j.metrics.MetricsSettings.csvEnabled; -import static org.neo4j.metrics.MetricsSettings.csvFile; import static org.neo4j.metrics.MetricsSettings.csvPath; +import static org.neo4j.metrics.MetricsSettings.metricsEnabled; public class MetricsKernelExtensionFactoryIT { @@ -61,20 +59,20 @@ public class MetricsKernelExtensionFactoryIT @Rule public final ClusterRule clusterRule = new ClusterRule( getClass() ); - private File outputFile; + private File outputPath; private ClusterManager.ManagedCluster cluster; private HighlyAvailableGraphDatabase db; @Before public void setup() throws Exception { - outputFile = folder.file( "metrics.csv" ); + outputPath = folder.file( "metrics.csv" ); Map config = new HashMap<>(); config.put( MetricsSettings.neoEnabled.name(), Settings.TRUE ); + config.put( metricsEnabled.name(), Settings.TRUE ); config.put( csvEnabled.name(), Settings.TRUE ); config.put( cypher_min_replan_interval.name(), "0" ); - config.put( csvFile.name(), single.name() ); - config.put( csvPath.name(), outputFile.getAbsolutePath() ); + config.put( csvPath.name(), outputPath.getAbsolutePath() ); cluster = clusterRule.withSharedConfig( config ).withProvider( clusterOfSize( 1 ) ).startCluster(); db = cluster.getMaster(); } @@ -88,12 +86,12 @@ public void mustLoadMetricsExtensionWhenConfigured() throws Throwable // Awesome. Let's get some metric numbers. // We should at least have a "timestamp" column, and a "neo4j.transaction.committed" column - try ( BufferedReader reader = new BufferedReader( new FileReader( outputFile ) ) ) + File metricsFile = new File( outputPath, TransactionMetrics.TX_COMMITTED + ".csv" ); + try ( BufferedReader reader = new BufferedReader( new FileReader( metricsFile ) ) ) { String[] headers = reader.readLine().split( "," ); - assertThat( headers[0], is( "timestamp" ) ); - int committedColumn = Arrays.binarySearch( headers, "neo4j.transaction.committed" ); - assertThat( committedColumn, is( not( -1 ) ) ); + assertThat( headers[0], is( "t" ) ); + assertThat( headers[1], is( "value" ) ); // Now we can verify that the number of committed transactions should never decrease. int committedTransactions = 0; @@ -101,7 +99,7 @@ public void mustLoadMetricsExtensionWhenConfigured() throws Throwable while ( (line = reader.readLine()) != null ) { String[] fields = line.split( "," ); - int newCommittedTransactions = Integer.parseInt( fields[committedColumn] ); + int newCommittedTransactions = Integer.parseInt( fields[1] ); assertThat( newCommittedTransactions, greaterThanOrEqualTo( committedTransactions ) ); committedTransactions = newCommittedTransactions; } @@ -130,10 +128,11 @@ public void showReplanEvents() throws Throwable cluster.stop(); //now we should have one replan event - try ( BufferedReader reader = new BufferedReader( new FileReader( outputFile ) ) ) + File metricFile = new File( outputPath, CypherMetrics.REPLAN_EVENTS + ".csv" ); + try ( BufferedReader reader = new BufferedReader( new FileReader( metricFile ) ) ) { String[] headers = reader.readLine().split( "," ); - int replanColumn = Arrays.binarySearch( headers, CypherMetrics.REPLAN_EVENTS ); + int replanColumn = Arrays.binarySearch( headers, "value" ); assertThat( replanColumn, is( not( -1 ) ) ); // Now we can verify that the number of committed transactions should never decrease.