当前位置: 首页>>代码示例>>Java>>正文


Java Meter类代码示例

本文整理汇总了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());
        }
    };
}
 
开发者ID:micrometer-metrics,项目名称:micrometer,代码行数:19,代码来源:MeterFilter.java

示例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());
        }
    };
}
 
开发者ID:micrometer-metrics,项目名称:micrometer,代码行数:18,代码来源:MeterFilter.java

示例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());
        }
    };
}
 
开发者ID:micrometer-metrics,项目名称:micrometer,代码行数:27,代码来源:MeterFilter.java

示例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
    );
}
 
开发者ID:micrometer-metrics,项目名称:micrometer,代码行数:25,代码来源:StatsdLineBuilder.java

示例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;
}
 
开发者ID:micrometer-metrics,项目名称:micrometer,代码行数:21,代码来源:GraphiteHierarchicalNameMapper.java

示例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();
}
 
开发者ID:line,项目名称:armeria,代码行数:21,代码来源:MoreMeters.java

示例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;
}
 
开发者ID:micrometer-metrics,项目名称:micrometer,代码行数:9,代码来源:CompositeFunctionTimer.java

示例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);
}
 
开发者ID:micrometer-metrics,项目名称:micrometer,代码行数:9,代码来源:CompositeCustomMeter.java

示例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());
        }
    };
}
 
开发者ID:micrometer-metrics,项目名称:micrometer,代码行数:12,代码来源:MeterFilter.java

示例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;
        }
    };
}
 
开发者ID:micrometer-metrics,项目名称:micrometer,代码行数:9,代码来源:MeterFilter.java

示例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;
        }
    };
}
 
开发者ID:micrometer-metrics,项目名称:micrometer,代码行数:9,代码来源:MeterFilter.java

示例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;
        }
    };
}
 
开发者ID:micrometer-metrics,项目名称:micrometer,代码行数:25,代码来源:MeterFilter.java

示例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;
}
 
开发者ID:micrometer-metrics,项目名称:micrometer,代码行数:8,代码来源:PropertyMeterFilter.java

示例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());
}
 
开发者ID:micrometer-metrics,项目名称:micrometer,代码行数:9,代码来源:MeterEquivalence.java

示例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);
}
 
开发者ID:micrometer-metrics,项目名称:micrometer,代码行数:8,代码来源:DropwizardMeterRegistryTest.java


注:本文中的io.micrometer.core.instrument.Meter类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。