io.prometheus.client.Gauge.labels()方法的使用及代码示例

x33g5p2x  于2022-01-20 转载在 其他  
字(7.3k)|赞(0)|评价(0)|浏览(422)

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

Gauge.labels介绍

暂无

代码示例

代码示例来源:origin: qunarcorp/qmq

public PrometheusQmqCounter(final Gauge gauge, final String[] labels) {
  this.gauge = gauge.labels(labels);
}

代码示例来源:origin: prometheus/client_java

@Benchmark
@BenchmarkMode({Mode.AverageTime})
@OutputTimeUnit(TimeUnit.NANOSECONDS)
public void prometheusSimpleGaugeIncBenchmark() {
 prometheusSimpleGauge.labels("test", "group").inc(); 
}

代码示例来源:origin: prometheus/client_java

@Benchmark
@BenchmarkMode({Mode.AverageTime})
@OutputTimeUnit(TimeUnit.NANOSECONDS)
public void prometheusSimpleGaugeSetBenchmark() {
 prometheusSimpleGauge.labels("test", "group").set(42); 
}

代码示例来源:origin: prometheus/client_java

@Benchmark
@BenchmarkMode({Mode.AverageTime})
@OutputTimeUnit(TimeUnit.NANOSECONDS)
public void prometheusSimpleGaugeDecBenchmark() {
 prometheusSimpleGauge.labels("test", "group").dec(); 
}

代码示例来源:origin: prometheus/client_java

@Setup
public void setup() {
 prometheusGauge = io.prometheus.client.metrics.Gauge.newBuilder()
  .name("name")
  .documentation("some description..")
  .build();
 prometheusGaugeChild = prometheusGauge.newPartial().apply();
 prometheusSimpleGauge = io.prometheus.client.Gauge.build()
  .name("name")
  .help("some description..")
  .labelNames("some", "group").create();
 prometheusSimpleGaugeChild = prometheusSimpleGauge.labels("test", "group");
 prometheusSimpleGaugeNoLabels = io.prometheus.client.Gauge.build()
  .name("name")
  .help("some description..")
  .create();
 registry = new MetricRegistry();
 codahaleCounter = registry.counter("name");
}

代码示例来源:origin: com.jonnymatts.prometheus/metrics-core

public Child labels(String... labels) {
  return gauge.labels(labels);
}

代码示例来源:origin: no.skatteetaten.aurora/aurora-prometheus

public static void size(String name, int number) {
  instance.sizes.labels(name, "").set(number);
}

代码示例来源:origin: avaire/avaire

private void register() {
    Metrics.blacklist.labels("servers").set(0);
    Metrics.blacklist.labels("users").set(0);
  }
}

代码示例来源:origin: no.skatteetaten.aurora/aurora-prometheus

public static void size(String name, String type, int number) {
  instance.sizes.labels(name, type).set(number);
}

代码示例来源:origin: no.skatteetaten.aurora/aurora-prometheus

public static void status(String name, StatusValue value) {
  instance.statuses.labels(name).set(value.getValue());
}

代码示例来源:origin: dabbotorg/java-music-bot

@Override
public void onUserUpdateOnlineStatus(UserUpdateOnlineStatusEvent event) {
  String shard = Integer.toString(event.getJDA().getShardInfo().getShardId());
  int memberCount = event.getJDA().getGuildCache().stream().flatMap(g -> g.getMembers().stream()).collect(Collectors.toList()).size();
  members.labels(shard).set(memberCount);
}

代码示例来源:origin: avaire/avaire

public void onGuildUpdateRegion(GuildUpdateRegionEvent event) {
  Metrics.geoTracker.labels(event.getOldRegion().getName()).dec();
  Metrics.geoTracker.labels(event.getNewRegion().getName()).inc();
}

代码示例来源:origin: nlighten/tomcat_exporter

@Override
protected String reportFailedQuery(String query, Object[] args, String name, long start, Throwable t) {
  String sql = super.reportFailedQuery(query, args, name, start, t);
  long now = System.currentTimeMillis();
  long delta = now - start;
  globalQueryStats.labels(FAILED_QUERY_STATUS).observe((double) delta/1000);
  if (failedQueryStatsEnabled) {
    failedQueryStats.labels(sql).inc();
  }
  return sql;
}

代码示例来源:origin: dabbotorg/java-music-bot

private final void setGuildCount(JDA jda) {
    long count = jda.getGuildCache().size();
    String shard = Integer.toString(jda.getShardInfo().getShardId());

    guilds.labels(shard).set(count);
  }
}

代码示例来源:origin: avaire/avaire

@Override
public void handle(AvaIre avaire) {
  Metrics.uptime.labels("dynamic").set(ManagementFactory.getRuntimeMXBean().getUptime());
  Metrics.memoryTotal.set(Runtime.getRuntime().totalMemory());
  Metrics.memoryUsed.set(Runtime.getRuntime().totalMemory() - Runtime.getRuntime().freeMemory());
  if (!avaire.areWeReadyYet() || !hasLoadedGuilds(avaire)) {
    return;
  }
  Metrics.guilds.set(avaire.getShardEntityCounter().getGuilds());
  Metrics.users.set(avaire.getShardEntityCounter().getUsers());
  Metrics.channels.labels("text").set(avaire.getShardEntityCounter().getTextChannels());
  Metrics.channels.labels("voice").set(avaire.getShardEntityCounter().getVoiceChannels());
  for (Region region : Region.values()) {
    Metrics.geoTracker.labels(region.getName()).set(0);
  }
  for (JDA shard : avaire.getShardManager().getShards()) {
    for (Guild guild : shard.getGuilds()) {
      Metrics.geoTracker.labels(guild.getRegion().getName()).inc();
    }
  }
}

代码示例来源:origin: smartcat-labs/cassandra-diagnostics

@Override
public void report(Measurement measurement) {
  if (measurement.isSimple()) {
    String name = measurement.name().replaceAll(ILLEGAL_CHARACTERS_REGEX, ALLOWED_DELIMITER);
    Gauge gauge = getOrCreateGaugeMeasurement(measurement, name);
    String[] tagValues = convertTagValues(measurement.tags());
    double value = measurement.getValue();
    gauge.labels(tagValues).set(value);
  } else {
    String baseName = measurement.name().replaceAll(ILLEGAL_CHARACTERS_REGEX, ALLOWED_DELIMITER);
    for (String key : measurement.fields().keySet()) {
      if (!isNumeric(measurement.fields().get(key))) {
        continue;
      }
      String metricName = baseName + ":" + key.replaceAll(ILLEGAL_CHARACTERS_REGEX, ALLOWED_DELIMITER);
      Gauge gauge = getOrCreateGaugeMeasurement(measurement, metricName);
      double value = Double.parseDouble(measurement.fields().get(key));
      String[] tagValues = convertTagValues(measurement.tags());
      gauge.labels(tagValues).set(value);
    }
  }
}

代码示例来源:origin: hellobike/tunnel

@Override
public void collect(Statics statics) {
  this.gauge.labels(statics.getSlotName(), statics.getAppId(),
      statics.getDatabase(), statics.getTable(),
      statics.getTarget(), String.valueOf(statics.getTotal()),
      String.valueOf(statics.getCurrentTime()), statics.getError() == null ? "" : statics.getError()).inc();
}

代码示例来源:origin: avaire/avaire

@Override
public void handle(AvaIre avaire) {
  if (avaire.getBlacklist() == null) {
    register();
    return;
  }
  int servers = 0,
    users = 0;
  for (BlacklistEntity entity : avaire.getBlacklist().getBlacklistEntities()) {
    if (!entity.isBlacklisted()) {
      continue;
    }
    if (entity.getScope().equals(Scope.GUILD)) {
      servers++;
    } else {
      users++;
    }
  }
  Metrics.blacklist.labels("servers").set(servers);
  Metrics.blacklist.labels("users").set(users);
}

代码示例来源:origin: avaire/avaire

@Override
  public void handle(AvaIre avaire) {
    if (!avaire.areWeReadyYet()) {
      return;
    }

    for (JDA shard : avaire.getShardManager().getShards()) {
      Metrics.websocketHeartbeat.labels("Shard " + shard.getShardInfo().getShardId())
        .set(shard.getPing());
    }
  }
}

代码示例来源:origin: avaire/avaire

private void handleSendGuildLeaveWebhook(Guild guild) {
  AvaIre.getLogger().info(ConsoleColor.format(
    "%redLeft guild with an ID of " + guild.getId() + " called: " + guild.getName() + "%reset"
  ));
  if (!avaire.areWeReadyYet()) {
    return;
  }
  Metrics.guilds.dec();
  Metrics.geoTracker.labels(guild.getRegion().getName()).dec();
  TextChannel channel = avaire.getShardManager().getTextChannelById(DiscordConstants.ACTIVITY_LOG_CHANNEL_ID);
  if (channel == null) {
    return;
  }
  channel.sendMessage(
    new EmbedBuilder()
      .setColor(Color.decode("#EF5350"))
      .setTimestamp(Instant.now())
      .addField("Removed", String.format("%s (ID: %s)",
        guild.getName(), guild.getId()
      ), false)
      .build()
  ).queue(null, RestActionUtil.ignore);
}

相关文章