@Override public Callable<FastForwardLifecycle> setup( final SemanticMetricRegistry metricRegistry, final MetricId metricId, final String searchDomain ) { final FastForwardReporter.Builder builder = FastForwardReporter .forRegistry(metricRegistry) .schedule(TimeUnit.SECONDS, interval) .tagExtractor(new EnvironmentTagExtractor()) .prefix(metricId); host.ifPresent(builder::host); port.ifPresent(builder::port); return () -> { final FastForwardReporter reporter = builder.build(); reporter.start(); return reporter::stop; }; } }
private FastForwardHttpReporter( SemanticMetricRegistry registry, MetricId prefix, TimeUnit unit, long duration, HttpClient client, Set<Percentile> histogramPercentiles, Clock clock ) { this(registry, prefix, unit, duration, client, histogramPercentiles, clock, new NoopTagExtractor()); }
public EnvironmentTagExtractor(Supplier<Map<String, String>> enviromentSupplier) { this.environmentTags = filterEnvironmentTags(enviromentSupplier.get()); }
private void send(Metric metric) { final Map<String, String> tags = tagExtractor.addTags(metric.getAttributes()); final Metric taggedMetric = metric.attributes(tags); try { client.send(taggedMetric); } catch (IOException e) { log.error("Failed to send metric", e); } }
private FastForwardReporter( SemanticMetricRegistry registry, MetricId prefix, TimeUnit unit, long duration, FastForward client, Set<Percentile> histogramPercentiles ) { this(registry, prefix, unit, duration, client, new HashSet<>(histogramPercentiles), new NoopTagExtractor()); }
final Map<String, String> commonTags = tagExtractor.addTags(prefix.getTags()); final Batch batch = new Batch(commonTags, points);
@Override public Callable<FastForwardLifecycle> setup( final SemanticMetricRegistry metricRegistry, final MetricId metricId, final String searchDomain ) { final HttpClient.Builder httpClient = new HttpClient.Builder(); httpClient.discovery(discovery.toHttpDiscovery()); httpClient.searchDomain(searchDomain); final FastForwardHttpReporter.Builder builder = FastForwardHttpReporter .forRegistry(metricRegistry, httpClient.build()) .tagExtractor(new EnvironmentTagExtractor()) .schedule(interval, TimeUnit.SECONDS) .prefix(metricId); return () -> { final FastForwardHttpReporter reporter = builder.build(); reporter.start(); return reporter::stop; }; } }
public EnvironmentTagExtractor(Supplier<Map<String, String>> enviromentSupplier) { this.environmentTags = filterEnvironmentTags(enviromentSupplier.get()); }
public FastForwardReporter build() throws IOException { final FastForward client = this.client != null ? this.client : FastForward.setup(host, port); final TagExtractor tagExtractor = this.tagExtractor != null ? this.tagExtractor : new NoopTagExtractor(); return new FastForwardReporter(registry, prefix, unit, time, client, histogramPercentiles, tagExtractor); } }
public FastForwardHttpReporter build() throws IOException { Clock clock = this.clock; if (clock == null) { clock = new Clock.SystemTime(); } final TagExtractor tagExtractor = this.tagExtractor != null ? this.tagExtractor : new NoopTagExtractor(); return new FastForwardHttpReporter(registry, prefix, unit, time, client, histogramPercentiles, clock, tagExtractor); } }