Java 类com.codahale.metrics.graphite.GraphiteSender 实例源码

项目:graylog-plugin-metrics-reporter    文件:GraphiteSenderProvider.java   
@Override
public GraphiteSender get() {
    switch (configuration.getProtocol()) {
        case PICKLE:
            return new PickledGraphite(
                    configuration.getAddress(),
                    SocketFactory.getDefault(),
                    configuration.getCharset(),
                    configuration.getPickleBatchSize());
        case TCP:
            return new Graphite(configuration.getAddress(), SocketFactory.getDefault(), configuration.getCharset());
        case UDP:
            return new GraphiteUDP(configuration.getAddress());
        default:
            throw new IllegalArgumentException("Unknown Graphite protocol \"" + configuration.getProtocol() + "\"");
    }
}
项目:pay-adminusers    文件:AdminUsersApp.java   
private void initialiseMetrics(AdminUsersConfig configuration, Environment environment) {
    GraphiteSender graphiteUDP = new GraphiteUDP(configuration.getGraphiteHost(), Integer.valueOf(configuration.getGraphitePort()));
    GraphiteReporter.forRegistry(environment.metrics())
            .prefixedWith(SERVICE_METRICS_NODE)
            .build(graphiteUDP)
            .start(GRAPHITE_SENDING_PERIOD_SECONDS, TimeUnit.SECONDS);

}
项目:pay-cardid    文件:CardApi.java   
private void initialiseMetrics(CardConfiguration configuration, Environment environment) {
    GraphiteSender graphiteUDP = new GraphiteUDP(configuration.getGraphiteHost(), Integer.valueOf(configuration.getGraphitePort()));
    GraphiteReporter.forRegistry(environment.metrics())
            .prefixedWith(SERVICE_METRICS_NODE)
            .build(graphiteUDP)
            .start(GRAPHITE_SENDING_PERIOD_SECONDS, TimeUnit.SECONDS);

}
项目:monitoring-center    文件:MonitoringCenter.java   
private static void initGraphiteReporter(final GraphiteReporterConfig graphiteReporterConfig) {
    HostAndPort hostAndPort = graphiteReporterConfig.getAddress();
    InetSocketAddress inetSocketAddress = new InetSocketAddress(hostAndPort.getHost(), hostAndPort.getPort());

    GraphiteSender graphiteSender = graphiteReporterConfig.isEnableBatching()
            ? new PickledGraphite(inetSocketAddress)
            : new Graphite(inetSocketAddress);

    graphiteReporter = GraphiteReporter.forRegistry(metricRegistry)
            .prefixedWith(prefix)
            .convertRatesTo(TimeUnit.SECONDS)
            .convertDurationsTo(TimeUnit.MICROSECONDS)
            .withClock(new Clock() {
                private long lastReportingTime = 0;

                @Override
                public long getTick() {
                    return System.nanoTime();
                }

                @Override
                public synchronized long getTime() {
                    if (lastReportingTime == 0) {
                        lastReportingTime = System.currentTimeMillis();
                        return lastReportingTime;
                    }
                    lastReportingTime += graphiteReporterConfig.getReportingIntervalInSeconds() * 1000;
                    return lastReportingTime;
                }
            })
            .filter(buildMetricFilter(graphiteReporterConfig.getStartsWithFilters(), graphiteReporterConfig.getBlockedStartsWithFilters()))
            .build(graphiteSender);

    graphiteReporter.start(graphiteReporterConfig.getReportingIntervalInSeconds(), TimeUnit.SECONDS);
}
项目:graylog-plugin-metrics-reporter    文件:MetricsGraphiteReporterModule.java   
@Override
protected void configure() {
    bind(GraphiteSender.class).toProvider(GraphiteSenderProvider.class);
    bind(GraphiteReporter.class).toProvider(GraphiteReporterProvider.class);

    addConfigBeans();
    addInitializer(MetricsGraphiteReporterService.class);
}
项目:graylog-plugin-metrics-reporter    文件:GraphiteReporterProvider.java   
@Inject
public GraphiteReporterProvider(MetricsGraphiteReporterConfiguration configuration,
                                GraphiteSender graphiteSender,
                                MetricRegistry metricRegistry) {
    this.configuration = requireNonNull(configuration);
    this.graphiteSender = requireNonNull(graphiteSender);
    this.metricRegistry = requireNonNull(metricRegistry);
}
项目:graylog-plugin-metrics-reporter    文件:GraphiteSenderProviderTest.java   
@Test
public void getReturnsGraphite() throws Exception {
    final MetricsGraphiteReporterConfiguration configuration = new MetricsGraphiteReporterConfiguration() {
        @Override
        public GraphiteProtocol getProtocol() {
            return GraphiteProtocol.TCP;
        }
    };
    final GraphiteSenderProvider provider = new GraphiteSenderProvider(configuration);

    final GraphiteSender graphiteSender = provider.get();
    assertTrue(graphiteSender instanceof Graphite);
    assertFalse(graphiteSender.isConnected());
}
项目:graylog-plugin-metrics-reporter    文件:GraphiteSenderProviderTest.java   
@Test
public void getReturnsGraphiteUDP() throws Exception {
    final MetricsGraphiteReporterConfiguration configuration = new MetricsGraphiteReporterConfiguration() {
        @Override
        public GraphiteProtocol getProtocol() {
            return GraphiteProtocol.UDP;
        }
    };
    final GraphiteSenderProvider provider = new GraphiteSenderProvider(configuration);

    final GraphiteSender graphiteSender = provider.get();
    assertTrue(graphiteSender instanceof GraphiteUDP);
    assertFalse(graphiteSender.isConnected());
}
项目:graylog-plugin-metrics-reporter    文件:GraphiteSenderProviderTest.java   
@Test
public void getReturnsGraphitePickledGraphite() throws Exception {
    final MetricsGraphiteReporterConfiguration configuration = new MetricsGraphiteReporterConfiguration() {
        @Override
        public GraphiteProtocol getProtocol() {
            return GraphiteProtocol.PICKLE;
        }
    };
    final GraphiteSenderProvider provider = new GraphiteSenderProvider(configuration);

    final GraphiteSender graphiteSender = provider.get();
    assertTrue(graphiteSender instanceof PickledGraphite);
    assertFalse(graphiteSender.isConnected());
}
项目:graylog-plugin-metrics-reporter    文件:GraphiteReporterProviderTest.java   
@Test
public void get() throws Exception {
    final MetricsGraphiteReporterConfiguration configuration = new MetricsGraphiteReporterConfiguration();
    final GraphiteSender graphiteSender = new GraphiteUDP("127.0.0.1", 12345);
    final MetricRegistry metricRegistry = new MetricRegistry();
    final GraphiteReporterProvider provider = new GraphiteReporterProvider(configuration, graphiteSender, metricRegistry);

    final GraphiteReporter reporter = provider.get();
    assertNotNull(reporter);
}
项目:devramble    文件:DropwizardMetricsConfig.java   
@Bean(destroyMethod = "stop")
public GraphiteReporter graphiteReporter() {
    GraphiteSender sender = new Graphite("localhost", 2003);
    GraphiteReporter reporter = GraphiteReporter.forRegistry(registry).prefixedWith("user-service").convertRatesTo(TimeUnit.SECONDS).convertDurationsTo(TimeUnit.MILLISECONDS).build(sender);
    reporter.start(10, TimeUnit.SECONDS);
    return reporter;
}
项目:Camel    文件:Application.java   
/**
 * Create reporter bean and tell Spring to call stop() when shutting down.
 * UPD must be enabled in carbon.conf
 * 
 * @return graphite reporter
 */
@Bean(destroyMethod = "stop")
public GraphiteReporter graphiteReporter() {
    final GraphiteSender graphite = new GraphiteUDP(new InetSocketAddress("localhost", 2003));
    final GraphiteReporter reporter = GraphiteReporter.forRegistry(metricRegistry).prefixedWith("camel-spring-boot").convertRatesTo(TimeUnit.SECONDS)
        .convertDurationsTo(TimeUnit.MILLISECONDS).filter(MetricFilter.ALL).build(graphite);
    reporter.start(5, TimeUnit.SECONDS);
    return reporter;
}
项目:pay-publicauth    文件:PublicAuthApp.java   
private void initialiseMetrics(PublicAuthConfiguration configuration, Environment environment) {
    GraphiteSender graphiteUDP = new GraphiteUDP(configuration.getGraphiteHost(), Integer.valueOf(configuration.getGraphitePort()));
    GraphiteReporter.forRegistry(environment.metrics())
            .prefixedWith(SERVICE_METRICS_NODE)
            .build(graphiteUDP)
            .start(GRAPHITE_SENDING_PERIOD_SECONDS, TimeUnit.SECONDS);

}
项目:pay-publicapi    文件:PublicApi.java   
private void initialiseMetrics(PublicApiConfig configuration, Environment environment) {
    GraphiteSender graphiteUDP = new GraphiteUDP(configuration.getGraphiteHost(), Integer.valueOf(configuration.getGraphitePort()));
    GraphiteReporter.forRegistry(environment.metrics())
            .prefixedWith(SERVICE_METRICS_NODE)
            .build(graphiteUDP)
            .start(GRAPHITE_SENDING_PERIOD_SECONDS, TimeUnit.SECONDS);
}
项目:circus-train    文件:GraphiteMetricSender.java   
GraphiteMetricSender(GraphiteSender graphite, Clock clock, String prefix) {
  this.graphite = graphite;
  this.clock = clock;
  this.prefix = prefix;
}
项目:Gobblin    文件:GraphiteReporter.java   
protected GraphiteReporter(MetricContext context, String name, MetricFilter filter,
    TimeUnit rateUnit, TimeUnit durationUnit, GraphiteSender graphiteSender) {
  super(context, name, filter, rateUnit, durationUnit);
  this.graphiteSender = graphiteSender;
}
项目:Gobblin    文件:GraphiteReporter.java   
public Builder(String name, GraphiteSender graphiteSender) {
  super(name);
  this.graphiteSender = graphiteSender;
}
项目:edison-microservice    文件:FilteringGraphiteSender.java   
public FilteringGraphiteSender(GraphiteSender delegate, Predicate<String> predicate) {
    this.delegate = delegate;
    this.predicate = predicate;
}
项目:edison-microservice    文件:GraphiteReporterConfiguration.java   
private GraphiteSender graphiteSender(final MetricsProperties.Graphite graphiteMetricsProperties,
                                      final Predicate<String> graphiteFilterPredicate) {
    final InetSocketAddress address = new InetSocketAddress(graphiteMetricsProperties.getHost(), valueOf(graphiteMetricsProperties.getPort()));
    return new FilteringGraphiteSender(new Graphite(address), graphiteFilterPredicate);
}
项目:edison-microservice    文件:FilteringGraphiteSenderTest.java   
private void sendValue(String name, GraphiteSender delegate) throws IOException {
    new FilteringGraphiteSender(delegate, predicate).send(name, value, timestamp);
}
项目:Gobblin    文件:GraphiteReporter.java   
/**
 * Create a new {@link gobblin.metrics.graphite.GraphiteReporter.Builder} that uses
 * the simple name of {@link GraphiteReporter} as the reporter name.
 *
 * @param graphiteSender a {@link com.codahale.metrics.graphite.GraphiteSender} to
 *                       send metrics to Graphite
 * @return a new {@link gobblin.metrics.graphite.GraphiteReporter.Builder}
 */
public static Builder builder(GraphiteSender graphiteSender) {
  return builder(GraphiteReporter.class.getName(), graphiteSender);
}
项目:Gobblin    文件:GraphiteReporter.java   
/**
 * Create a new {@link gobblin.metrics.graphite.GraphiteReporter.Builder} that uses
 * a given reporter name.
 *
 * @param name the given reporter name
 * @param graphiteSender a {@link com.codahale.metrics.graphite.GraphiteSender}
 *                       to send metrics to Graphite
 * @return a new {@link gobblin.metrics.graphite.GraphiteReporter.Builder}
 */
public static Builder builder(String name, GraphiteSender graphiteSender) {
  return new Builder(name, graphiteSender);
}