Search in sources :

Example 11 with Tag

use of com.netflix.spectator.api.Tag in project kork by spinnaker.

the class StackdriverWriter method deriveBaseTimerId.

/**
 * Generate an Id for the derived timer measurements.
 *
 * @param id The original Measurement id
 * @return A copy of the original but without the 'statistic' tag, and the name will be decorated
 *     with "__count" or "__totalTime" depending on the value of the original statistic tag.
 */
Id deriveBaseTimerId(Id id) {
    String suffix = null;
    ArrayList<Tag> tags = new ArrayList<Tag>();
    for (Tag tag : id.tags()) {
        if (tag.key().equals("statistic")) {
            if (tag.value().equals("totalTime")) {
                suffix = "totalTime";
            } else if (tag.value().equals("count")) {
                suffix = "count";
            } else {
                throw new IllegalStateException("Unexpected statistic=" + tag.value());
            }
            continue;
        }
        tags.add(tag);
    }
    if (suffix == null) {
        // Didnt have statistic, so return original.
        return id;
    }
    return ID_FACTORY.createId(id.name() + "__" + suffix).withTags(tags);
}
Also used : ArrayList(java.util.ArrayList) Tag(com.netflix.spectator.api.Tag)

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