io.micrometer.core.instrument.Tags.concat()方法的使用及代码示例

x33g5p2x  于2022-01-30 转载在 其他  
字(7.6k)|赞(0)|评价(0)|浏览(151)

本文整理了Java中io.micrometer.core.instrument.Tags.concat()方法的一些代码示例,展示了Tags.concat()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Tags.concat()方法的具体详情如下:
包路径:io.micrometer.core.instrument.Tags
类名称:Tags
方法名:concat

Tags.concat介绍

暂无

代码示例

代码示例来源:origin: org.springframework.boot/spring-boot-actuator

public DataSourcePoolMetrics(DataSource dataSource,
    DataSourcePoolMetadataProvider metadataProvider, String name,
    Iterable<Tag> tags) {
  Assert.notNull(dataSource, "DataSource must not be null");
  Assert.notNull(metadataProvider, "MetadataProvider must not be null");
  this.dataSource = dataSource;
  this.metadataProvider = new CachingDataSourcePoolMetadataProvider(
      metadataProvider);
  this.tags = Tags.concat(tags, "name", name);
}

代码示例来源:origin: io.micrometer/micrometer-spring-legacy

private void addSourceMetrics(MeterRegistry registry) {
  for (String source : configurer.getSourceNames()) {
    MessageSourceMetrics sourceMetrics = configurer.getSourceMetrics(source);
    Iterable<Tag> tagsWithSource = Tags.concat(tags, "source", source);
    FunctionCounter.builder("spring.integration.source.messages", sourceMetrics, MessageSourceMetrics::getMessageCount)
      .tags(tagsWithSource)
      .description("The number of successful handler calls")
      .register(registry);
  }
}

代码示例来源:origin: io.micrometer/micrometer-registry-atlas

@SuppressWarnings("ConstantConditions")
@Override
protected io.micrometer.core.instrument.DistributionSummary newDistributionSummary(Meter.Id id, DistributionStatisticConfig distributionStatisticConfig,
                                          double scale) {
  com.netflix.spectator.api.DistributionSummary internalSummary;
  if (distributionStatisticConfig.isPercentileHistogram()) {
    // This doesn't report the normal count/totalTime/max stats, so we treat it as additive
    internalSummary = PercentileDistributionSummary.get(registry, spectatorId(id));
  } else {
    internalSummary = registry.distributionSummary(spectatorId(id));
  }
  SpectatorDistributionSummary summary = new SpectatorDistributionSummary(id, internalSummary, clock, distributionStatisticConfig, scale);
  HistogramGauges.register(summary, this,
      percentile -> id.getName(),
      percentile -> Tags.concat(id.getTagsAsIterable(), "percentile", DoubleFormat.decimalOrNan(percentile.percentile())),
      ValueAtPercentile::value,
      bucket -> id.getName(),
      bucket -> Tags.concat(id.getTagsAsIterable(), "sla", DoubleFormat.decimalOrWhole(bucket.bucket())));
  return summary;
}

代码示例来源:origin: io.micrometer/micrometer-registry-atlas

@SuppressWarnings("ConstantConditions")
@Override
protected Timer newTimer(Meter.Id id, DistributionStatisticConfig distributionStatisticConfig, PauseDetector pauseDetector) {
  com.netflix.spectator.api.Timer internalTimer;
  if (distributionStatisticConfig.isPercentileHistogram()) {
    // This doesn't report the normal count/totalTime/max stats, so we treat it as additive
    internalTimer = PercentileTimer.get(registry, spectatorId(id));
  } else {
    internalTimer = registry.timer(spectatorId(id));
  }
  SpectatorTimer timer = new SpectatorTimer(id, internalTimer, clock, distributionStatisticConfig, pauseDetector, getBaseTimeUnit());
  HistogramGauges.register(timer, this,
      percentile -> id.getName(),
      percentile -> Tags.concat(id.getTagsAsIterable(), "percentile", DoubleFormat.decimalOrNan(percentile.percentile())),
      percentile -> percentile.value(timer.baseTimeUnit()),
      bucket -> id.getName(),
      bucket -> Tags.concat(id.getTagsAsIterable(), "sla", DoubleFormat.decimalOrWhole(bucket.bucket(timer.baseTimeUnit()))));
  return timer;
}

代码示例来源:origin: org.apache.camel/camel-micrometer

@Override
public void process(Exchange exchange) {
  Message in = exchange.getIn();
  String defaultMetricsName = simple(exchange, getEndpoint().getMetricsName(), String.class);
  String finalMetricsName = getStringHeader(in, HEADER_METRIC_NAME, defaultMetricsName);
  Iterable<Tag> defaultTags = getEndpoint().getTags();
  Iterable<Tag> headerTags = getTagHeader(in, HEADER_METRIC_TAGS, Tags.empty());
  Iterable<Tag> finalTags = Tags.concat(defaultTags, headerTags).stream()
      .map(tag -> Tag.of(
          simple(exchange, tag.getKey(), String.class),
          simple(exchange, tag.getValue(), String.class)))
      .reduce(Tags.empty(), Tags::and, Tags::and)
      .and(Tags.of(
          CAMEL_CONTEXT_TAG, getEndpoint().getCamelContext().getName()));
  try {
    doProcess(exchange, finalMetricsName, finalTags);
  } catch (Exception e) {
    exchange.setException(e);
  } finally {
    clearMetricsHeaders(in);
  }
}

代码示例来源:origin: org.eclipse.che.core/che-core-metrics-core

@Override
public void bindTo(MeterRegistry registry) {
 for (FileStore fileStore : FileSystems.getDefault().getFileStores()) {
  LOG.debug("Add gauge metric for {}", fileStore.name());
  Iterable<Tag> tagsWithPath = Tags.concat(Tags.empty(), "path", fileStore.toString());
  Gauge.builder("disk.free", fileStore, exceptionToNonWrapper(FileStore::getUnallocatedSpace))
    .tags(tagsWithPath)
    .description("Unallocated space for file store")
    .baseUnit("bytes")
    .strongReference(true)
    .register(registry);
  Gauge.builder("disk.total", fileStore, exceptionToNonWrapper(FileStore::getTotalSpace))
    .tags(tagsWithPath)
    .description("Total space for file store")
    .baseUnit("bytes")
    .strongReference(true)
    .register(registry);
  Gauge.builder("disk.usable", fileStore, exceptionToNonWrapper(FileStore::getUsableSpace))
    .tags(tagsWithPath)
    .description("Usable space for file store")
    .baseUnit("bytes")
    .strongReference(true)
    .register(registry);
 }
}

代码示例来源:origin: io.micrometer/micrometer-spring-legacy

private void addChannelMetrics(MeterRegistry registry) {
  for (String channel : configurer.getChannelNames()) {
    MessageChannelMetrics channelMetrics = configurer.getChannelMetrics(channel);
    Iterable<Tag> tagsWithChannel = Tags.concat(tags, "channel", channel);
    FunctionCounter.builder("spring.integration.channel.sendErrors", channelMetrics, MessageChannelMetrics::getSendErrorCount)
      .tags(tagsWithChannel)
      .description("The number of failed sends (either throwing an exception or rejected by the channel)")
      .register(registry);
    FunctionCounter.builder("spring.integration.channel.sends", channelMetrics, MessageChannelMetrics::getSendCount)
      .tags(tagsWithChannel)
      .description("The number of successful sends")
      .register(registry);
    if (channelMetrics instanceof PollableChannelManagement) {
      FunctionCounter.builder("spring.integration.receives", (PollableChannelManagement) channelMetrics, PollableChannelManagement::getReceiveCount)
        .tags(tagsWithChannel)
        .description("The number of messages received")
        .register(registry);
    }
  }
}

代码示例来源:origin: io.micrometer/micrometer-spring-legacy

private void addHandlerMetrics(MeterRegistry registry) {
  for (String handler : configurer.getHandlerNames()) {
    MessageHandlerMetrics handlerMetrics = configurer.getHandlerMetrics(handler);
    Iterable<Tag> tagsWithHandler = Tags.concat(tags, "handler", handler);
    TimeGauge.builder("spring.integration.handler.duration.max", handlerMetrics, TimeUnit.MILLISECONDS, MessageHandlerMetrics::getMaxDuration)
      .tags(tagsWithHandler)
      .description("The maximum handler duration")
      .register(registry);
    TimeGauge.builder("spring.integration.handler.duration.min", handlerMetrics, TimeUnit.MILLISECONDS, MessageHandlerMetrics::getMinDuration)
      .tags(tagsWithHandler)
      .description("The minimum handler duration")
      .register(registry);
    TimeGauge.builder("spring.integration.handler.duration.mean", handlerMetrics, TimeUnit.MILLISECONDS, MessageHandlerMetrics::getMeanDuration)
      .tags(tagsWithHandler)
      .description("The mean handler duration")
      .register(registry);
    Gauge.builder("spring.integration.handler.activeCount", handlerMetrics, MessageHandlerMetrics::getActiveCount)
      .tags(tagsWithHandler)
      .description("The number of active handlers")
      .register(registry);
  }
}

相关文章