Package com.datasift.dropwizard.config

Examples of com.datasift.dropwizard.config.GraphiteConfiguration


     * @param environment the {@link Service} environment
     */
    public void run(final GraphiteReportingConfiguration configuration,
                    final Environment environment) {

        final GraphiteConfiguration graphiteConfiguration = configuration.getGraphite();

        if (graphiteConfiguration.getEnabled()) {
            log.info("Reporting metrics to Graphite at {}:{}, every {}",
                    graphiteConfiguration.getHost(),
                    graphiteConfiguration.getPort(),
                    graphiteConfiguration.getFrequency());

            GraphiteReporter.enable(
                    Metrics.defaultRegistry(),
                    graphiteConfiguration.getFrequency().toNanoseconds(),
                    TimeUnit.NANOSECONDS,
                    graphiteConfiguration.getHost(),
                    graphiteConfiguration.getPort(),
                    graphiteConfiguration.getPrefix(),
                    new MetricPredicate() {
                        @Override
                        public boolean matches(final MetricName name, final Metric metric) {
                            return !graphiteConfiguration.getExcludes().contains(pathFor(name));
                        }

                        private String pathFor(final MetricName name) {
                            final StringBuilder sb = new StringBuilder(name.getGroup())
                                    .append('.')
                                    .append(name.getType())
                                    .append('.');
                            if (name.hasScope()) {
                                sb.append(name.getScope()).append('.');
                            }

                            return sb.append(name.getName()).toString();
                        }
                    }
            );

            environment.addHealthCheck(new GraphiteHealthCheck(
                    graphiteConfiguration.getHost(),
                    graphiteConfiguration.getPort(),
                    "graphite"));
        }
    }
View Full Code Here

TOP

Related Classes of com.datasift.dropwizard.config.GraphiteConfiguration

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.