com.netflix.spectator.api.Registry.createId()方法的使用及代码示例

x33g5p2x  于2022-01-28 转载在 其他  
字(11.2k)|赞(0)|评价(0)|浏览(121)

本文整理了Java中com.netflix.spectator.api.Registry.createId方法的一些代码示例,展示了Registry.createId的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Registry.createId方法的具体详情如下:
包路径:com.netflix.spectator.api.Registry
类名称:Registry
方法名:createId

Registry.createId介绍

[英]Creates an identifier for a meter.
[中]创建仪表的标识符。

代码示例

代码示例来源:origin: Netflix/zuul

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");
}

代码示例来源:origin: Netflix/zuul

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");
}

代码示例来源:origin: Netflix/zuul

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());
}

代码示例来源:origin: Netflix/conductor

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));
  });
}

代码示例来源:origin: Netflix/zuul

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);
}

代码示例来源:origin: Netflix/conductor

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);
  });
}

代码示例来源:origin: Netflix/conductor

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);
  });
}

代码示例来源:origin: Netflix/conductor

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));
  });
}

代码示例来源:origin: Netflix/servo

/** 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);
}

代码示例来源:origin: Netflix/zuul

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());
}

代码示例来源:origin: Netflix/concurrency-limits

private Id suffixBaseId(String suffix) {
  return registry.createId(this.baseId.name() + "." + suffix).withTags(this.baseId.tags());
}

代码示例来源:origin: Netflix/zuul

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);
}

代码示例来源:origin: Netflix/servo

@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());
}

代码示例来源:origin: Netflix/zuul

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());
}

代码示例来源:origin: Netflix/servo

@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());
}

代码示例来源:origin: Netflix/servo

@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());
}

代码示例来源:origin: Netflix/servo

@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());
}

代码示例来源:origin: Netflix/servo

@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);
}

代码示例来源:origin: Netflix/servo

@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());
}

代码示例来源:origin: Netflix/zuul

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());
}

相关文章