use of com.netflix.spectator.api.Tag in project incubator-servicecomb-java-chassis by apache.
the class TestDefaultTagFinder method readSucc.
@Test
public void readSucc() {
Tag tag = new BasicTag("key", "value");
List<Tag> tags = Arrays.asList(new BasicTag("t1", "t1v"), tag);
Assert.assertSame(tag, finder.find(tags));
}
use of com.netflix.spectator.api.Tag in project incubator-servicecomb-java-chassis by apache.
the class TestDefaultTagFinder method readFail.
@Test
public void readFail() {
List<Tag> tags = Arrays.asList(new BasicTag("t1", "t1v"));
Assert.assertNull(finder.find(tags));
}
use of com.netflix.spectator.api.Tag in project incubator-servicecomb-java-chassis by apache.
the class MeasurementTree method from.
public void from(Iterable<Measurement> measurements, MeasurementGroupConfig groupConfig) {
for (Measurement measurement : measurements) {
Id id = measurement.id();
List<TagFinder> tagFinders = groupConfig.findTagFinders(id.name());
if (tagFinders == null) {
continue;
}
MeasurementNode node = addChild(id.name(), measurement);
for (TagFinder tagFinder : tagFinders) {
Tag tag = tagFinder.find(id.tags());
if (tag == null) {
throw new IllegalStateException(String.format("tag key \"%s\" not exist in %s", tagFinder.getTagKey(), measurement));
}
node = node.addChild(tag.value(), measurement);
}
}
}
use of com.netflix.spectator.api.Tag in project kork by spinnaker.
the class StackdriverWriterTest method makeTimeSeries.
TimeSeries makeTimeSeries(MetricDescriptor descriptor, Id id, double value, String time) {
TypedValue tv = new TypedValue();
tv.setDoubleValue(value);
TimeInterval timeInterval = new TimeInterval();
timeInterval.setStartTime("2016-08-28T14:20:00.000000000Z");
timeInterval.setEndTime(time);
Point point = new Point();
point.setValue(tv);
point.setInterval(timeInterval);
HashMap<String, String> labels = new HashMap<String, String>();
labels.put(MetricDescriptorCache.INSTANCE_LABEL, INSTANCE_ID);
for (Tag tag : id.tags()) {
labels.put(tag.key(), tag.value());
}
Metric metric = new Metric();
metric.setType(descriptor.getType());
metric.setLabels(labels);
TimeSeries ts = new TimeSeries();
ts.setResource(writer.peekMonitoredResource());
ts.setMetric(metric);
ts.setPoints(Arrays.asList(point));
ts.setMetricKind("CUMULATIVE");
ts.setValueType("DOUBLE");
return ts;
}
use of com.netflix.spectator.api.Tag in project java-chassis by ServiceComb.
the class ThreadPoolMetersInitializer method createThreadPoolMeters.
protected void createThreadPoolMeters(String threadPoolName, Executor executor) {
if (!ThreadPoolExecutor.class.isInstance(executor)) {
return;
}
ThreadPoolMonitor.attach(registry, (ThreadPoolExecutor) executor, threadPoolName);
if (executor instanceof ThreadPoolExecutorEx) {
Tag idTag = new BasicTag("id", threadPoolName);
PolledMeter.using(registry).withName(REJECTED_COUNT).withTag(idTag).monitorMonotonicCounter((ThreadPoolExecutorEx) executor, ThreadPoolExecutorEx::getRejectedCount);
}
}
Aggregations