Java Code Examples for com.yammer.metrics.Metrics#defaultRegistry()
The following examples show how to use
com.yammer.metrics.Metrics#defaultRegistry() .
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: RootResource.java From usergrid with Apache License 2.0 | 6 votes |
private void dumpMetrics( ObjectNode node ) { MetricsRegistry registry = Metrics.defaultRegistry(); for ( Map.Entry<String, SortedMap<MetricName, Metric>> entry : registry.groupedMetrics().entrySet() ) { ObjectNode meterNode = JsonNodeFactory.instance.objectNode(); for ( Map.Entry<MetricName, Metric> subEntry : entry.getValue().entrySet() ) { ObjectNode metricNode = JsonNodeFactory.instance.objectNode(); try { subEntry.getValue().processWith( this, subEntry.getKey(), new MetricContext( metricNode, true ) ); } catch ( Exception e ) { logger.warn( "Error writing out {}", subEntry.getKey(), e ); } meterNode.put( subEntry.getKey().getName(), metricNode ); } node.put( entry.getKey(), meterNode ); } }
Example 2
Source File: StatsdMetricsReporter.java From kafka-statsd-metrics2 with Apache License 2.0 | 6 votes |
@Override public void startReporter(long pollingPeriodInSeconds) { if (pollingPeriodInSeconds <= 0) { throw new IllegalArgumentException("Polling period must be greater than zero"); } synchronized (running) { if (running.get()) { log.warn("Reporter is already running"); } else { statsd = createStatsd(); underlying = new StatsDReporter( Metrics.defaultRegistry(), statsd, metricPredicate, metricDimensions, isTagEnabled); underlying.start(pollingPeriodInSeconds, TimeUnit.SECONDS); log.info("Started Reporter with host={}, port={}, polling_period_secs={}, prefix={}", host, port, pollingPeriodInSeconds, prefix); running.set(true); } } }
Example 3
Source File: KafkaGraphiteMetricsReporter.java From kafka-graphite with Apache License 2.0 | 6 votes |
private FilteredGraphiteReporter buildGraphiteReporter() { FilteredGraphiteReporter graphiteReporter = null; try { graphiteReporter = new FilteredGraphiteReporter( Metrics.defaultRegistry(), metricPrefix, metricPredicate, metricDimensions, new FilteredGraphiteReporter.DefaultSocketProvider(graphiteHost, graphitePort), Clock.defaultClock() ); } catch (IOException e) { LOG.error("Unable to initialize GraphiteReporter", e); } return graphiteReporter; }
Example 4
Source File: KafkaStatsdMetricsReporter.java From kafka-statsd-reporter with MIT License | 6 votes |
@Override public synchronized void stopReporter() { if (initialized && running) { reporter.shutdown(); running = false; LOG.info("Stopped Kafka Statsd metrics reporter"); try { reporter = new StatsdReporter( Metrics.defaultRegistry(), statsdGroupPrefix, predicate, statsdHost, statsdPort, Clock.defaultClock() ); } catch (IOException e) { LOG.error("Unable to initialize StatsdReporter", e); } } }
Example 5
Source File: KafkaStatsdMetricsReporter.java From kafka-statsd-reporter with MIT License | 5 votes |
@Override public synchronized void init(VerifiableProperties props) { if (!initialized) { KafkaMetricsConfig metricsConfig = new KafkaMetricsConfig(props); statsdHost = props.getString("kafka.statsd.metrics.host", STATSD_DEFAULT_HOST).trim(); statsdPort = props.getInt("kafka.statsd.metrics.port", STATSD_DEFAULT_PORT); statsdGroupPrefix = props.getString("kafka.statsd.metrics.group", STATSD_DEFAULT_PREFIX).trim(); String regex = props.getString("kafka.statsd.metrics.exclude.regex", null); LOG.debug("Initialize StatsdReporter ["+statsdHost+","+statsdPort+","+statsdGroupPrefix+"]"); if (regex != null) { predicate = new RegexMetricPredicate(regex); } try { reporter = new StatsdReporter( Metrics.defaultRegistry(), statsdGroupPrefix, predicate, statsdHost, statsdPort, Clock.defaultClock() ); } catch (IOException e) { LOG.error("Unable to initialize StatsdReporter", e); } if (props.getBoolean("kafka.statsd.metrics.reporter.enabled", false)) { initialized = true; startReporter(metricsConfig.pollingIntervalSecs()); LOG.debug("StatsdReporter started."); } } }
Example 6
Source File: KafkaBrokerReporter.java From metrics-kafka with Apache License 2.0 | 5 votes |
public synchronized void stopReporter() { if (initialized && running) { underlying.shutdown(); running = false; log.info("Stopped Kafka Topic metrics reporter"); underlying = new TopicReporter(Metrics.defaultRegistry(), new ProducerConfig(props.props()), String.format("broker%s", props.getString("broker.id"))); } }
Example 7
Source File: KafkaBrokerReporter.java From metrics-kafka with Apache License 2.0 | 5 votes |
synchronized public void init(VerifiableProperties props) { if (!initialized) { this.props = props; props.props().put("metadata.broker.list", String.format("%s:%d", "localhost", props.getInt("port"))); final KafkaMetricsConfig metricsConfig = new KafkaMetricsConfig(props); this.underlying = new TopicReporter(Metrics.defaultRegistry(), new ProducerConfig(props.props()), "broker%s".format(props.getString("broker.id"))); initialized = true; startReporter(metricsConfig.pollingIntervalSecs()); } }
Example 8
Source File: GraphiteReporter.java From mireka with Apache License 2.0 | 5 votes |
@PostConstruct public void start() { try { reporter = new com.yammer.metrics.reporting.GraphiteReporter( Metrics.defaultRegistry(), host, port, prefix); reporter.start(period, periodUnit); } catch (IOException e) { throw new RuntimeException(e); } }
Example 9
Source File: ConsumerGroupReporter.java From kafka-metrics with Apache License 2.0 | 5 votes |
public void stopReporter() { if (initialized && running) { running = false; underlying.shutdown(); log.info("Stopped TopicReporter instance"); underlying = new X(Metrics.defaultRegistry()); } }
Example 10
Source File: ConsumerGroupReporter.java From kafka-metrics with Apache License 2.0 | 5 votes |
@Override public void init(VerifiableProperties props) { if (!initialized) { this.props = new Properties(); if (props.containsKey(CONFIG_POLLING_INTERVAL)) { this.pollingIntervalSeconds = props.getInt(CONFIG_POLLING_INTERVAL); } else { this.pollingIntervalSeconds = 10; } this.brokerId = Integer.parseInt(props.getProperty("broker.id")); log.info("Building ConsumerGroupReporter: polling.interval=" + pollingIntervalSeconds); Enumeration<Object> keys = props.props().keys(); while (keys.hasMoreElements()) { String key = keys.nextElement().toString(); if (key.startsWith("kafka.metrics.")) { String subKey = key.substring(14); this.props.put(subKey, props.props().get(key)); log.info("Building ConsumerGroupReporter: " + subKey + "=" + this.props.get(subKey)); } } initialized = true; this.underlying = new X(Metrics.defaultRegistry()); startReporter(pollingIntervalSeconds); } }
Example 11
Source File: MeterPoolTest.java From common-kafka with Apache License 2.0 | 5 votes |
@Before public void clearMetrics() { MetricsRegistry metricsRegistry = Metrics.defaultRegistry(); for (MetricName metric : metricsRegistry.allMetrics().keySet()) { metricsRegistry.removeMetric(metric); } }
Example 12
Source File: MemoryReporter.java From incubator-retired-blur with Apache License 2.0 | 4 votes |
public static void enable() { MemoryReporter memoryReporter = new MemoryReporter(Metrics.defaultRegistry(), "memory-reporter"); memoryReporter.start(1, TimeUnit.SECONDS); }
Example 13
Source File: KafkaTimelineMetricsReporter.java From ambari-metrics with Apache License 2.0 | 4 votes |
private void initializeReporter() { reporter = new TimelineScheduledReporter(Metrics.defaultRegistry(), "timeline-scheduled-reporter", TimeUnit.SECONDS, TimeUnit.MILLISECONDS); initialized = true; }
Example 14
Source File: CustomReporter.java From netty-4.1.22 with Apache License 2.0 | 2 votes |
/** * 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 15
Source File: StatsdReporter.java From kafka-statsd-reporter with MIT License | 2 votes |
/** * Creates a new {@link StatsdReporter}. * * @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(String host, int port, String prefix) throws IOException { this(Metrics.defaultRegistry(), host, port, prefix); }
Example 16
Source File: CustomReporter.java From netty4.0.27Learn with Apache License 2.0 | 2 votes |
/** * 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 17
Source File: BcryptCommandTest.java From usergrid with Apache License 2.0 | 2 votes |
/** * 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(); }