protected <T> Gauge<T> gauge(Gauge<T> gauge, String... names) { try { return registry.register(nameOf(names), gauge); } catch (IllegalArgumentException e) { return gauge; } }
DatagramSocketMetricsImpl(AbstractMetrics metrics, String baseName) { super(metrics.registry(), baseName); socketsCounter = counter("sockets"); exceptions = counter("exceptions"); bytesWritten = histogram("bytes-written"); socketsCounter.inc(); }
public ScheduledMetricsConsumer(Vertx vertx, Measured measured) { this.vertx = vertx; this.measured = AbstractMetrics.unwrap(measured); }
String projectName(String name) { String baseName = baseName(); return name.substring(baseName.length() + 1); }
public void start(long delay, TimeUnit unit, BiConsumer<String, Object> consumer) { timerId = vertx.setPeriodic(unit.toMillis(delay), tid -> { measured.metrics().getMap().forEach((name, metric) -> { System.out.println("maybe " + name); if (filter.test(name, metric)) { System.out.println("sending " + name); consumer.accept(name, metric); } }); }); }
/** * Will return the metrics that correspond with a given base name. * * @return the map of metrics where the key is the name of the metric (excluding the base name) and the value is * the json data representing that metric */ public JsonObject metrics(String baseName) { Map<String, Object> map = registry.getMetrics(). entrySet(). stream(). filter(e -> e.getKey().startsWith(baseName)). collect(Collectors.toMap( e -> projectName(e.getKey()), e -> Helper.convertMetric(e.getValue(), TimeUnit.SECONDS, TimeUnit.MILLISECONDS))); return new JsonObject(map); }
EventBusMetricsImpl(AbstractMetrics metrics, String baseName, DropwizardMetricsOptions options) { super(metrics.registry(), baseName); handlerCount = counter("handlers"); pending = counter("messages", "pending"); pendingLocal = counter("messages", "pending-local"); pendingRemote = counter("messages", "pending-remote"); receivedMessages = throughputMeter("messages", "received"); receivedLocalMessages = throughputMeter("messages", "received-local"); receivedRemoteMessages = throughputMeter("messages", "received-remote"); deliveredMessages = throughputMeter("messages", "delivered"); deliveredLocalMessages = throughputMeter("messages", "delivered-local"); deliveredRemoteMessages = throughputMeter("messages", "delivered-remote"); sentMessages = throughputMeter("messages", "sent"); sentLocalMessages = throughputMeter("messages", "sent-local"); sentRemoteMessages = throughputMeter("messages", "sent-remote"); publishedMessages = throughputMeter("messages", "published"); publishedLocalMessages = throughputMeter("messages", "published-local"); publishedRemoteMessages = throughputMeter("messages", "published-remote"); replyFailures = meter("messages", "reply-failures"); bytesRead = meter("messages", "bytes-read"); bytesWritten = meter("messages", "bytes-written"); handlerMatcher = new Matcher(options.getMonitoredEventBusHandlers()); }
public Set<String> metricsNames() { AbstractMetrics codahaleMetrics = AbstractMetrics.unwrap(vertx); if (codahaleMetrics != null) { MetricRegistry registry = codahaleMetrics.registry; return new HashSet<>(registry.getMetrics().keySet()); } return Collections.emptySet(); } }
protected Counter counter(String... names) { try { return registry.counter(nameOf(names)); } catch (Exception e) { return new Counter(); } }
protected Meter meter(String... names) { try { return registry.meter(nameOf(names)); } catch (Exception e) { return new Meter(); } }
protected Timer timer(String... names) { try { return registry.timer(nameOf(names)); } catch (Exception e) { return new Timer(); } }
protected void remove(String... names) { registry.remove(nameOf(names)); }
protected ThroughputMeter throughputMeter(String... names) { try { return RegistryHelper.throughputMeter(registry, nameOf(names)); } catch (Exception e) { return new ThroughputMeter(); } }
protected ThroughputTimer throughputTimer(String... names) { try { return RegistryHelper.throughputTimer(registry, nameOf(names)); } catch (Exception e) { return new ThroughputTimer(); } }
protected Histogram histogram(String... names) { try { return registry.histogram(nameOf(names)); } catch (Exception e) { return new Histogram(new ExponentiallyDecayingReservoir()); } }