nodeInfo.keyspaces.contains(keyspaceName) ? keyspaceName : "", "", metricName).set(value); return; STATS.labels(nodeInfo.clusterName, nodeInfo.datacenterName, keyspaceName, tableName, metricName).set(value); return; STATS.labels(nodeInfo.clusterName, nodeInfo.datacenterName, keyspaceName, tableName, metricName).set(value); return; STATS.labels(nodeInfo.clusterName, nodeInfo.datacenterName, "", "", metricName).set(value);
@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); }
@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); } } }
@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(); } } }
@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); }
public static void size(String name, String type, int number) { instance.sizes.labels(name, type).set(number); }
public static void status(String name, StatusValue value) { instance.statuses.labels(name).set(value.getValue()); }
public static void size(String name, int number) { instance.sizes.labels(name, "").set(number); }
public void set(String beanName, String attributeName, double amount) { labels(beanName, attributeName).set(amount); }
private final void setGuildCount(JDA jda) { long count = jda.getGuildCache().size(); String shard = Integer.toString(jda.getShardInfo().getShardId()); guilds.labels(shard).set(count); } }
@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()); } } }
/** * Set the amount of time in seconds since {@link Child#startTimer} was called. * @return Measured duration in seconds since {@link Child#startTimer} was called. */ public double setDuration() { double elapsed = (Child.timeProvider.nanoTime() - start) / NANOSECONDS_PER_SECOND; child.set(elapsed); return elapsed; }
/** * Set the gauge with no labels to the given value. */ public void set(double val) { noLabelsChild.set(val); } /**
/** * Set the gauge to the current unixtime. */ public void setToCurrentTime() { set(timeProvider.currentTimeMillis() / MILLISECONDS_PER_SECOND); } /**
/** * Set the gauge with no labels to the given value. */ public void set(double val) { noLabelsChild.set(val); } /**
@Benchmark @BenchmarkMode({Mode.AverageTime}) @OutputTimeUnit(TimeUnit.NANOSECONDS) public void prometheusSimpleGaugeChildSetBenchmark() { prometheusSimpleGaugeChild.set(42); }
@Benchmark @BenchmarkMode({Mode.AverageTime}) @OutputTimeUnit(TimeUnit.NANOSECONDS) public void prometheusSimpleGaugeSetBenchmark() { prometheusSimpleGauge.labels("test", "group").set(42); }
/** * Set the amount of time in seconds since {@link Child#startTimer} was called. * @return Measured duration in seconds since {@link Child#startTimer} was called. */ public double setDuration() { double elapsed = (Child.timeProvider.nanoTime() - start) / NANOSECONDS_PER_SECOND; child.set(elapsed); return elapsed; }
/** * Set the gauge to the current unixtime. */ public void setToCurrentTime() { set(timeProvider.currentTimeMillis() / MILLISECONDS_PER_SECOND); } /**