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


Java ScheduledReporter类代码示例

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


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

示例1: testPointsSent

import com.codahale.metrics.ScheduledReporter; //导入依赖的package包/类
@Test
public void testPointsSent() throws Exception {
    MetricRegistry registry = new MetricRegistry();
    new BasicJvmMetrics(registry);

    ScheduledReporter reporter = new ScheduledReporter(registry, "test", MetricFilter.ALL,
            TimeUnit.SECONDS, TimeUnit.MILLISECONDS) {

        @Override
        public void report(SortedMap<String, Gauge> gauges, SortedMap<String, Counter> counters,
                           SortedMap<String, Histogram> histograms,
                           SortedMap<String, Meter> meters, SortedMap<String, Timer> timers) {
            Assert.assertFalse(gauges.isEmpty());
            Assert.assertNotNull(gauges.get("jvm.uptime"));
            for (Map.Entry<String, Gauge> entry : gauges.entrySet()) {
                Assert.assertNotNull(entry.getValue().getValue());
            }
        }
    };

    reporter.report();
    reporter.close();
}
 
开发者ID:signalfx,项目名称:signalfx-java,代码行数:24,代码来源:BasicJvmMetrisTest.java

示例2: build

import com.codahale.metrics.ScheduledReporter; //导入依赖的package包/类
@Override
public ScheduledReporter build(final MetricRegistry registry) {
  final Sender builtSender = new Sender(sender.build(registry));
  final DropwizardTransformer transformer = new DropwizardTransformer(
    globalTags,
    DropwizardMeasurementParser.withTemplates(metricTemplates),
    groupCounters,
    groupGauges,
    getRateUnit(),
    getDurationUnit()
  );

  return new InfluxDbMeasurementReporter(
    builtSender,
    registry,
    getFilter(),
    getRateUnit(),
    getDurationUnit(),
    Clock.systemUTC(),
    transformer
  );
}
 
开发者ID:kickstarter,项目名称:dropwizard-influxdb-reporter,代码行数:23,代码来源:InfluxDbMeasurementReporterFactory.java

示例3: createAndGetConfiguredCSVReporter

import com.codahale.metrics.ScheduledReporter; //导入依赖的package包/类
private ScheduledReporter createAndGetConfiguredCSVReporter(String prefix, String csvDir) throws IOException {
    // NOTE:
    // 1) metrics output files are exclusive to a given process
    // 2) the output directory must exist
    // 3) if output files already exist they are not overwritten and there is no metrics output
    File outputDir;
    if (Strings.isNullOrEmpty(prefix)) {
        outputDir = new File(csvDir, prefix);
    } else {
        outputDir = new File(csvDir);
    }
    FileUtils.forceMkdir(outputDir);
    LOG.info("Configuring stats with csv output to directory [{}]", outputDir.getAbsolutePath());
    return CsvReporter.forRegistry(metrics)
            .convertRatesTo(TimeUnit.SECONDS)
            .convertDurationsTo(TimeUnit.MILLISECONDS)
            .build(outputDir);
}
 
开发者ID:apache,项目名称:incubator-omid,代码行数:19,代码来源:CodahaleMetricsProvider.java

示例4: createReporter

import com.codahale.metrics.ScheduledReporter; //导入依赖的package包/类
private ScheduledReporter createReporter(String json)
        throws Exception {
    ObjectMapper objectMapper = Jackson.newObjectMapper();
    ReporterFactory reporterFactory = objectMapper.readValue(json, ReporterFactory.class);

    assertTrue(reporterFactory instanceof DatadogExpansionFilteredReporterFactory);
    DatadogExpansionFilteredReporterFactory datadogReporterFactory = (DatadogExpansionFilteredReporterFactory) reporterFactory;

    // Replace the transport with our own mock for testing

    Transport transport = mock(Transport.class);
    when(transport.prepare()).thenReturn(_request);

    AbstractTransportFactory transportFactory = mock(AbstractTransportFactory.class);
    when(transportFactory.build()).thenReturn(transport);

    datadogReporterFactory.setTransport(transportFactory);

    // Build the reporter
    return datadogReporterFactory.build(_metricRegistry);
}
 
开发者ID:bazaarvoice,项目名称:emodb,代码行数:22,代码来源:DatadogMetricFilterTest.java

示例5: startMetricReporting

import com.codahale.metrics.ScheduledReporter; //导入依赖的package包/类
/**
 * Start metric reporting.
 *
 * @param properties configuration properties
 */
public void startMetricReporting(Properties properties) {
  if (this.reportingStarted) {
    LOGGER.warn("Metric reporting has already started");
    return;
  }

  long reportInterval = Long.parseLong(properties.getProperty(ConfigurationKeys.METRICS_REPORT_INTERVAL_KEY,
      ConfigurationKeys.DEFAULT_METRICS_REPORT_INTERVAL));

  buildJmxMetricReporter(properties);
  if (this.jmxReporter.isPresent()) {
    this.jmxReporter.get().start();
  }

  buildFileMetricReporter(properties);
  buildKafkaMetricReporter(properties);
  buildCustomMetricReporters(properties);

  for (ScheduledReporter reporter : this.scheduledReporters) {
    reporter.start(reportInterval, TimeUnit.MILLISECONDS);
  }

  this.reportingStarted = true;
}
 
开发者ID:Hanmourang,项目名称:Gobblin,代码行数:30,代码来源:GobblinMetrics.java

示例6: build

import com.codahale.metrics.ScheduledReporter; //导入依赖的package包/类
@Override
public ScheduledReporter build(MetricRegistry metricRegistry) {
    MetricAdapterFactory metricAdapterFactory = new MetricAdapterFactoryImpl(
            new DefaultMetricDescriptorLookup(),
            new DefaultMetricNameTranslator(getReplacements()));

    MonitorableRegistry monitorableRegistry = MonitorableRegistry.getNamedInstance(getRegistryName());

    PcpMmvWriter pcpMmvWriter = new PcpMmvWriter(getPcpName(), IdentifierSourceSet.DEFAULT_SET);
    pcpMmvWriter.setClusterIdentifier(getClusterIdentifier());

    MonitoringView monitoringView = new PcpMonitorBridge(pcpMmvWriter);

    DynamicMonitoringView dynamicMonitoringView = new DynamicMonitoringView(monitorableRegistry, monitoringView, quietPeriod);

    return new ParfaitReporter(metricRegistry,
            monitorableRegistry,
            dynamicMonitoringView,
            metricAdapterFactory,
            getRateUnit(),
            getDurationUnit(),
            getFilter(),
            getPrefix());
}
 
开发者ID:performancecopilot,项目名称:parfait,代码行数:25,代码来源:ParfaitReporterFactory.java

示例7: createElasticSearchReporter

import com.codahale.metrics.ScheduledReporter; //导入依赖的package包/类
/**
 * Create a new ElasticSearch reporter.
 *
 * @param metricRegistry
 *            the registry to report on
 * @param config
 *            the configuration map (see {@link MetricsFactory})
 * @return the reporter instance
 */
public static ScheduledReporter createElasticSearchReporter(MetricRegistry metricRegistry,
		Map<String, Object> config) throws BaleenException {
	try {
		String server = (String) config.getOrDefault("server", "localhost:9200");
		String index = (String) config.getOrDefault("index", "metrics");
		int timeout = (int) config.getOrDefault("timeout", 1000);
		int bulkSize = (int) config.getOrDefault("bulkSize", 2500);

		return ElasticsearchReporter.forRegistry(metricRegistry).convertRatesTo(getRatesUnit(config))
				.convertDurationsTo(getDurationUnit(config)).bulkSize(bulkSize).hosts(server).index(index)
				.timeout(timeout).build();
	} catch (IOException e) {
		throw new BaleenException("Unable to create ElasticSearch reporter", e);
	}
}
 
开发者ID:dstl,项目名称:baleen,代码行数:25,代码来源:ReporterUtils.java

示例8: onPassivate

import com.codahale.metrics.ScheduledReporter; //导入依赖的package包/类
@Override
public void onPassivate( Application application )
{
    requestTimers.values().forEach( t -> t.stop() );
    requestTimers = null;
    reporters.forEach(
        r ->
        {
            if( r instanceof ScheduledReporter )
            {
                ( (ScheduledReporter) r ).stop();
            }
            else if( r instanceof JmxReporter )
            {
                ( (JmxReporter) r ).stop();
            }
        }
    );
    reporters = null;
    api = null;
    eventRegistration.unregister();
    eventRegistration = null;
    SharedMetricRegistries.clear();
    SharedHealthCheckRegistries.clear();
}
 
开发者ID:werval,项目名称:werval,代码行数:26,代码来源:MetricsPlugin.java

示例9: build

import com.codahale.metrics.ScheduledReporter; //导入依赖的package包/类
@Override
public ScheduledReporter build(MetricRegistry registry) {

    final EnumSet<Expansions> expansions = EnumSet.of(COUNT, RATE_1_MINUTE,
            RATE_15_MINUTE, MEDIAN, P95, P99);
    final DatadogReporter reporter;
    try {
        reporter = new DatadogReporter.Builder(registry).withEC2Host()
                .withApiKey(apiKey).withExpansions(expansions).build();
    } catch (IOException e) {
        e.printStackTrace();
        throw new IllegalStateException(
                "Unable to construct DataDog metrics reporter", e);
    }
    return reporter;
}
 
开发者ID:skidder,项目名称:metrics-datadog-factory,代码行数:17,代码来源:DatadogReporterFactory.java

示例10: build

import com.codahale.metrics.ScheduledReporter; //导入依赖的package包/类
/**
 * Builds a {@link ScheduledReporter} with the given properties, sending
 * metrics using the given InfluxDB.
 *
 * @return a {@link ScheduledReporter}
 */
public ScheduledReporter build() {
	ScheduledReporter reporter;

	switch (influxdbVersion) {
	case V08:
		Influxdb influxdb = buildInfluxdb();
		reporter = (executor == null)
				? new ReporterV08(registry, influxdb, clock, prefix, rateUnit, durationUnit, filter, skipIdleMetrics)
				: new ReporterV08(registry, influxdb, clock, prefix, rateUnit, durationUnit, filter, skipIdleMetrics, executor)
				;
		break;
	default:
		Sender s = buildSender();
		reporter = executor == null
				? new MeasurementReporter(s, registry, filter, rateUnit, durationUnit, clock, tags, transformer)
				: new MeasurementReporter(s, registry, filter, rateUnit, durationUnit, clock, tags, transformer, executor)
				;
	}
	return reporter;
}
 
开发者ID:davidB,项目名称:metrics-influxdb,代码行数:27,代码来源:InfluxdbReporter.java

示例11: builder_api_with_tags

import com.codahale.metrics.ScheduledReporter; //导入依赖的package包/类
@Test
public void builder_api_with_tags() {
	String tagKey = "tag-name";
	String tagValue = "tag-value";

	Builder builder = InfluxdbReporter
			.forRegistry(registry)
			.tag(tagKey, tagValue)
			.protocol(new HttpInfluxdbProtocol());

	assertThat(builder.tags, notNullValue());
	assertThat(builder.tags, hasEntry(tagKey, tagValue));

	ScheduledReporter reporter = builder.build();
	assertThat(reporter, notNullValue());
}
 
开发者ID:davidB,项目名称:metrics-influxdb,代码行数:17,代码来源:InfluxdbReporterBuilderTest.java

示例12: NbdStatsReporter

import com.codahale.metrics.ScheduledReporter; //导入依赖的package包/类
@Inject
public NbdStatsReporter(MetricRegistry metrics) {
    ScheduledReporter reporter = Slf4jReporter.forRegistry(metrics)
            .withLoggingLevel(Slf4jReporter.LoggingLevel.DEBUG)
            .outputTo(LOGGER)
            .convertRatesTo(TimeUnit.SECONDS)
            .convertDurationsTo(TimeUnit.MILLISECONDS)
            .build();
    reporter.start(5, TimeUnit.SECONDS);
}
 
开发者ID:MineboxOS,项目名称:minebox,代码行数:11,代码来源:NbdStatsReporter.java

示例13: shutDown

import com.codahale.metrics.ScheduledReporter; //导入依赖的package包/类
@Override
protected void shutDown() throws Exception {
    for (ScheduledReporter entry : reporter.values()) {
        LOG.debug("Stopping metrics reporter: {}", entry);
        entry.stop();
    }
}
 
开发者ID:DevOpsStudio,项目名称:Re-Collector,代码行数:8,代码来源:MetricService.java

示例14: newInstance

import com.codahale.metrics.ScheduledReporter; //导入依赖的package包/类
@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);
}
 
开发者ID:HotelsDotCom,项目名称:circus-train,代码行数:8,代码来源:GraphiteScheduledReporterFactory.java

示例15: build

import com.codahale.metrics.ScheduledReporter; //导入依赖的package包/类
public ScheduledReporter build(MetricRegistry registry) {
  try {
    return new ApptuitReporter(registry, getFilter(), getRateUnit(), getDurationUnit(),
        globalTags, apiKey, apiUrl != null ? new URL(apiUrl) : null, reportingMode);
  } catch (MalformedURLException e) {
    throw new IllegalArgumentException(e);
  }
}
 
开发者ID:ApptuitAI,项目名称:JInsight,代码行数:9,代码来源:ApptuitReporterFactory.java


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