private void updateGauge(Id gaugeId, int value) { registry.gauge(gaugeId.withTag("eventloop", name)).set(value); } }
.withTag("controller", controller) .withTag("method", handlerMethod.getMethod().getName()) .withTag("status", status.toString().charAt(0) + "xx") .withTag("statusCode", status.toString()); id = id.withTag(queryParamName, request.getParameter(queryParamName)); id = id.withTag("success", "false").withTag("cause", ex.getClass().getSimpleName()); } else { id = id.withTag("success", "true"); registry.createId(contentLengthMetricName).withTags(id.tags()) ).record(request.getContentLengthLong());
@Override public SampleListener registerDistribution(String id, String... tagNameValuePairs) { DistributionSummary summary = registry.distributionSummary(suffixBaseId(id).withTags(tagNameValuePairs)); return value -> summary.record(value.longValue()); }
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()); }
@Test public void testTagsEmpty() { Id id = new DefaultId("foo"); Assertions.assertFalse(id.tags().iterator().hasNext()); }
/** Create a new instance. */ AtlasGauge(Id id, Clock clock, long ttl) { super(id, clock, ttl); this.value = new AtomicDouble(0.0); // Add the statistic for typing. Re-adding the tags from the id is to retain // the statistic from the id if it was already set this.stat = id.withTag(Statistic.gauge).withTags(id.tags()).withTag(DsType.gauge); }
protected Sample convertMeasurementToSample(Measurement measurement) { String prometheusName = measurement.id().name().replace(".", "_"); List<String> labelNames = new ArrayList<>(); List<String> labelValues = new ArrayList<>(); for (Tag tag : measurement.id().tags()) { labelNames.add(tag.key()); labelValues.add(tag.value()); } return new Sample(prometheusName, labelNames, labelValues, measurement.value()); }
/** 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()); }
public static DistributionSummary getDistributionSummary(String name, String appName, String serverGroup) { final String metricName = getMetricName(appName, serverGroup, name); final DistributionSummary _ds = distributionSummaryMap.get(metricName); if(_ds != null) return _ds; final Registry registry = Spectator.globalRegistry(); //_poolManager.getRegistry(); if (registry != null) { Id id = registry.createId(name); id = id.withTag("owner", "evcache"); id = id.withTag("APP", appName); if(serverGroup != null) id = id.withTag("ServerGroup", serverGroup); final DistributionSummary ds = registry.distributionSummary(id); if (!Monitors.isObjectRegistered(ds)) Monitors.registerObject(ds); distributionSummaryMap.put(metricName, ds); return ds; } return null; }
/** Create a new instance. */ AtlasCounter(Id id, Clock clock, long ttl, long step) { super(id, clock, ttl); this.value = new StepDouble(0L, clock, step); // Add the statistic for typing. Re-adding the tags from the id is to retain // the statistic from the id if it was already set this.stat = id.withTag(Statistic.count).withTags(id.tags()).withTag(DsType.rate); }
public void from(Iterable<Measurement> measurements, MeasurementGroupConfig groupConfig) { for (Measurement measurement : measurements) { Id id = measurement.id(); MeasurementNode node = addChild(id.name(), measurement); List<TagFinder> tagFinders = groupConfig.findTagFinders(id.name()); if (tagFinders == null) { continue; } for (TagFinder tagFinder : tagFinders) { Tag tag = tagFinder.find(id.tags()); if (tag == null) { if (tagFinder.skipOnNull()) { break; } throw new IllegalStateException( String.format("tag key \"%s\" not exist in %s", tagFinder.getTagKey(), measurement)); } node = node.addChild(tag.value(), measurement); } } } }
@Override public void registerGauge(String id, Supplier<Number> supplier, String... tagNameValuePairs) { Id metricId = suffixBaseId(id).withTags(tagNameValuePairs); PolledMeter.remove(registry, metricId); PolledMeter.using(registry) .withId(metricId) .monitorValue(supplier, ignore -> supplier.get().doubleValue()); }
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 void checkIdTagValue(Meter meter, String expectedIdValue) { final Iterable<Measurement> measurements = meter.measure(); final Iterator<Measurement> measurementIterator = measurements.iterator(); Assertions.assertTrue(measurementIterator.hasNext()); final Iterator<Tag> tags = measurementIterator.next().id().tags().iterator(); Assertions.assertTrue(tags.hasNext()); Tag tag = tags.next(); Assertions.assertEquals(ThreadPoolMonitor.ID_TAG_NAME, tag.key()); Assertions.assertEquals(expectedIdValue, tag.value()); }
private void updateGauge(Id gaugeId, int value) { registry.gauge(gaugeId.withTag("eventloop", name)).set(value); } }