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);
}
Aggregations