Java Code Examples for com.netflix.spectator.api.Tag#value()

The following examples show how to use com.netflix.spectator.api.Tag#value() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: StackdriverWriter.java    From kork with Apache License 2.0 6 votes vote down vote up
/**
 * 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);
}
 
Example 2
Source File: DoubleDistributionSummaryTest.java    From spectator with Apache License 2.0 5 votes vote down vote up
private String get(Id id, String key) {
  for (Tag t : id.tags()) {
    if (key.equals(t.key())) {
      return t.value();
    }
  }
  return null;
}
 
Example 3
Source File: TaggedDataPoints.java    From spectator with Apache License 2.0 4 votes vote down vote up
JacksonableTag(Tag tag) {
  key = tag.key();
  value = tag.value();
}