當前位置: 首頁>>代碼示例>>Java>>正文


Java Graphite類代碼示例

本文整理匯總了Java中com.codahale.metrics.graphite.Graphite的典型用法代碼示例。如果您正苦於以下問題:Java Graphite類的具體用法?Java Graphite怎麽用?Java Graphite使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


Graphite類屬於com.codahale.metrics.graphite包,在下文中一共展示了Graphite類的11個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: config

import com.codahale.metrics.graphite.Graphite; //導入依賴的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: get

import com.codahale.metrics.graphite.Graphite; //導入依賴的package包/類
@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() + "\"");
    }
}
 
開發者ID:graylog-labs,項目名稱:graylog-plugin-metrics-reporter,代碼行數:18,代碼來源:GraphiteSenderProvider.java

示例3: init

import com.codahale.metrics.graphite.Graphite; //導入依賴的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

示例4: report

import com.codahale.metrics.graphite.Graphite; //導入依賴的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

示例5: init

import com.codahale.metrics.graphite.Graphite; //導入依賴的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

示例6: init

import com.codahale.metrics.graphite.Graphite; //導入依賴的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

示例7: GraphiteReporter

import com.codahale.metrics.graphite.Graphite; //導入依賴的package包/類
/**
 * Start a metrics graphite reporter.
 */
public GraphiteReporter(Configuration conf) {
    Configuration.MetricsConfig.ReporterConfig metricConf = conf.getReporterConfig(GraphiteReporter.type);

    frequency = conf.getReportingFrequency();

    String[] urlSplit = metricConf.url.split(":");
    String hostName = urlSplit[0];
    int port = 3002;
    if (urlSplit.length > 1) {
        port = Integer.parseInt(urlSplit[1]);
    }

    reporter = com.codahale.metrics.graphite.GraphiteReporter
            .forRegistry(Metrics.registry)
            .prefixedWith(metricConf.namespace)
            .convertRatesTo(TimeUnit.SECONDS)
            .convertDurationsTo(TimeUnit.SECONDS)
            .build(new Graphite(new InetSocketAddress(hostName, port)));
}
 
開發者ID:mysql-time-machine,項目名稱:replicator,代碼行數:23,代碼來源:GraphiteReporter.java

示例8: startMetricReporters

import com.codahale.metrics.graphite.Graphite; //導入依賴的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

示例9: configureReporters

import com.codahale.metrics.graphite.Graphite; //導入依賴的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

示例10: GraphiteRegistry

import com.codahale.metrics.graphite.Graphite; //導入依賴的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

示例11: init

import com.codahale.metrics.graphite.Graphite; //導入依賴的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


注:本文中的com.codahale.metrics.graphite.Graphite類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。