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


Java Collector.Type方法代码示例

本文整理汇总了Java中io.prometheus.client.Collector.Type方法的典型用法代码示例。如果您正苦于以下问题:Java Collector.Type方法的具体用法?Java Collector.Type怎么用?Java Collector.Type使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在io.prometheus.client.Collector的用法示例。


在下文中一共展示了Collector.Type方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: collectorByName

import io.prometheus.client.Collector; //导入方法依赖的package包/类
private MicrometerCollector collectorByName(Meter.Id id, Collector.Type type) {
    return collectorMap.compute(getConventionName(id), (name, existingCollector) -> {
        if(existingCollector == null) {
            return new MicrometerCollector(id, type, config().namingConvention(), prometheusConfig).register(registry);
        }

        List<String> tagKeys = getConventionTags(id).stream().map(Tag::getKey).collect(toList());
        if(existingCollector.getTagKeys().equals(tagKeys)) {
            return existingCollector;
        }

        throw new IllegalArgumentException("Prometheus requires that all meters with the same name have the same" +
            " set of tag keys. There is already an existing meter containing tag keys [" +
            existingCollector.getTagKeys().stream().collect(joining(", ")) + "]. The meter you are attempting to register" +
            " has keys [" + tagKeys.stream().collect(joining(", ")) + "].");
    });
}
 
开发者ID:micrometer-metrics,项目名称:micrometer,代码行数:18,代码来源:PrometheusMeterRegistry.java

示例2: typeString

import io.prometheus.client.Collector; //导入方法依赖的package包/类
private static String typeString(Collector.Type t) {
  switch (t) {
    case GAUGE:
      return "gauge";
    case COUNTER:
      return "counter";
    case SUMMARY:
      return "summary";
    case HISTOGRAM:
      return "histogram";
    default:
      return "untyped";
  }
}
 
开发者ID:prometheus,项目名称:client_java,代码行数:15,代码来源:TextFormat.java

示例3: newMeter

import io.prometheus.client.Collector; //导入方法依赖的package包/类
@Override
protected Meter newMeter(Meter.Id id, Meter.Type type, Iterable<Measurement> measurements) {
    Collector.Type promType = Collector.Type.UNTYPED;
    switch (type) {
        case Counter:
            promType = Collector.Type.COUNTER;
            break;
        case Gauge:
            promType = Collector.Type.GAUGE;
            break;
        case DistributionSummary:
        case Timer:
            promType = Collector.Type.SUMMARY;
            break;
    }

    MicrometerCollector collector = collectorByName(id, promType);
    List<String> tagValues = tagValues(id);

    collector.add((conventionName, tagKeys) -> {
        List<String> statKeys = new LinkedList<>(tagKeys);
        statKeys.add("statistic");

        return stream(measurements.spliterator(), false)
            .map(m -> {
                List<String> statValues = new LinkedList<>(tagValues);
                statValues.add(m.getStatistic().toString());

                String name = conventionName;
                switch (m.getStatistic()) {
                    case Total:
                    case TotalTime:
                        name += "_sum";
                        break;
                    case Max:
                        name += "_max";
                        break;
                    case ActiveTasks:
                        name += "_active_count";
                        break;
                    case Duration:
                        name += "_duration_sum";
                        break;
                }

                return new Collector.MetricFamilySamples.Sample(name, tagKeys, tagValues, m.getValue());
            });
    });

    return new DefaultMeter(id, type, measurements);
}
 
开发者ID:micrometer-metrics,项目名称:micrometer,代码行数:52,代码来源:PrometheusMeterRegistry.java


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