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


Java GraphiteReporter.Builder方法代碼示例

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


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

示例1: 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

示例2: graphiteReporterBuilder

import com.codahale.metrics.graphite.GraphiteReporter; //導入方法依賴的package包/類
private GraphiteReporter.Builder graphiteReporterBuilder() {
  return GraphiteReporter
      .forRegistry(metricRegistry)
      .convertRatesTo(TimeUnit.SECONDS)
      .convertDurationsTo(TimeUnit.MILLISECONDS)
      .filter(MetricFilter.ALL)
      .prefixedWith(graphiteConfiguration.getPrefix());
}
 
開發者ID:HotelsDotCom,項目名稱:waggle-dance,代碼行數:9,代碼來源:MonitoringConfiguration.java

示例3: start

import com.codahale.metrics.graphite.GraphiteReporter; //導入方法依賴的package包/類
@Override
public void start() throws Exception {
  if (!graphiteConfiguration.isEnabled()) {
    LOG.info("Not reporting data points to graphite.");
    return;
  }

  final String prefix = buildGraphitePrefix();

  LOG.info("Reporting data points to graphite server {}:{} every {} seconds with prefix '{}' and predicates '{}'.", graphiteConfiguration.getHostname(),
      graphiteConfiguration.getPort(), graphiteConfiguration.getPeriodSeconds(), prefix, JavaUtils.COMMA_JOINER.join(graphiteConfiguration.getPredicates()));

  final Graphite graphite = new Graphite(new InetSocketAddress(graphiteConfiguration.getHostname(), graphiteConfiguration.getPort()));

  final GraphiteReporter.Builder reporterBuilder = GraphiteReporter.forRegistry(registry);

  if (!Strings.isNullOrEmpty(prefix)) {
    reporterBuilder.prefixedWith(prefix);
  }

  if (!graphiteConfiguration.getPredicates().isEmpty()) {
    reporterBuilder.filter(new MetricFilter() {
      @Override
      public boolean matches(String name, Metric metric) {
        for (String predicate : graphiteConfiguration.getPredicates()) {
          if (name.startsWith(predicate)) {
            return true;
          }
        }
        return false;
      }
    });
  }

  reporter = Optional.of(reporterBuilder.build(graphite));
  reporter.get().start(graphiteConfiguration.getPeriodSeconds(), TimeUnit.SECONDS);
}
 
開發者ID:PacktPublishing,項目名稱:Mastering-Mesos,代碼行數:38,代碼來源:SingularityGraphiteReporterManaged.java

示例4: testEnabled

import com.codahale.metrics.graphite.GraphiteReporter; //導入方法依賴的package包/類
@Test
public void testEnabled() {
    GraphiteReporter.Builder builder = spy(GraphiteReporter.forRegistry(registry));
    GraphiteReporter reporter = spy(builder.build(null));
    when(builder.build(isA(Graphite.class))).thenReturn(reporter);

    new GraphiteRegistry(registry, properties) {

        @Override
        Graphite getGraphite(String graphiteHost, int graphitePort) {
            assertThat(graphiteHost).isEqualTo(METRICS_HOST);
            assertThat(graphitePort).isEqualTo(METRICS_PORT);
            return super.getGraphite(graphiteHost, graphitePort);
        }

        @Override
        GraphiteReporter.Builder getBuilder(MetricRegistry metricRegistry) {
            super.getBuilder(metricRegistry);
            return builder;
        }
    };

    verify(builder).convertRatesTo(TimeUnit.SECONDS);
    verify(builder).convertDurationsTo(TimeUnit.MILLISECONDS);
    verify(builder).prefixedWith(METRICS_PREFIX);
    verify(builder).build(isA(Graphite.class));
    verify(reporter).start(GraphiteRegistry.REPORTER_PERIOD, TimeUnit.MINUTES);

    List<Event> events = recorder.play();
    assertThat(events).hasSize(1);
    Event event = events.get(0);
    assertThat(event.getLevel()).isEqualTo("INFO");
    assertThat(event.getMessage()).isEqualTo(GraphiteRegistry.INITIALIZING_MESSAGE);
}
 
開發者ID:jhipster,項目名稱:jhipster,代碼行數:35,代碼來源:GraphiteRegistryTest.java

示例5: start

import com.codahale.metrics.graphite.GraphiteReporter; //導入方法依賴的package包/類
@Override
public void start() throws Exception {
  if (!graphiteConfiguration.isEnabled()) {
    LOG.info("Not reporting data points to graphite.");
    return;
  }

  final String prefix = buildGraphitePrefix();
  final Map<String, String> tags = buildGraphiteTags();

  LOG.info("Reporting data points to graphite server {}:{} every {} seconds with prefix '{}', predicates '{}', and tags '{}'.", graphiteConfiguration.getHostname(),
      graphiteConfiguration.getPort(), graphiteConfiguration.getPeriodSeconds(), prefix, JavaUtils.COMMA_JOINER.join(graphiteConfiguration.getPredicates()), JavaUtils.COMMA_EQUALS_MAP_JOINER.join(tags));

  graphite = new GraphiteWithTags(new InetSocketAddress(graphiteConfiguration.getHostname(), graphiteConfiguration.getPort()), SocketFactory.getDefault(), Charsets.UTF_8, tags);

  final GraphiteReporter.Builder reporterBuilder = GraphiteReporter.forRegistry(registry);

  if (!Strings.isNullOrEmpty(prefix)) {
    reporterBuilder.prefixedWith(prefix);
  }

  if (!graphiteConfiguration.getPredicates().isEmpty()) {
    reporterBuilder.filter(new MetricFilter() {
      @Override
      public boolean matches(String name, Metric metric) {
        for (String predicate : graphiteConfiguration.getPredicates()) {
          if (name.startsWith(predicate)) {
            return true;
          }
        }
        return false;
      }
    });
  }

  reporter = reporterBuilder.build(graphite);
  reporter.start(graphiteConfiguration.getPeriodSeconds(), TimeUnit.SECONDS);
}
 
開發者ID:HubSpot,項目名稱:Singularity,代碼行數:39,代碼來源:SingularityGraphiteReporterManaged.java

示例6: start

import com.codahale.metrics.graphite.GraphiteReporter; //導入方法依賴的package包/類
@Override
public void start() throws Exception {
  if (!graphiteConfiguration.isEnabled()) {
    LOG.info("Not reporting data points to graphite.");
    return;
  }

  LOG.info("Reporting data points to graphite server {}:{} every {} seconds with prefix '{}' and predicates '{}'.", graphiteConfiguration.getHostname(),
      graphiteConfiguration.getPort(), graphiteConfiguration.getPeriodSeconds(), graphiteConfiguration.getPrefix(), JavaUtils.COMMA_JOINER.join(graphiteConfiguration.getPredicates()));

  final Graphite graphite = new Graphite(new InetSocketAddress(graphiteConfiguration.getHostname(), graphiteConfiguration.getPort()));

  final GraphiteReporter.Builder reporterBuilder = GraphiteReporter.forRegistry(registry);

  if (!Strings.isNullOrEmpty(graphiteConfiguration.getPrefix())) {
    reporterBuilder.prefixedWith(graphiteConfiguration.getPrefix());
  }

  if (!graphiteConfiguration.getPredicates().isEmpty()) {
    reporterBuilder.filter(new MetricFilter() {
      @Override
      public boolean matches(String name, Metric metric) {
        for (String predicate : graphiteConfiguration.getPredicates()) {
          if (name.startsWith(predicate)) {
            return true;
          }
        }
        return false;
      }
    });
  }

  reporter = Optional.of(reporterBuilder.build(graphite));
  reporter.get().start(graphiteConfiguration.getPeriodSeconds(), TimeUnit.SECONDS);
}
 
開發者ID:HubSpot,項目名稱:Baragon,代碼行數:36,代碼來源:BaragonAgentGraphiteReporterManaged.java

示例7: start

import com.codahale.metrics.graphite.GraphiteReporter; //導入方法依賴的package包/類
@Override
public void start() throws Exception {
  if (!graphiteConfiguration.isEnabled()) {
    LOG.info("Not reporting data points to graphite.");
    return;
  }

  final String prefix = buildGraphitePrefix();

  LOG.info("Reporting data points to graphite server {}:{} every {} seconds with prefix '{}' and predicates '{}'.", graphiteConfiguration.getHostname(),
      graphiteConfiguration.getPort(), graphiteConfiguration.getPeriodSeconds(), graphiteConfiguration.getPrefix(), JavaUtils.COMMA_JOINER.join(graphiteConfiguration.getPredicates()));

  final Graphite graphite = new Graphite(new InetSocketAddress(graphiteConfiguration.getHostname(), graphiteConfiguration.getPort()));

  final GraphiteReporter.Builder reporterBuilder = GraphiteReporter.forRegistry(registry);

  if (!Strings.isNullOrEmpty(graphiteConfiguration.getPrefix())) {
    reporterBuilder.prefixedWith(prefix);
  }

  if (!graphiteConfiguration.getPredicates().isEmpty()) {
    reporterBuilder.filter(new MetricFilter() {
      @Override
      public boolean matches(String name, Metric metric) {
        for (String predicate : graphiteConfiguration.getPredicates()) {
          if (name.startsWith(predicate)) {
            return true;
          }
        }
        return false;
      }
    });
  }

  reporter = Optional.of(reporterBuilder.build(graphite));
  reporter.get().start(graphiteConfiguration.getPeriodSeconds(), TimeUnit.SECONDS);
}
 
開發者ID:HubSpot,項目名稱:Baragon,代碼行數:38,代碼來源:BaragonGraphiteReporterManaged.java

示例8: getBuilder

import com.codahale.metrics.graphite.GraphiteReporter; //導入方法依賴的package包/類
GraphiteReporter.Builder getBuilder(MetricRegistry metricRegistry) {
    return GraphiteReporter.forRegistry(metricRegistry);
}
 
開發者ID:jhipster,項目名稱:jhipster,代碼行數:4,代碼來源:GraphiteRegistry.java


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