当前位置: 首页>>代码示例>>Java>>正文


Java GraphiteReporter类代码示例

本文整理汇总了Java中com.codahale.metrics.graphite.GraphiteReporter的典型用法代码示例。如果您正苦于以下问题:Java GraphiteReporter类的具体用法?Java GraphiteReporter怎么用?Java GraphiteReporter使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


GraphiteReporter类属于com.codahale.metrics.graphite包,在下文中一共展示了GraphiteReporter类的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: config

import com.codahale.metrics.graphite.GraphiteReporter; //导入依赖的package包/类
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:" + graphiteHost + ":"
          + port + " this:" + prefix);
}
 
开发者ID:folio-org,项目名称:okapi,代码行数:19,代码来源:DropwizardHelper.java

示例2: init

import com.codahale.metrics.graphite.GraphiteReporter; //导入依赖的package包/类
@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);
    }
}
 
开发者ID:GastonMauroDiaz,项目名称:buenojo,代码行数:17,代码来源:MetricsConfiguration.java

示例3: report

import com.codahale.metrics.graphite.GraphiteReporter; //导入依赖的package包/类
@Override
public void report(MetricRegistry metricRegistry) {

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

    if (StringUtils.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);
}
 
开发者ID:yangfuhai,项目名称:jboot,代码行数:27,代码来源:JbootGraphiteReporter.java

示例4: init

import com.codahale.metrics.graphite.GraphiteReporter; //导入依赖的package包/类
@PostConstruct
private void init() {
    if (properties.getMetrics().getGraphite().isEnabled()) {
        log.info("Initializing Metrics Graphite reporting");
        String graphiteHost = properties.getMetrics().getGraphite().getHost();
        Integer graphitePort = properties.getMetrics().getGraphite().getPort();
        String graphitePrefix = properties.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);
    }
}
 
开发者ID:quanticc,项目名称:ugc-bot-redux,代码行数:17,代码来源:MetricsConfiguration.java

示例5: init

import com.codahale.metrics.graphite.GraphiteReporter; //导入依赖的package包/类
@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);
    }
}
 
开发者ID:VHAINNOVATIONS,项目名称:BCDS,代码行数:19,代码来源:MetricsConfiguration.java

示例6: startMetricReporters

import com.codahale.metrics.graphite.GraphiteReporter; //导入依赖的package包/类
protected void startMetricReporters(int metricsReportingInterval, int graphitePort, String graphiteHostname, MetricRegistry metricRegistry) {
    if (shouldCreateLoggingMetricsReporter()) {
        registerReporter(Slf4jReporter.forRegistry(metricRegistry)
                .convertDurationsTo(MILLISECONDS)
                .convertRatesTo(SECONDS)
                .withLoggingLevel(TRACE)
                .outputTo(getLogger(ReverseProxyFilter.class))
                .build()
        ).start(metricsReportingInterval, SECONDS);
    }
    if (shouldCreateGraphiteMetricsReporter()) {
        Graphite graphite = new Graphite(graphiteHostname, graphitePort);
        registerReporter(GraphiteReporter.forRegistry(metricRegistry)
                .convertDurationsTo(MILLISECONDS)
                .convertRatesTo(SECONDS)
                .build(graphite)
        ).start(metricsReportingInterval, SECONDS);
    }
}
 
开发者ID:mkopylec,项目名称:charon-spring-boot-starter,代码行数:20,代码来源:CharonConfiguration.java

示例7: configureReporters

import com.codahale.metrics.graphite.GraphiteReporter; //导入依赖的package包/类
@Override
public void configureReporters(MetricRegistry metricRegistry) {

    registerReporter(Slf4jReporter.forRegistry(metricRegistry)
            .outputTo(LoggerFactory.getLogger("metrics"))
            .convertRatesTo(TimeUnit.SECONDS)
            .convertDurationsTo(TimeUnit.MILLISECONDS)
            .build()).start(1, TimeUnit.MINUTES);

    // set DNS ttl to 60 per Hosted Graphite documentation
    java.security.Security.setProperty("networkaddress.cache.ttl", "60");
    Graphite graphite = new Graphite(new InetSocketAddress(graphiteHost, graphitePort));

    registerReporter(GraphiteReporter.forRegistry(metricRegistry)
            .convertRatesTo(TimeUnit.SECONDS)
            .convertDurationsTo(TimeUnit.MILLISECONDS)
            .prefixedWith(graphiteApiKey)
            .build(graphite)).start(1, TimeUnit.MINUTES);
}
 
开发者ID:rpmartz,项目名称:booktrackr,代码行数:20,代码来源:MetricsConfig.java

示例8: GraphiteRegistry

import com.codahale.metrics.graphite.GraphiteReporter; //导入依赖的package包/类
public GraphiteRegistry(MetricRegistry metricRegistry, JHipsterProperties jHipsterProperties) {
    this.jHipsterProperties = jHipsterProperties;
    if (this.jHipsterProperties.getMetrics().getGraphite().isEnabled()) {
        log.info(INITIALIZING_MESSAGE);
        String graphiteHost = jHipsterProperties.getMetrics().getGraphite().getHost();
        Integer graphitePort = jHipsterProperties.getMetrics().getGraphite().getPort();
        String graphitePrefix = jHipsterProperties.getMetrics().getGraphite().getPrefix();
        Graphite graphite = getGraphite(graphiteHost, graphitePort);
        GraphiteReporter graphiteReporter = getBuilder(metricRegistry)
            .convertRatesTo(TimeUnit.SECONDS)
            .convertDurationsTo(TimeUnit.MILLISECONDS)
            .prefixedWith(graphitePrefix)
            .build(graphite);
        graphiteReporter.start(REPORTER_PERIOD, TimeUnit.MINUTES);
    }
}
 
开发者ID:jhipster,项目名称:jhipster,代码行数:17,代码来源:GraphiteRegistry.java

示例9: init

import com.codahale.metrics.graphite.GraphiteReporter; //导入依赖的package包/类
private static void init() {
  // Init JMX reporter
  reporter = JmxReporter.forRegistry(registry).build();
  reporter.start();
  // Init graphite reporter
  Graphite graphite = getGraphite();
  GraphiteReporter graphiteReporter;
  if (graphite == null) {
    graphiteReporter = null;
  } else {
    graphiteReporter =
        GraphiteReporter.forRegistry(registry).prefixedWith(PREFIX).convertRatesTo(TimeUnit.SECONDS)
            .convertDurationsTo(TimeUnit.MILLISECONDS).filter(MetricFilter.ALL).build(graphite);
    graphiteReporter.start(AuditConfig.GRAPHITE_REPORT_PERIOD_SEC, TimeUnit.SECONDS);
  }
}
 
开发者ID:uber,项目名称:chaperone,代码行数:17,代码来源:Metrics.java

示例10: setupGraphiteReporter

import com.codahale.metrics.graphite.GraphiteReporter; //导入依赖的package包/类
private void setupGraphiteReporter(Configuration configuration) {
  boolean graphiteEnabled = configuration.getBoolean("graphite.enabled", false);

  if (graphiteEnabled) {
    String   host        = configuration.getString("graphite.host", "localhost");
    int      port        = configuration.getInt("graphite.port", 80);
    String   prefix      = configuration.getString("graphite.prefix", "");
    long     period      = configuration.getLong("graphite.period", 1l);
    TimeUnit periodUnit  = TimeUnit.valueOf(configuration.getString("graphite.periodUnit", "MINUTES"));

    final Graphite graphite = new Graphite(new InetSocketAddress(host, port));
    GraphiteReporter.Builder reportBuilder = GraphiteReporter.forRegistry(metricRegistry)
      .convertRatesTo(TimeUnit.SECONDS)
      .convertDurationsTo(TimeUnit.MILLISECONDS)
      .filter(MetricFilter.ALL);

    if (prefix != null && !prefix.isEmpty()) {
      reportBuilder.prefixedWith(prefix);
    }

    graphiteReporter = reportBuilder.build(graphite);

    graphiteReporter.start(period, periodUnit);
  }
}
 
开发者ID:shelajev,项目名称:cgif,代码行数:26,代码来源:Global.java


注:本文中的com.codahale.metrics.graphite.GraphiteReporter类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。