本文整理汇总了Java中io.micrometer.core.instrument.Meter类的典型用法代码示例。如果您正苦于以下问题:Java Meter类的具体用法?Java Meter怎么用?Java Meter使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
Meter类属于io.micrometer.core.instrument包,在下文中一共展示了Meter类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: renameTag
import io.micrometer.core.instrument.Meter; //导入依赖的package包/类
static MeterFilter renameTag(String metricPrefix, String fromTagKey, String toTagKey) {
return new MeterFilter() {
@Override
public Meter.Id map(Meter.Id id) {
if (!id.getName().startsWith(metricPrefix))
return id;
List<Tag> tags = new ArrayList<>();
for (Tag tag : id.getTags()) {
if (tag.getKey().equals(fromTagKey))
tags.add(Tag.of(toTagKey, tag.getValue()));
else tags.add(tag);
}
return new Meter.Id(id.getName(), tags, id.getBaseUnit(), id.getDescription(), id.getType());
}
};
}
示例2: ignoreTags
import io.micrometer.core.instrument.Meter; //导入依赖的package包/类
static MeterFilter ignoreTags(String... tagKeys) {
return new MeterFilter() {
@Override
public Meter.Id map(Meter.Id id) {
List<Tag> tags = stream(id.getTags().spliterator(), false)
.filter(t -> {
for (String tagKey : tagKeys) {
if (t.getKey().equals(tagKey))
return false;
}
return true;
}).collect(Collectors.toList());
return new Meter.Id(id.getName(), tags, id.getBaseUnit(), id.getDescription(), id.getType());
}
};
}
示例3: replaceTagValues
import io.micrometer.core.instrument.Meter; //导入依赖的package包/类
/**
* @param tagKey The tag key for which replacements should be made
* @param replacement The value to replace with
* @param exceptions All a matching tag with this value to retain its original value
* @author Clint Checketts
*/
static MeterFilter replaceTagValues(String tagKey, Function<String, String> replacement, String... exceptions) {
return new MeterFilter() {
@Override
public Meter.Id map(Meter.Id id) {
List<Tag> tags = stream(id.getTags().spliterator(), false)
.map(t -> {
if (!t.getKey().equals(tagKey))
return t;
for (String exception : exceptions) {
if (t.getValue().equals(exception))
return t;
}
return Tag.of(tagKey, replacement.apply(t.getValue()));
})
.collect(Collectors.toList());
return new Meter.Id(id.getName(), tags, id.getBaseUnit(), id.getDescription(), id.getType());
}
};
}
示例4: StatsdLineBuilder
import io.micrometer.core.instrument.Meter; //导入依赖的package包/类
StatsdLineBuilder(Meter.Id id, StatsdFlavor flavor, HierarchicalNameMapper nameMapper, MeterRegistry.Config config) {
this.id = id;
this.flavor = flavor;
this.nameMapper = nameMapper;
this.config = config;
// service:payroll,region:us-west
this.datadogTagString = memoize(convention ->
id.getTags().iterator().hasNext() ?
id.getConventionTags(convention).stream()
.map(t -> t.getKey() + ":" + t.getValue())
.collect(Collectors.joining(","))
: null
);
// service=payroll,region=us-west
this.telegrafTagString = memoize(convention ->
id.getTags().iterator().hasNext() ?
id.getConventionTags(convention).stream()
.map(t -> t.getKey() + "=" + t.getValue())
.collect(Collectors.joining(","))
: null
);
}
示例5: toHierarchicalName
import io.micrometer.core.instrument.Meter; //导入依赖的package包/类
@Override
public String toHierarchicalName(Meter.Id id, NamingConvention convention) {
StringBuilder prefix = new StringBuilder();
StringBuilder tags = new StringBuilder();
if (id.getTags().iterator().hasNext()) {
conventionTags: for (Tag tag : id.getConventionTags(convention)) {
for (String tagPrefix : tagsAsPrefix) {
if (tag.getKey().equals(tagPrefix)) {
prefix.append(tag.getValue()).append(".");
continue conventionTags;
}
}
tags.append(("." + tag.getKey() + "." + tag.getValue()).replace(" ", "_"));
}
}
return prefix.toString() + id.getConventionName(convention) + tags;
}
示例6: measurementName
import io.micrometer.core.instrument.Meter; //导入依赖的package包/类
private static String measurementName(Meter.Id id, Measurement measurement) {
final StringBuilder buf = new StringBuilder();
// Append name.
buf.append(id.getName());
// Append statistic.
buf.append('#');
buf.append(CaseFormat.UPPER_CAMEL.to(CaseFormat.LOWER_CAMEL, measurement.getStatistic().name()));
// Append tags if there are any.
final Iterator<Tag> tagsIterator = id.getTags().iterator();
if (tagsIterator.hasNext()) {
buf.append('{');
tagsIterator.forEachRemaining(tag -> buf.append(tag.getKey()).append('=')
.append(tag.getValue()).append(','));
buf.setCharAt(buf.length() - 1, '}');
}
return buf.toString();
}
示例7: CompositeFunctionTimer
import io.micrometer.core.instrument.Meter; //导入依赖的package包/类
CompositeFunctionTimer(Meter.Id id, T obj, ToLongFunction<T> countFunction,
ToDoubleFunction<T> totalTimeFunction, TimeUnit totalTimeFunctionUnits) {
super(id);
this.ref = new WeakReference<>(obj);
this.countFunction = countFunction;
this.totalTimeFunction = totalTimeFunction;
this.totalTimeFunctionUnits = totalTimeFunctionUnits;
}
示例8: add
import io.micrometer.core.instrument.Meter; //导入依赖的package包/类
@Override
public void add(MeterRegistry registry) {
Meter.builder(getId().getName(), getType(), measure())
.tags(getId().getTags())
.description(getId().getDescription())
.baseUnit(getId().getBaseUnit())
.register(registry);
}
示例9: commonTags
import io.micrometer.core.instrument.Meter; //导入依赖的package包/类
static MeterFilter commonTags(Iterable<Tag> tags) {
return new MeterFilter() {
@Override
public Meter.Id map(Meter.Id id) {
List<Tag> allTags = new ArrayList<>();
id.getTags().forEach(allTags::add);
tags.forEach(allTags::add);
return new Meter.Id(id.getName(), allTags, id.getBaseUnit(), id.getDescription(), id.getType());
}
};
}
示例10: accept
import io.micrometer.core.instrument.Meter; //导入依赖的package包/类
static MeterFilter accept(Predicate<Meter.Id> iff) {
return new MeterFilter() {
@Override
public MeterFilterReply accept(Meter.Id id) {
return iff.test(id) ? MeterFilterReply.ACCEPT : MeterFilterReply.NEUTRAL;
}
};
}
示例11: deny
import io.micrometer.core.instrument.Meter; //导入依赖的package包/类
static MeterFilter deny(Predicate<Meter.Id> iff) {
return new MeterFilter() {
@Override
public MeterFilterReply accept(Meter.Id id) {
return iff.test(id) ? MeterFilterReply.DENY : MeterFilterReply.NEUTRAL;
}
};
}
示例12: maximumAllowableMetrics
import io.micrometer.core.instrument.Meter; //导入依赖的package包/类
/**
* Useful for cost-control in monitoring systems which charge directly or indirectly by the
* total number of time series you generate.
* <p>
* While this filter doesn't discriminate between your most critical and less useful metrics in
* deciding what to drop (all the metrics you intend to use should fit below this threshold),
* it can effectively cap your risk of an accidentally high-cardiality metric costing too much.
*
* @param maximumTimeSeries The total number of unique name/tag permutations allowed before filtering kicks in.
*/
static MeterFilter maximumAllowableMetrics(int maximumTimeSeries) {
return new MeterFilter() {
private final Set<Meter.Id> ids = ConcurrentHashMap.newKeySet();
@Override
public MeterFilterReply accept(Meter.Id id) {
if (ids.size() > maximumTimeSeries)
return MeterFilterReply.DENY;
ids.add(id);
return ids.size() > maximumTimeSeries ? MeterFilterReply.DENY : MeterFilterReply.NEUTRAL;
}
};
}
示例13: accept
import io.micrometer.core.instrument.Meter; //导入依赖的package包/类
@Override
public MeterFilterReply accept(Meter.Id id) {
Boolean enabled = getMostSpecific(id.getName(), "enabled", Boolean.class);
if(enabled == null)
return MeterFilterReply.NEUTRAL;
return enabled ? MeterFilterReply.ACCEPT : MeterFilterReply.DENY;
}
示例14: equals
import io.micrometer.core.instrument.Meter; //导入依赖的package包/类
public static boolean equals(Meter m1, Object o) {
if (m1 == null && o != null) return false;
if (o == null && m1 != null) return false;
if (!(o instanceof Meter)) return false;
if (m1 == o) return true;
Meter m2 = (Meter) o;
return m1.getId().equals(m2.getId());
}
示例15: customMeasurementsThatDifferOnlyInTagValue
import io.micrometer.core.instrument.Meter; //导入依赖的package包/类
@Test
void customMeasurementsThatDifferOnlyInTagValue() {
Meter.builder("my.custom", Meter.Type.Gauge, Arrays.asList(
new Measurement(() -> 1.0, Statistic.Count),
new Measurement(() -> 2.0, Statistic.Total)
)).register(registry);
}