Java Code Examples for com.yammer.metrics.core.MetricPredicate#ALL

The following examples show how to use com.yammer.metrics.core.MetricPredicate#ALL . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: StatsdMetricsReporter.java    From kafka-statsd-metrics2 with Apache License 2.0 6 votes vote down vote up
private void loadConfig(VerifiableProperties props) {
  enabled = props.getBoolean("external.kafka.statsd.reporter.enabled", false);
  host = props.getString("external.kafka.statsd.host", "localhost");
  port = props.getInt("external.kafka.statsd.port", 8125);
  prefix = props.getString("external.kafka.statsd.metrics.prefix", "");
  pollingPeriodInSeconds = props.getInt("kafka.metrics.polling.interval.secs", 10);
  metricDimensions = Dimension.fromProperties(props.props(), "external.kafka.statsd.dimension.enabled.");

  String excludeRegex = props.getString("external.kafka.statsd.metrics.exclude_regex", DEFAULT_EXCLUDE_REGEX);
  if (excludeRegex != null && excludeRegex.length() != 0) {
    metricPredicate = new ExcludeMetricPredicate(excludeRegex);
  } else {
    metricPredicate = MetricPredicate.ALL;
  }

  this.isTagEnabled = props.getBoolean("external.kafka.statsd.tag.enabled", true);
}
 
Example 2
Source File: CustomReporter.java    From netty-4.1.22 with Apache License 2.0 5 votes vote down vote up
/**
 * Enables the console reporter for the given metrics registry, and causes
 * it to print to STDOUT with the specified period and unrestricted output.
 */
public static void enable(final MetricsRegistry metricsRegistry,
        final long period, final TimeUnit unit) {
    final CustomReporter reporter = new CustomReporter(
            metricsRegistry, System.out, MetricPredicate.ALL);
    reporter.start(period, unit);
}
 
Example 3
Source File: CustomReporter.java    From netty4.0.27Learn with Apache License 2.0 5 votes vote down vote up
/**
 * Enables the console reporter for the given metrics registry, and causes
 * it to print to STDOUT with the specified period and unrestricted output.
 */
public static void enable(final MetricsRegistry metricsRegistry,
        final long period, final TimeUnit unit) {
    final CustomReporter reporter = new CustomReporter(
            metricsRegistry, System.out, MetricPredicate.ALL);
    reporter.start(period, unit);
}
 
Example 4
Source File: CustomReporter.java    From netty-4.1.22 with Apache License 2.0 2 votes vote down vote up
/**
 * Creates a new {@link CustomReporter} for the default metrics
 * registry, with unrestricted output.
 */
public CustomReporter(final PrintStream out) {
    this(Metrics.defaultRegistry(), out, MetricPredicate.ALL);
}
 
Example 5
Source File: CustomReporter.java    From netty4.0.27Learn with Apache License 2.0 2 votes vote down vote up
/**
 * Creates a new {@link CustomReporter} for the default metrics
 * registry, with unrestricted output.
 */
public CustomReporter(final PrintStream out) {
    this(Metrics.defaultRegistry(), out, MetricPredicate.ALL);
}
 
Example 6
Source File: StatsdReporter.java    From kafka-statsd-reporter with MIT License 2 votes vote down vote up
/**
 * Creates a new {@link StatsdReporter}.
 * 
 * @param metricsRegistry
 *            the metrics registry
 * @param host
 *            the host name of statsd server
 * @param port
 *            the port number on which the statsd server is listening
 * @param prefix
 *            is prepended to all names reported to statsd
 * @throws IOException
 *             if there is an error connecting to the statsd server
 */
public StatsdReporter(MetricsRegistry metricsRegistry, String host, int port, String prefix) throws IOException {
	this(metricsRegistry, prefix, MetricPredicate.ALL, host, port, Clock.defaultClock());
}
 
Example 7
Source File: BcryptCommandTest.java    From usergrid with Apache License 2.0 2 votes vote down vote up
/**
 * Tests bcrypt hashing with a default number of rounds.  Note that via the console output, this test should take
 * about 5 seconds to run since we want to force 500 ms per authentication attempt with bcrypt
 */
@Test
public void testHashRoundSpeed() throws UnsupportedEncodingException {

    int cryptIterations = 2 ^ 11;
    int numberOfTests = 10;

    BcryptCommand command = new BcryptCommand();
    command.setDefaultIterations( cryptIterations );

    String baseString = "I am a test password for hashing";

    CredentialsInfo info = new CredentialsInfo();


    UUID user = UUID.randomUUID();
    UUID applicationId = UUID.randomUUID();

    byte[] result = command.hash( baseString.getBytes( "UTF-8" ), info, user, applicationId );


    String stringResults = encodeBase64URLSafeString( result );

    info.setSecret( stringResults );

    Timer timer = Metrics.newTimer( BcryptCommandTest.class, "hashtimer" );

    for ( int i = 0; i < numberOfTests; i++ ) {
        TimerContext timerCtx = timer.time();

        //now check we can auth with the same phrase
        byte[] authed = command.auth( baseString.getBytes( "UTF-8" ), info, user, applicationId );

        timerCtx.stop();


        assertArrayEquals( result, authed );
    }

    /**
     * Print out the data
     */
    ConsoleReporter reporter = new ConsoleReporter( Metrics.defaultRegistry(), System.out, MetricPredicate.ALL );

    reporter.run();
}