类com.codahale.metrics.graphite.Graphite源码实例Demo

下面列出了怎么用com.codahale.metrics.graphite.Graphite的API类实例代码及写法,或者点击链接到github查看源代码。

源代码1 项目: emissary   文件: MetricsManager.java
protected void initGraphiteReporter() {
    if (!this.conf.findBooleanEntry("GRAPHITE_METRICS_ENABLED", false)) {
        logger.debug("Graphite Metrics are disabled");
        return;
    }

    logger.debug("Graphite Metrics are enabled");

    final String prefix = this.conf.findStringEntry("GRAPHITE_METRICS_PREFIX", "emissary");
    final String host = this.conf.findStringEntry("GRAPHITE_METRICS_HOST", "localhost");
    final int port = this.conf.findIntEntry("GRAPHITE_METRICS_PORT", 2003);
    final int interval = this.conf.findIntEntry("GRAPHITE_METRICS_INTERVAL", -1);

    final TimeUnit intervalUnit = TimeUnit.valueOf(this.conf.findStringEntry("GRAPHITE_METRICS_INTERVAL_UNIT", TimeUnit.MINUTES.name()));
    final TimeUnit rateUnit = TimeUnit.valueOf(this.conf.findStringEntry("GRAPHITE_RATE_UNIT", TimeUnit.SECONDS.name()));
    final TimeUnit durationUnit = TimeUnit.valueOf(this.conf.findStringEntry("GRAPHITE_DURATION_UNIT", TimeUnit.MILLISECONDS.name()));

    final Graphite graphite = new Graphite(new InetSocketAddress(host, port));
    final GraphiteReporter graphiteReporter =
            GraphiteReporter.forRegistry(this.metrics).prefixedWith(prefix).convertRatesTo(rateUnit).convertDurationsTo(durationUnit)
                    .filter(MetricFilter.ALL).build(graphite);

    if (interval > 0) {
        graphiteReporter.start(interval, intervalUnit);
    }
}
 
源代码2 项目: jboot   文件: JbootGraphiteReporter.java
@Override
public void report(MetricRegistry metricRegistry) {

    JbootMetricGraphiteReporterConfig config = Jboot.config(JbootMetricGraphiteReporterConfig.class);

    if (StrUtil.isBlank(config.getHost())) {
        throw new NullPointerException("graphite reporter host must not be null, please config jboot.metrics.reporter.graphite.host in you properties.");
    }
    if (config.getPort() == null) {
        throw new NullPointerException("graphite reporter port must not be null, please config jboot.metrics.reporter.graphite.port in you properties.");
    }
    if (config.getPrefixedWith() == null) {
        throw new NullPointerException("graphite reporter prefixedWith must not be null, please config jboot.metrics.reporter.graphite.prefixedWith in you properties.");
    }

    Graphite graphite = new Graphite(new InetSocketAddress(config.getHost(), config.getPort()));

    GraphiteReporter reporter = GraphiteReporter.forRegistry(metricRegistry)
            .prefixedWith(config.getPrefixedWith())
            .convertRatesTo(TimeUnit.SECONDS)
            .convertDurationsTo(TimeUnit.MILLISECONDS)
            .filter(MetricFilter.ALL)
            .build(graphite);

    reporter.start(1, TimeUnit.MINUTES);
}
 
源代码3 项目: styx   文件: GraphiteReporterTest.java
@BeforeEach
public void setUp() {
    Clock clock = mock(Clock.class);
    graphite = mock(Graphite.class);

    MetricRegistry registry = mock(MetricRegistry.class);

    when(clock.getTime()).thenReturn(TIMESTAMP * 1000);
    reporter = forRegistry(registry)
            .withClock(clock)
            .prefixedWith("prefix")
            .convertRatesTo(SECONDS)
            .convertDurationsTo(MILLISECONDS)
            .filter(MetricFilter.ALL)
            .build(graphite);

    logging = new LoggingTestSupport(GraphiteReporter.class);
}
 
源代码4 项目: klask-io   文件: MetricsConfiguration.java
@PostConstruct
private void init() {
    if (jHipsterProperties.getMetrics().getGraphite().isEnabled()) {
        log.info("Initializing Metrics Graphite reporting");
        String graphiteHost = jHipsterProperties.getMetrics().getGraphite().getHost();
        Integer graphitePort = jHipsterProperties.getMetrics().getGraphite().getPort();
        String graphitePrefix = jHipsterProperties.getMetrics().getGraphite().getPrefix();
        Graphite graphite = new Graphite(new InetSocketAddress(graphiteHost, graphitePort));
        GraphiteReporter graphiteReporter = GraphiteReporter.forRegistry(metricRegistry)
            .convertRatesTo(TimeUnit.SECONDS)
            .convertDurationsTo(TimeUnit.MILLISECONDS)
            .prefixedWith(graphitePrefix)
            .build(graphite);
        graphiteReporter.start(1, TimeUnit.MINUTES);
    }
}
 
@PostConstruct
private void init() {
    if (jHipsterProperties.getMetrics().getGraphite().isEnabled()) {
        log.info("Initializing Metrics Graphite reporting");
        String graphiteHost = jHipsterProperties.getMetrics().getGraphite().getHost();
        Integer graphitePort = jHipsterProperties.getMetrics().getGraphite().getPort();
        String graphitePrefix = jHipsterProperties.getMetrics().getGraphite().getPrefix();
        Graphite graphite = new Graphite(new InetSocketAddress(graphiteHost, graphitePort));
        GraphiteReporter graphiteReporter = GraphiteReporter.forRegistry(metricRegistry)
            .convertRatesTo(TimeUnit.SECONDS)
            .convertDurationsTo(TimeUnit.MILLISECONDS)
            .prefixedWith(graphitePrefix)
            .build(graphite);
        graphiteReporter.start(1, TimeUnit.MINUTES);
    }
}
 
@PostConstruct
private void init() {
    if (jHipsterProperties.getMetrics().getGraphite().isEnabled()) {
        log.info("Initializing Metrics Graphite reporting");
        String graphiteHost = jHipsterProperties.getMetrics().getGraphite().getHost();
        Integer graphitePort = jHipsterProperties.getMetrics().getGraphite().getPort();
        String graphitePrefix = jHipsterProperties.getMetrics().getGraphite().getPrefix();
        Graphite graphite = new Graphite(new InetSocketAddress(graphiteHost, graphitePort));
        GraphiteReporter graphiteReporter = GraphiteReporter.forRegistry(metricRegistry)
            .convertRatesTo(TimeUnit.SECONDS)
            .convertDurationsTo(TimeUnit.MILLISECONDS)
            .prefixedWith(graphitePrefix)
            .build(graphite);
        graphiteReporter.start(1, TimeUnit.MINUTES);
    }
}
 
@PostConstruct
private void init() {
    if (jHipsterProperties.getMetrics().getGraphite().isEnabled()) {
        log.info("Initializing Metrics Graphite reporting");
        String graphiteHost = jHipsterProperties.getMetrics().getGraphite().getHost();
        Integer graphitePort = jHipsterProperties.getMetrics().getGraphite().getPort();
        String graphitePrefix = jHipsterProperties.getMetrics().getGraphite().getPrefix();
        Graphite graphite = new Graphite(new InetSocketAddress(graphiteHost, graphitePort));
        GraphiteReporter graphiteReporter = GraphiteReporter.forRegistry(metricRegistry)
            .convertRatesTo(TimeUnit.SECONDS)
            .convertDurationsTo(TimeUnit.MILLISECONDS)
            .prefixedWith(graphitePrefix)
            .build(graphite);
        graphiteReporter.start(1, TimeUnit.MINUTES);
    }
}
 
@PostConstruct
private void init() {
    if (jHipsterProperties.getMetrics().getGraphite().isEnabled()) {
        log.info("Initializing Metrics Graphite reporting");
        String graphiteHost = jHipsterProperties.getMetrics().getGraphite().getHost();
        Integer graphitePort = jHipsterProperties.getMetrics().getGraphite().getPort();
        String graphitePrefix = jHipsterProperties.getMetrics().getGraphite().getPrefix();
        Graphite graphite = new Graphite(new InetSocketAddress(graphiteHost, graphitePort));
        GraphiteReporter graphiteReporter = GraphiteReporter.forRegistry(metricRegistry)
            .convertRatesTo(TimeUnit.SECONDS)
            .convertDurationsTo(TimeUnit.MILLISECONDS)
            .prefixedWith(graphitePrefix)
            .build(graphite);
        graphiteReporter.start(1, TimeUnit.MINUTES);
    }
}
 
源代码9 项目: okapi   文件: DropwizardHelper.java
/**
 * Configure Dropwizard helper.
 * @param graphiteHost graphite server host
 * @param port  graphits server port
 * @param tu time unit
 * @param period reporting period
 * @param vopt Vert.x options
 * @param hostName logical hostname for this node (reporting)
 */
public static void config(String graphiteHost, int port, TimeUnit tu,
        int period, VertxOptions vopt, String hostName) {
  final String registryName = "okapi";
  MetricRegistry registry = SharedMetricRegistries.getOrCreate(registryName);

  DropwizardMetricsOptions metricsOpt = new DropwizardMetricsOptions();
  metricsOpt.setEnabled(true).setRegistryName(registryName);
  vopt.setMetricsOptions(metricsOpt);
  Graphite graphite = new Graphite(new InetSocketAddress(graphiteHost, port));
  final String prefix = "folio.okapi." + hostName;
  GraphiteReporter reporter = GraphiteReporter.forRegistry(registry)
          .prefixedWith(prefix)
          .build(graphite);
  reporter.start(period, tu);

  logger.info("Metrics remote {}:{} this {}", graphiteHost, port, prefix);
}
 
源代码10 项目: gpmr   文件: MetricsConfiguration.java
@PostConstruct
private void init() {
    if (jHipsterProperties.getMetrics().getGraphite().isEnabled()) {
        log.info("Initializing Metrics Graphite reporting");
        String graphiteHost = jHipsterProperties.getMetrics().getGraphite().getHost();
        Integer graphitePort = jHipsterProperties.getMetrics().getGraphite().getPort();
        String graphitePrefix = jHipsterProperties.getMetrics().getGraphite().getPrefix();
        Graphite graphite = new Graphite(new InetSocketAddress(graphiteHost, graphitePort));
        GraphiteReporter graphiteReporter = GraphiteReporter.forRegistry(metricRegistry)
            .convertRatesTo(TimeUnit.SECONDS)
            .convertDurationsTo(TimeUnit.MILLISECONDS)
            .prefixedWith(graphitePrefix)
            .build(graphite);
        graphiteReporter.start(1, TimeUnit.MINUTES);
    }
}
 
源代码11 项目: OpenIoE   文件: MetricsConfiguration.java
@PostConstruct
private void init() {
    if (jHipsterProperties.getMetrics().getGraphite().isEnabled()) {
        log.info("Initializing Metrics Graphite reporting");
        String graphiteHost = jHipsterProperties.getMetrics().getGraphite().getHost();
        Integer graphitePort = jHipsterProperties.getMetrics().getGraphite().getPort();
        String graphitePrefix = jHipsterProperties.getMetrics().getGraphite().getPrefix();
        Graphite graphite = new Graphite(new InetSocketAddress(graphiteHost, graphitePort));
        GraphiteReporter graphiteReporter = GraphiteReporter.forRegistry(metricRegistry)
            .convertRatesTo(TimeUnit.SECONDS)
            .convertDurationsTo(TimeUnit.MILLISECONDS)
            .prefixedWith(graphitePrefix)
            .build(graphite);
        graphiteReporter.start(1, TimeUnit.MINUTES);
    }
}
 
@Override
public GraphiteSender get() {
    HostAndPort hostAndPort = configuration.getAddress();
    String host = hostAndPort.getHost();
    int port = hostAndPort.getPortOrDefault(2003);

    switch (configuration.getProtocol()) {
        case PICKLE:
            return new PickledGraphite(
                    host,
                    port,
                    SocketFactory.getDefault(),
                    configuration.getCharset(),
                    configuration.getPickleBatchSize());
        case TCP:
            return new Graphite(host, port, SocketFactory.getDefault(), configuration.getCharset());
        case UDP:
            return new GraphiteUDP(host, port);
        default:
            throw new IllegalArgumentException("Unknown Graphite protocol \"" + configuration.getProtocol() + "\"");
    }
}
 
@PostConstruct
private void init() {
    Boolean graphiteEnabled = propertyResolver.getProperty(PROP_GRAPHITE_ENABLED, Boolean.class, false);
    if (graphiteEnabled) {
        log.info("Initializing Metrics Graphite reporting");
        String graphiteHost = propertyResolver.getRequiredProperty(PROP_HOST);
        Integer graphitePort = propertyResolver.getRequiredProperty(PROP_PORT, Integer.class);
        String graphitePrefix = propertyResolver.getProperty(PROP_GRAPHITE_PREFIX, String.class, "");

        Graphite graphite = new Graphite(new InetSocketAddress(graphiteHost, graphitePort));
        GraphiteReporter graphiteReporter = GraphiteReporter.forRegistry(metricRegistry)
                .convertRatesTo(TimeUnit.SECONDS)
                .convertDurationsTo(TimeUnit.MILLISECONDS)
                .prefixedWith(graphitePrefix)
                .build(graphite);
        graphiteReporter.start(1, TimeUnit.MINUTES);
    }
}
 
源代码14 项目: ServiceCutter   文件: MetricsConfiguration.java
@PostConstruct
private void init() {
    Boolean graphiteEnabled = propertyResolver.getProperty(PROP_GRAPHITE_ENABLED, Boolean.class, false);
    if (graphiteEnabled) {
        log.info("Initializing Metrics Graphite reporting");
        String graphiteHost = propertyResolver.getRequiredProperty(PROP_HOST);
        Integer graphitePort = propertyResolver.getRequiredProperty(PROP_PORT, Integer.class);
        String graphitePrefix = propertyResolver.getProperty(PROP_GRAPHITE_PREFIX, String.class, "");

        Graphite graphite = new Graphite(new InetSocketAddress(graphiteHost, graphitePort));
        GraphiteReporter graphiteReporter = GraphiteReporter.forRegistry(metricRegistry)
                .convertRatesTo(TimeUnit.SECONDS)
                .convertDurationsTo(TimeUnit.MILLISECONDS)
                .prefixedWith(graphitePrefix)
                .build(graphite);
        graphiteReporter.start(1, TimeUnit.MINUTES);
    }
}
 
源代码15 项目: expper   文件: MetricsConfiguration.java
@PostConstruct
private void init() {
    if (jHipsterProperties.getMetrics().getGraphite().isEnabled()) {
        log.info("Initializing Metrics Graphite reporting");
        String graphiteHost = jHipsterProperties.getMetrics().getGraphite().getHost();
        Integer graphitePort = jHipsterProperties.getMetrics().getGraphite().getPort();
        String graphitePrefix = jHipsterProperties.getMetrics().getGraphite().getPrefix();
        Graphite graphite = new Graphite(new InetSocketAddress(graphiteHost, graphitePort));
        GraphiteReporter graphiteReporter = GraphiteReporter.forRegistry(metricRegistry)
            .convertRatesTo(TimeUnit.SECONDS)
            .convertDurationsTo(TimeUnit.MILLISECONDS)
            .prefixedWith(graphitePrefix)
            .build(graphite);
        graphiteReporter.start(1, TimeUnit.MINUTES);
    }
}
 
源代码16 项目: usergrid   文件: MetricsFactoryImpl.java
@Inject
public MetricsFactoryImpl(MetricsFig metricsFig) {
    registry = new MetricRegistry();
    String metricsHost = metricsFig.getHost();
    if (!metricsHost.equals("false")) {
        Graphite graphite = new Graphite(new InetSocketAddress(metricsHost, 2003));
        graphiteReporter = GraphiteReporter.forRegistry(registry).prefixedWith("usergrid-metrics")
            .convertRatesTo(TimeUnit.SECONDS)
            .convertDurationsTo(TimeUnit.MILLISECONDS).filter(MetricFilter.ALL)
            .build(graphite);
        graphiteReporter.start(30, TimeUnit.SECONDS);
    } else {
        logger.warn("MetricsService:Logger not started.");
    }

    jmxReporter = JmxReporter.forRegistry(registry).build();
    jmxReporter.start();
}
 
源代码17 项目: fluo   文件: GraphiteReporterStarter.java
@Override
public List<AutoCloseable> start(Params params) {
  SimpleConfiguration config =
      new FluoConfiguration(params.getConfiguration()).getReporterConfiguration("graphite");

  if (!config.getBoolean("enable", false)) {
    return Collections.emptyList();
  }

  String host = config.getString("host");
  String prefix = config.getString("prefix", "");
  int port = config.getInt("port", 8080);
  TimeUnit rateUnit = TimeUnit.valueOf(config.getString("rateUnit", "seconds").toUpperCase());
  TimeUnit durationUnit =
      TimeUnit.valueOf(config.getString("durationUnit", "milliseconds").toUpperCase());

  Graphite graphite = new Graphite(host, port);
  GraphiteReporter reporter =
      GraphiteReporter.forRegistry(params.getMetricRegistry()).convertDurationsTo(durationUnit)
          .convertRatesTo(rateUnit).prefixedWith(prefix).build(graphite);
  reporter.start(config.getInt("frequency", 60), TimeUnit.SECONDS);

  log.info("Reporting metrics to graphite server {}:{}", host, port);

  return Collections.singletonList((AutoCloseable) reporter);
}
 
源代码18 项目: data-highway   文件: MetricsConfiguration.java
@Override
public void configureReporters(MetricRegistry registry) {
  if (graphiteEndpoint != null) {
    log.info("Starting Graphite reporter");
    reporter = registerReporter(GraphiteReporter
        .forRegistry(registry)
        .prefixedWith(MetricRegistry.name("road", "truck-park", "host", getHostname(), "road", roadName))
        .convertRatesTo(SECONDS)
        .convertDurationsTo(MILLISECONDS)
        .build(new Graphite(graphiteEndpoint)));
  }
}
 
源代码19 项目: prebid-server-java   文件: MetricsConfiguration.java
@Bean
@ConditionalOnProperty(prefix = "metrics.graphite", name = "enabled", havingValue = "true")
ScheduledReporter graphiteReporter(GraphiteProperties graphiteProperties, MetricRegistry metricRegistry) {
    final Graphite graphite = new Graphite(graphiteProperties.getHost(), graphiteProperties.getPort());
    final ScheduledReporter reporter = GraphiteReporter.forRegistry(metricRegistry)
            .prefixedWith(graphiteProperties.getPrefix())
            .build(graphite);
    reporter.start(graphiteProperties.getInterval(), TimeUnit.SECONDS);

    return reporter;
}
 
@Override
public ScheduledReporter newInstance(String qualifiedReplicaName) {
  InetSocketAddress address = new InetSocketAddressFactory().newInstance(graphiteHost);
  Graphite graphite = new Graphite(address);
  String prefix = DotJoiner.join(graphitePrefix, qualifiedReplicaName);
  return GraphiteReporter.forRegistry(runningMetricRegistry).prefixedWith(prefix).build(graphite);
}
 
源代码21 项目: phoenix-omid   文件: CodahaleMetricsProvider.java
private ScheduledReporter createAndGetConfiguredGraphiteReporter(String prefix, String graphiteHost) {
    LOG.info("Configuring Graphite reporter. Sendig data to host:port {}", graphiteHost);
    HostAndPort addr = HostAndPort.fromString(graphiteHost);

    final Graphite graphite = new Graphite(
            new InetSocketAddress(addr.getHostText(), addr.getPort()));

    return GraphiteReporter.forRegistry(metrics)
            .prefixedWith(prefix)
            .convertRatesTo(TimeUnit.SECONDS)
            .convertDurationsTo(TimeUnit.MILLISECONDS)
            .filter(MetricFilter.ALL)
            .build(graphite);
}
 
static Graphite getGraphite(MetricsReporterConf config) {
  if (config.getGraphiteHost() == null || config.getGraphitePort() == 0) {
    LOGGER.warn("No Graphite built!");
    return null;
  }
  InetSocketAddress graphiteAddress =
      new InetSocketAddress(config.getGraphiteHost(), config.getGraphitePort());
  LOGGER.info(String.format("Trying to connect to Graphite with address: %s",
      graphiteAddress.toString()));
  return new Graphite(graphiteAddress);
}
 
源代码23 项目: replicator   文件: GraphiteMetrics.java
@Override
protected ScheduledReporter getReporter(Map<String, Object> configuration, MetricRegistry registry) {
    Object namespace = configuration.get(Configuration.GRAPHITE_NAMESPACE);
    Object hostname = configuration.get(Configuration.GRAPHITE_HOSTNAME);
    Object port = configuration.get(Configuration.GRAPHITE_PORT);

    Objects.requireNonNull(namespace, String.format("Configuration required: %s", Configuration.GRAPHITE_NAMESPACE));
    Objects.requireNonNull(hostname, String.format("Configuration required: %s", Configuration.GRAPHITE_HOSTNAME));
    Objects.requireNonNull(port, String.format("Configuration required: %s", Configuration.GRAPHITE_PORT));

    registry.register(MetricRegistry.name("jvm", "gc"), new GarbageCollectorMetricSet());
    registry.register(MetricRegistry.name("jvm", "threads"), new ThreadStatesGaugeSet());
    registry.register(MetricRegistry.name("jvm", "classes"), new ClassLoadingGaugeSet());
    registry.register(MetricRegistry.name("jvm", "fd"), new FileDescriptorRatioGauge());
    registry.register(MetricRegistry.name("jvm", "memory"), new MemoryUsageGaugeSet());

    ScheduledReporter reporter = GraphiteReporter
            .forRegistry(registry)
            .prefixedWith(namespace.toString())
            .convertRatesTo(TimeUnit.SECONDS)
            .convertDurationsTo(TimeUnit.SECONDS)
            .build(new Graphite(new InetSocketAddress(hostname.toString(), Integer.parseInt(port.toString()))));

    reporter.start(1L, TimeUnit.MINUTES);

    return reporter;
}
 
源代码24 项目: okapi   文件: MetricsTest.java
@Before
public void setUp(TestContext context) {
  String graphiteHost = System.getProperty("graphiteHost");

  final String registryName = "okapi";
  MetricRegistry registry = SharedMetricRegistries.getOrCreate(registryName);

  // Note the setEnabled (true or false)
  DropwizardMetricsOptions metricsOpt = new DropwizardMetricsOptions().
          setEnabled(false).setRegistryName(registryName);

  vertx = Vertx.vertx(new VertxOptions().setMetricsOptions(metricsOpt));

  reporter1 = ConsoleReporter.forRegistry(registry).build();
  reporter1.start(1, TimeUnit.SECONDS);

  if (graphiteHost != null) {
    Graphite graphite = new Graphite(new InetSocketAddress(graphiteHost, 2003));
    reporter2 = GraphiteReporter.forRegistry(registry)
            .prefixedWith("okapiserver")
            .build(graphite);
    reporter2.start(1, TimeUnit.MILLISECONDS);
  }

  DeploymentOptions opt = new DeploymentOptions()
    .setConfig(new JsonObject().put("port", Integer.toString(port)));


  vertx.deployVerticle(MainVerticle.class.getName(),
          opt, context.asyncAssertSuccess());
  httpClient = vertx.createHttpClient();
}
 
源代码25 项目: riposte   文件: DefaultGraphiteReporterFactory.java
@Override
public synchronized Reporter getReporter(MetricRegistry registry) {
    if (null == reporter) {
        Graphite graphite = new Graphite(new InetSocketAddress(graphiteURL, graphitePort));
        reporter = GraphiteReporter.forRegistry(registry)
                                   .prefixedWith(prefix)
                                   .convertRatesTo(TimeUnit.SECONDS)
                                   .convertDurationsTo(TimeUnit.MILLISECONDS)
                                   .filter(MetricFilter.ALL)
                                   .build(graphite);
    }
    return reporter;
}
 
@Override
public void init(List<KafkaMetric> list) {
  super.init(list);
  InetSocketAddress address = new InetSocketAddress(
      config.getString(DropwizardReporterConfig.GRAPHITE_HOST_PROPERTY_NAME),
      config.getInt(DropwizardReporterConfig.GRAPHITE_PORT_PROPERTY_NAME));
  graphite = new Graphite(address);
  reporter = GraphiteReporter.forRegistry(registry)
      .prefixedWith(config.getString(DropwizardReporterConfig.GRAPHITE_PREFIX_PROPERTY_NAME))
      .build(graphite);
  LOGGER.info("Starting the reporter");
  reporter.start(11, TimeUnit.SECONDS);
}
 
@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());
}
 
源代码28 项目: find   文件: MetricsConfiguration.java
@Bean
@ConditionalOnProperty(GRAPHITE_HOST_PROPERTY_KEY)
public GraphiteReporter graphiteReporter(final MetricRegistry registry,
                                         @Value(GRAPHITE_HOST_PROPERTY) final String graphiteHost,
                                         @Value(GRAPHITE_PORT_PROPERTY) final int graphitePort,
                                         @Value(GRAPHITE_SCHEDULE_INTERVAL_PROPERTY) final int graphiteScheduleInterval) {
    final Graphite graphite = new Graphite(new InetSocketAddress(graphiteHost, graphitePort));
    final GraphiteReporter reporter = GraphiteReporter.forRegistry(registry)
        .prefixedWith(GRAPHITE_PREFIX)
        .build(graphite);
    reporter.start(graphiteScheduleInterval, TimeUnit.MILLISECONDS);
    return reporter;
}
 
@PostConstruct
private void init() {
	if (graphiteEnabled) {
		log.info("Initializing Metrics Graphite reporting");
		Graphite graphite = new Graphite(new InetSocketAddress(
				graphiteHost, graphitePort));
		GraphiteReporter graphiteReporter = GraphiteReporter
				.forRegistry(metricRegistry)
				.convertRatesTo(TimeUnit.SECONDS)
				.convertDurationsTo(TimeUnit.MILLISECONDS).build(graphite);
		graphiteReporter.start(1, TimeUnit.MINUTES);
	}
}
 
@PostConstruct
private void init() {
	if (graphiteEnabled) {
		log.info("Initializing Metrics Graphite reporting");
		Graphite graphite = new Graphite(new InetSocketAddress(
				graphiteHost, graphitePort));
		GraphiteReporter graphiteReporter = GraphiteReporter
				.forRegistry(metricRegistry)
				.convertRatesTo(TimeUnit.SECONDS)
				.convertDurationsTo(TimeUnit.MILLISECONDS).build(graphite);
		graphiteReporter.start(1, TimeUnit.MINUTES);
	}
}
 
 类所在包
 同包方法