本文整理了Java中com.netflix.spectator.api.Tag.value()
方法的一些代码示例,展示了Tag.value()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Tag.value()
方法的具体详情如下:
包路径:com.netflix.spectator.api.Tag
类名称:Tag
方法名:value
[英]Value for the tag.
[中]标记的值。
代码示例来源:origin: apache/servicecomb-java-chassis
protected Sample convertMeasurementToSample(Measurement measurement) {
String prometheusName = measurement.id().name().replace(".", "_");
List<String> labelNames = new ArrayList<>();
List<String> labelValues = new ArrayList<>();
for (Tag tag : measurement.id().tags()) {
labelNames.add(tag.key());
labelValues.add(tag.value());
}
return new Sample(prometheusName, labelNames, labelValues, measurement.value());
}
代码示例来源:origin: apache/servicecomb-java-chassis
private void printNetLog(StringBuilder sb, MeasurementNode osNode) {
MeasurementNode netNode = osNode.findChild(OsMeter.OS_TYPE_NET);
if (netNode == null || netNode.getMeasurements().isEmpty()) {
return;
}
appendLine(sb, " net:");
appendLine(sb, " send(Bps) recv(Bps) send(pps) recv(pps) interface");
StringBuilder tmpSb = new StringBuilder();
for (MeasurementNode interfaceNode : netNode.getChildren().values()) {
double sendRate = interfaceNode.findChild(NetMeter.TAG_SEND.value()).summary();
double sendPacketsRate = interfaceNode.findChild(NetMeter.TAG_PACKETS_SEND.value()).summary();
double receiveRate = interfaceNode.findChild(NetMeter.TAG_RECEIVE.value()).summary();
double receivePacketsRate = interfaceNode.findChild(NetMeter.TAG_PACKETS_RECEIVE.value()).summary();
if (sendRate == 0 && receiveRate == 0 && receivePacketsRate == 0 && sendPacketsRate == 0) {
continue;
}
appendLine(tmpSb, " %-12s %-12s %-12s %-12s %s",
NetUtils.humanReadableBytes((long) sendRate),
NetUtils.humanReadableBytes((long) receiveRate),
NetUtils.humanReadableBytes((long) sendPacketsRate),
NetUtils.humanReadableBytes((long) receivePacketsRate),
interfaceNode.getName());
}
if (tmpSb.length() != 0) {
sb.append(tmpSb.toString());
}
}
代码示例来源:origin: apache/servicecomb-java-chassis
public void from(Iterable<Measurement> measurements, MeasurementGroupConfig groupConfig) {
for (Measurement measurement : measurements) {
Id id = measurement.id();
MeasurementNode node = addChild(id.name(), measurement);
List<TagFinder> tagFinders = groupConfig.findTagFinders(id.name());
if (tagFinders == null) {
continue;
}
for (TagFinder tagFinder : tagFinders) {
Tag tag = tagFinder.find(id.tags());
if (tag == null) {
if (tagFinder.skipOnNull()) {
break;
}
throw new IllegalStateException(
String.format("tag key \"%s\" not exist in %s",
tagFinder.getTagKey(),
measurement));
}
node = node.addChild(tag.value(), measurement);
}
}
}
}
代码示例来源:origin: Netflix/spectator
private String[] toStringArray(Tag[] ts, int length) {
String[] strs = new String[length * 2];
for (int i = 0; i < length; ++i) {
strs[2 * i] = ts[i].key();
strs[2 * i + 1] = ts[i].value();
}
return strs;
}
代码示例来源:origin: Netflix/spectator
private void putTag(Map<String, String> tags, Tag tag) {
if (tag != null) {
tags.put(tag.key(), tag.value());
}
}
代码示例来源:origin: Netflix/spectator
@Override public boolean equals(Object obj) {
if (obj == this) return true;
if (!(obj instanceof Tag)) return false;
Tag tag = (Tag) obj;
return key.equals(tag.key()) && value.equals(tag.value());
}
代码示例来源:origin: Netflix/spectator
JsonStringBuilder addField(String k, Tag tag) {
if (tag != null) {
addField(k, tag.value());
}
return this;
}
代码示例来源:origin: com.netflix.spectator/spectator-ext-ipc
JsonStringBuilder addField(String k, Tag tag) {
if (tag != null) {
addField(k, tag.value());
}
return this;
}
代码示例来源:origin: com.netflix.spectator/spectator-web-spring
@Override public boolean equals(Object obj) {
if (obj == this) return true;
if (!(obj instanceof Tag)) return false;
Tag tag = (Tag) obj;
return key.equals(tag.key()) && value.equals(tag.value());
}
代码示例来源:origin: Netflix/spectator
/** Create a new instance. */
public MetricsRegistry(Clock clock, com.codahale.metrics.MetricRegistry impl) {
this(clock, impl, id -> {
Id normalized = Utils.normalize(id);
StringBuilder buf = new StringBuilder();
buf.append(normalized.name());
for (Tag t : normalized.tags()) {
buf.append('.').append(t.key()).append('-').append(t.value());
}
return buf.toString();
});
}
代码示例来源:origin: Netflix/spectator
/** Convert {@code id} to a map. */
static Map<String, String> toMap(Id id) {
Map<String, String> tags = new HashMap<>();
for (Tag t : id.tags()) {
tags.put(t.key(), t.value());
}
tags.put("name", id.name());
return tags;
}
代码示例来源:origin: Netflix/spectator
/**
* Convert an arbitrary implementation of {@link Tag} to BasicTag. When
* used as part of an id this is needed to ensure correct behavior. Alternative
* implementations will likely vary the hashCode/equals causing ids that should
* be equivalent to not match as expected.
*/
static BasicTag convert(Tag t) {
return (t instanceof BasicTag) ? (BasicTag) t : new BasicTag(t.key(), t.value());
}
代码示例来源:origin: com.netflix.spectator/spectator-reg-stateless
private static int operation(Id id) {
for (Tag t : id.tags()) {
if ("statistic".equals(t.key())) {
return operation(t.value());
}
}
LOGGER.warn("invalid statistic for {}, value will be dropped", id);
return UNKNOWN;
}
代码示例来源:origin: Netflix/spectator
private static int operation(Id id) {
for (Tag t : id.tags()) {
if ("statistic".equals(t.key())) {
return operation(t.value());
}
}
LOGGER.warn("invalid statistic for {}, value will be dropped", id);
return UNKNOWN;
}
代码示例来源:origin: org.springframework.metrics/spring-metrics
static List<Measurement> measurements(com.netflix.spectator.api.Meter meter) {
return stream(meter.measure().spliterator(), false)
.map(m ->
new Measurement(
m.id().name(),
stream(m.id().tags().spliterator(), false)
.map(t -> Tag.of(t.key(), t.value()))
.collect(Collectors.toList()),
m.value())
)
.collect(Collectors.toList());
}
代码示例来源:origin: Netflix/spectator
/** Converts a spectator id into a MonitorConfig that can be used by servo. */
MonitorConfig toMonitorConfig(Id id, Tag stat) {
MonitorConfig.Builder builder = new MonitorConfig.Builder(id.name());
if (stat != null) {
builder.withTag(stat.key(), stat.value());
}
for (Tag t : id.tags()) {
builder.withTag(t.key(), t.value());
}
return builder.build();
}
代码示例来源:origin: Netflix/spectator
private String get(Id id, String key) {
for (Tag t : id.tags()) {
if (key.equals(t.key())) {
return t.value();
}
}
return null;
}
代码示例来源:origin: Netflix/spectator
@Override public Id withTags(Iterable<Tag> ts) {
MonitorConfig.Builder builder = new MonitorConfig.Builder(config);
for (Tag t : ts) {
builder.withTag(t.key(), t.value());
}
return new ServoId(builder.build());
}
代码示例来源:origin: Netflix/spectator
private TagsValuePair newTagsValuePair(Measurement m) {
Map<String, String> tags = new HashMap<>();
for (Tag t : m.id().tags()) {
tags.put(t.key(), t.value());
}
tags.put("name", m.id().name());
return new TagsValuePair(tags, m.value());
}
代码示例来源:origin: Netflix/spectator
@Test
public void testSingle() {
ArrayTagSet ts = ArrayTagSet.create("k", "v");
for (Tag t : ts) {
Assertions.assertEquals(t.key(), "k");
Assertions.assertEquals(t.value(), "v");
}
}
内容来源于网络,如有侵权,请联系作者删除!