public EventLoopMetrics(Registry registry, String eventLoopName) { this.name = eventLoopName; this.registry = registry; this.currentRequestsId = this.registry.createId("server.eventloop.http.requests.current"); this.currentConnectionsId = this.registry.createId("server.eventloop.connections.current"); }
public EventLoopMetrics(Registry registry, String eventLoopName) { this.name = eventLoopName; this.registry = registry; this.currentRequestsId = this.registry.createId("server.eventloop.http.requests.current"); this.currentConnectionsId = this.registry.createId("server.eventloop.connections.current"); }
private void openSslStatGauge(OpenSslSessionStats stats, String sslContextId, String statName, ToDoubleFunction<OpenSslSessionStats> value) { Id id = spectatorRegistry.createId("server.ssl.stats", "id", sslContextId, "stat", statName); spectatorRegistry.gauge(id, stats, value); LOG.debug("Registered spectator gauge - " + id.name()); }
private static AtomicLong getGauge(String className, String name, String... additionalTags) { Map<String, String> tags = toMap(className, additionalTags); return gauges.computeIfAbsent(name, s -> new ConcurrentHashMap<>()).computeIfAbsent(tags, t -> { Id id = registry.createId(name, tags); return registry.gauge(id, new AtomicLong(0)); }); }
public HttpMetricsChannelHandler(Registry registry, String name, String id) { super(); this.registry = registry; this.currentRequestsGauge = this.registry.gauge(this.registry.createId(name + ".http.requests.current", "id", id)); this.unSupportedPipeliningCounter = this.registry.counter(name + ".http.requests.pipelining.dropped", "id", id); }
private static Counter getCounter(String className, String name, String... additionalTags) { Map<String, String> tags = toMap(className, additionalTags); return counters.computeIfAbsent(name, s -> new ConcurrentHashMap<>()).computeIfAbsent(tags, t -> { Id id = registry.createId(name, tags); return registry.counter(id); }); }
public static Timer getTimer(String className, String name, String... additionalTags) { Map<String, String> tags = toMap(className, additionalTags); tags.put("unit", TimeUnit.SECONDS.name()); return timers.computeIfAbsent(name, s -> new ConcurrentHashMap<>()).computeIfAbsent(tags, t -> { Id id = registry.createId(name, tags); return PercentileTimer.get(registry, id); }); }
private static AtomicLong getGauge(String name, String... additionalTags) { String key = className + "." + name + "." + Joiner.on(",").join(additionalTags); return gauges.computeIfAbsent(key, pollTimer -> { Id id = registry.createId(name, getTags(additionalTags)); return PolledMeter.using(registry) .withId(id) .monitorValue(new AtomicLong(0)); }); }
/** Convert servo config to spectator id. */ public static Id createId(MonitorConfig config) { // Need to ensure that Servo type tag is removed to avoid incorrectly reprocessing the // data in later transforms Map<String, String> tags = new HashMap<>(config.getTags().asMap()); tags.remove("type"); return registry .createId(config.getName()) .withTags(tags); }
private void openSslStatGauge(OpenSslSessionStats stats, String sslContextId, String statName, ToDoubleFunction<OpenSslSessionStats> value) { Id id = spectatorRegistry.createId("server.ssl.stats", "id", sslContextId, "stat", statName); spectatorRegistry.gauge(id, stats, value); LOG.debug("Registered spectator gauge - " + id.name()); }
private Id suffixBaseId(String suffix) { return registry.createId(this.baseId.name() + "." + suffix).withTags(this.baseId.tags()); }
public HttpMetricsChannelHandler(Registry registry, String name, String id) { super(); this.registry = registry; this.currentRequestsGauge = this.registry.gauge(this.registry.createId(name + ".http.requests.current", "id", id)); this.unSupportedPipeliningCounter = this.registry.counter(name + ".http.requests.pipelining.dropped", "id", id); }
@Test public void testCustomCompositeMemberCounter() { CustomCompositeExample c = new CustomCompositeExample("foo"); c.update("2"); Id id = registry.createId("test").withTag("c", "2"); assertEquals(1, registry.counter(id).count()); }
public DefaultClientChannelManager(String originName, String vip, IClientConfig clientConfig, Registry spectatorRegistry) { this.loadBalancer = createLoadBalancer(clientConfig); this.vip = vip; this.clientConfig = clientConfig; this.spectatorRegistry = spectatorRegistry; this.perServerPools = new ConcurrentHashMap<>(200); // Setup a listener for Discovery serverlist changes. this.loadBalancer.addServerListChangeListener((oldList, newList) -> removeMissingServerConnectionPools(oldList, newList)); this.connPoolConfig = new ConnectionPoolConfigImpl(originName, this.clientConfig); this.createNewConnCounter = SpectatorUtils.newCounter(METRIC_PREFIX + "_create", originName); this.createConnSucceededCounter = SpectatorUtils.newCounter(METRIC_PREFIX + "_create_success", originName); this.createConnFailedCounter = SpectatorUtils.newCounter(METRIC_PREFIX + "_create_fail", originName); this.closeConnCounter = SpectatorUtils.newCounter(METRIC_PREFIX + "_close", originName); this.requestConnCounter = SpectatorUtils.newCounter(METRIC_PREFIX + "_request", originName); this.reuseConnCounter = SpectatorUtils.newCounter(METRIC_PREFIX + "_reuse", originName); this.releaseConnCounter = SpectatorUtils.newCounter(METRIC_PREFIX + "_release", originName); this.alreadyClosedCounter = SpectatorUtils.newCounter(METRIC_PREFIX + "_alreadyClosed", originName); this.connTakenFromPoolIsNotOpen = SpectatorUtils.newCounter(METRIC_PREFIX + "_fromPoolIsClosed", originName); this.maxConnsPerHostExceededCounter = SpectatorUtils.newCounter(METRIC_PREFIX + "_maxConnsPerHostExceeded", originName); this.closeWrtBusyConnCounter = SpectatorUtils.newCounter(METRIC_PREFIX + "_closeWrtBusyConnCounter", originName); this.connEstablishTimer = PercentileTimer.get(spectatorRegistry, spectatorRegistry.createId(METRIC_PREFIX + "_createTiming", "id", originName)); this.connsInPool = SpectatorUtils.newGauge(METRIC_PREFIX + "_inPool", originName, new AtomicInteger()); this.connsInUse = SpectatorUtils.newGauge(METRIC_PREFIX + "_inUse", originName, new AtomicInteger()); }
@Test public void testMemberCounter() { AnnotateExample ex = new AnnotateExample("foo"); ex.update(); Id id = registry.createId("test") .withTag("class", "AnnotateExample") .withTag("id", "foo"); assertEquals(1, registry.counter(id).count()); }
@Test public void testAnnotatedCounter() { AnnotateExample ex = new AnnotateExample("foo"); PolledMeter.update(registry); Id id = registry.createId("counter") .withTag("class", "AnnotateExample") .withTag("level", "INFO") .withTag("id", "foo"); assertEquals(1, registry.counter(id).count()); }
@Test public void testContextualMemberCounter() { ContextualExample c = new ContextualExample("foo"); c.update(); Id id = registry.createId("counter") .withTag("a", "2") .withTag("id", "foo") .withTag("class", "ContextualExample"); assertEquals(1, registry.counter(id).count()); }
@Test public void testAnnotatedGauge() { AnnotateExample ex = new AnnotateExample("foo"); PolledMeter.update(registry); Id id = registry.createId("gauge") .withTag("class", "AnnotateExample") .withTag("level", "INFO") .withTag("id", "foo"); assertEquals(42.0, registry.gauge(id).value(), 1e-12); }
@Test public void testUnregisteredBasicTimerIncrement() { BasicTimer t = new BasicTimer(CONFIG); t.record(42, TimeUnit.MILLISECONDS); Id id = registry.createId("test") .withTag("unit", "MILLISECONDS"); assertEquals(3, registry.counters().count()); assertEquals(0, registry.timers().count()); assertEquals(1, registry.gauges().count()); assertEquals(0, registry.distributionSummaries().count()); assertEquals(1, registry.counter(id.withTag(Statistic.count)).count()); assertEquals(42, registry.counter(id.withTag(Statistic.totalTime)).count()); assertEquals(42 * 42, registry.counter(id.withTag(Statistic.totalOfSquares)).count()); assertEquals(42.0, registry.maxGauge(id.withTag(Statistic.max)).value()); }
public DefaultClientChannelManager(String originName, String vip, IClientConfig clientConfig, Registry spectatorRegistry) { this.loadBalancer = createLoadBalancer(clientConfig); this.vip = vip; this.clientConfig = clientConfig; this.spectatorRegistry = spectatorRegistry; this.perServerPools = new ConcurrentHashMap<>(200); // Setup a listener for Discovery serverlist changes. this.loadBalancer.addServerListChangeListener((oldList, newList) -> removeMissingServerConnectionPools(oldList, newList)); this.connPoolConfig = new ConnectionPoolConfigImpl(originName, this.clientConfig); this.createNewConnCounter = SpectatorUtils.newCounter(METRIC_PREFIX + "_create", originName); this.createConnSucceededCounter = SpectatorUtils.newCounter(METRIC_PREFIX + "_create_success", originName); this.createConnFailedCounter = SpectatorUtils.newCounter(METRIC_PREFIX + "_create_fail", originName); this.closeConnCounter = SpectatorUtils.newCounter(METRIC_PREFIX + "_close", originName); this.requestConnCounter = SpectatorUtils.newCounter(METRIC_PREFIX + "_request", originName); this.reuseConnCounter = SpectatorUtils.newCounter(METRIC_PREFIX + "_reuse", originName); this.releaseConnCounter = SpectatorUtils.newCounter(METRIC_PREFIX + "_release", originName); this.alreadyClosedCounter = SpectatorUtils.newCounter(METRIC_PREFIX + "_alreadyClosed", originName); this.connTakenFromPoolIsNotOpen = SpectatorUtils.newCounter(METRIC_PREFIX + "_fromPoolIsClosed", originName); this.maxConnsPerHostExceededCounter = SpectatorUtils.newCounter(METRIC_PREFIX + "_maxConnsPerHostExceeded", originName); this.closeWrtBusyConnCounter = SpectatorUtils.newCounter(METRIC_PREFIX + "_closeWrtBusyConnCounter", originName); this.connEstablishTimer = PercentileTimer.get(spectatorRegistry, spectatorRegistry.createId(METRIC_PREFIX + "_createTiming", "id", originName)); this.connsInPool = SpectatorUtils.newGauge(METRIC_PREFIX + "_inPool", originName, new AtomicInteger()); this.connsInUse = SpectatorUtils.newGauge(METRIC_PREFIX + "_inUse", originName, new AtomicInteger()); }