Search in sources :

Example 1 with Tag

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));
}
Also used : BasicTag(com.netflix.spectator.api.BasicTag) Tag(com.netflix.spectator.api.Tag) BasicTag(com.netflix.spectator.api.BasicTag) Test(org.junit.Test)

Example 2 with Tag

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));
}
Also used : BasicTag(com.netflix.spectator.api.BasicTag) Tag(com.netflix.spectator.api.Tag) BasicTag(com.netflix.spectator.api.BasicTag) Test(org.junit.Test)

Example 3 with Tag

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);
        }
    }
}
Also used : Measurement(com.netflix.spectator.api.Measurement) Id(com.netflix.spectator.api.Id) Tag(com.netflix.spectator.api.Tag)

Example 4 with Tag

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;
}
Also used : HashMap(java.util.HashMap) Tag(com.netflix.spectator.api.Tag)

Example 5 with Tag

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);
    }
}
Also used : BasicTag(com.netflix.spectator.api.BasicTag) ThreadPoolExecutorEx(org.apache.servicecomb.core.executor.ThreadPoolExecutorEx) ThreadPoolExecutor(java.util.concurrent.ThreadPoolExecutor) Tag(com.netflix.spectator.api.Tag) BasicTag(com.netflix.spectator.api.BasicTag)

Aggregations

Tag (com.netflix.spectator.api.Tag)11 BasicTag (com.netflix.spectator.api.BasicTag)5 Test (org.junit.Test)4 Id (com.netflix.spectator.api.Id)2 Measurement (com.netflix.spectator.api.Measurement)2 ArrayList (java.util.ArrayList)2 HashMap (java.util.HashMap)2 Sample (io.prometheus.client.Collector.MetricFamilySamples.Sample)1 ThreadPoolExecutor (java.util.concurrent.ThreadPoolExecutor)1 ThreadPoolExecutorEx (org.apache.servicecomb.core.executor.ThreadPoolExecutorEx)1