io.micrometer.core.instrument.Tags类的使用及代码示例

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

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

Tags介绍

暂无

代码示例

代码示例来源:origin: relayrides/pushy

  1. /**
  2. * Constructs a new Micrometer metrics listener that adds metrics to the given registry with the given list of tags.
  3. *
  4. * @param meterRegistry the registry to which to add metrics
  5. * @param tagKeysAndValues an optional list of tag keys/values to attach to metrics; must be an even number of
  6. * strings representing alternating key/value pairs
  7. */
  8. public MicrometerApnsClientMetricsListener(final MeterRegistry meterRegistry, final String... tagKeysAndValues) {
  9. this(meterRegistry, Tags.of(tagKeysAndValues));
  10. }

代码示例来源:origin: micrometer-metrics/micrometer

  1. @Threads(16)
  2. @Benchmark
  3. public void dotAnd() {
  4. Tags.of("key", "value").and("key2", "value2", "key3", "value3", "key4", "value4", "key5", "value5");
  5. }

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

  1. public DataSourcePoolMetrics(DataSource dataSource,
  2. DataSourcePoolMetadataProvider metadataProvider, String name,
  3. Iterable<Tag> tags) {
  4. Assert.notNull(dataSource, "DataSource must not be null");
  5. Assert.notNull(metadataProvider, "MetadataProvider must not be null");
  6. this.dataSource = dataSource;
  7. this.metadataProvider = new CachingDataSourcePoolMetadataProvider(
  8. metadataProvider);
  9. this.tags = Tags.concat(tags, "name", name);
  10. }

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

  1. @Override
  2. public void process(Exchange exchange) {
  3. Message in = exchange.getIn();
  4. String defaultMetricsName = simple(exchange, getEndpoint().getMetricsName(), String.class);
  5. String finalMetricsName = getStringHeader(in, HEADER_METRIC_NAME, defaultMetricsName);
  6. Iterable<Tag> defaultTags = getEndpoint().getTags();
  7. Iterable<Tag> headerTags = getTagHeader(in, HEADER_METRIC_TAGS, Tags.empty());
  8. Iterable<Tag> finalTags = Tags.concat(defaultTags, headerTags).stream()
  9. .map(tag -> Tag.of(
  10. simple(exchange, tag.getKey(), String.class),
  11. simple(exchange, tag.getValue(), String.class)))
  12. .reduce(Tags.empty(), Tags::and, Tags::and)
  13. .and(Tags.of(
  14. CAMEL_CONTEXT_TAG, getEndpoint().getCamelContext().getName()));
  15. try {
  16. doProcess(exchange, finalMetricsName, finalTags);
  17. } catch (Exception e) {
  18. exchange.setException(e);
  19. } finally {
  20. clearMetricsHeaders(in);
  21. }
  22. }

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

  1. Iterable<Tag> getMetricsTag(Map<String, Object> parameters) {
  2. String tagsString = getAndRemoveParameter(parameters, "tags", String.class, "");
  3. if (tagsString != null && !tagsString.isEmpty()) {
  4. String[] tagStrings = tagsString.split("\\s*,\\s*");
  5. return Stream.of(tagStrings)
  6. .map(s -> Tags.of(s.split("\\s*=\\s*")))
  7. .reduce(Tags.empty(), Tags::and);
  8. }
  9. return Tags.empty();
  10. }

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

  1. @SuppressWarnings({ "unchecked" })
  2. private MeterBinder getMeterBinder(Cache cache, Tags tags) {
  3. Tags cacheTags = tags.and(getAdditionalTags(cache));
  4. return LambdaSafe
  5. .callbacks(CacheMeterBinderProvider.class, this.binderProviders, cache)
  6. .withLogger(CacheMetricsRegistrar.class)
  7. .invokeAnd((binderProvider) -> binderProvider.getMeterBinder(cache,
  8. cacheTags))
  9. .filter(Objects::nonNull).findFirst().orElse(null);
  10. }

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

  1. @Override
  2. public void bindTo(MeterRegistry registry) {
  3. for (FileStore fileStore : FileSystems.getDefault().getFileStores()) {
  4. LOG.debug("Add gauge metric for {}", fileStore.name());
  5. Iterable<Tag> tagsWithPath = Tags.concat(Tags.empty(), "path", fileStore.toString());
  6. Gauge.builder("disk.free", fileStore, exceptionToNonWrapper(FileStore::getUnallocatedSpace))
  7. .tags(tagsWithPath)
  8. .description("Unallocated space for file store")
  9. .baseUnit("bytes")
  10. .strongReference(true)
  11. .register(registry);
  12. Gauge.builder("disk.total", fileStore, exceptionToNonWrapper(FileStore::getTotalSpace))
  13. .tags(tagsWithPath)
  14. .description("Total space for file store")
  15. .baseUnit("bytes")
  16. .strongReference(true)
  17. .register(registry);
  18. Gauge.builder("disk.usable", fileStore, exceptionToNonWrapper(FileStore::getUsableSpace))
  19. .tags(tagsWithPath)
  20. .description("Usable space for file store")
  21. .baseUnit("bytes")
  22. .strongReference(true)
  23. .register(registry);
  24. }
  25. }

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

  1. public MicrometerModule(TimeUnit timeUnit) {
  2. this(timeUnit, name -> true, Tags.empty());
  3. }

代码示例来源:origin: com.hotels.road/road-offramp-service

  1. private AtomicLong getPartitionLatencyHolder(int partition) {
  2. return partitionLatencies.computeIfAbsent(partition, k -> {
  3. Tags tags = roadStreamTags.and("partition", Integer.toString(k));
  4. AtomicLong latencyHolder = new AtomicLong();
  5. registry.more().timeGauge(OFFRAMP + LATENCY, tags, latencyHolder, MILLISECONDS, AtomicLong::doubleValue);
  6. return latencyHolder;
  7. });
  8. }

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

  1. @Override
  2. public TomcatMetrics get() {
  3. return new TomcatMetrics(manager, Tags.empty());
  4. }
  5. }

代码示例来源:origin: line/armeria

  1. /**
  2. * Returns a {@link MeterIdPrefixFunction} that returns a newly created {@link MeterIdPrefix} which has
  3. * the specified label added.
  4. */
  5. default MeterIdPrefixFunction withTags(String... keyValues) {
  6. requireNonNull(keyValues, "keyValues");
  7. return withTags(Tags.of(keyValues));
  8. }

代码示例来源:origin: rsocket/rsocket-java

  1. private static Counter counter(
  2. Type connectionType, MeterRegistry meterRegistry, String frameType, Tag... tags) {
  3. return meterRegistry.counter(
  4. "rsocket.frame",
  5. Tags.of(tags).and("connection.type", connectionType.name()).and("frame.type", frameType));
  6. }
  7. }

代码示例来源:origin: com.hotels.road/road-offramp-service

  1. public <T> T record(TimerTag timerTag, Supplier<T> supplier) {
  2. return registry.timer(OFFRAMP_TIMER, roadStreamTags.and(timerTag.tag)).record(supplier);
  3. }

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

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

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

  1. private String event(Meter.Id id, Attribute... attributes) {
  2. return event(id, Tags.empty(), attributes);
  3. }

代码示例来源:origin: micrometer-metrics/micrometer

  1. @Threads(16)
  2. @Benchmark
  3. public void of() {
  4. Tags.of("key", "value", "key2", "value2", "key3", "value3", "key4", "value4", "key5", "value5");
  5. }

代码示例来源:origin: rsocket/rsocket-java

  1. private static Counter counter(
  2. MeterRegistry meterRegistry, String interactionModel, SignalType signalType, Tag... tags) {
  3. return meterRegistry.counter(
  4. "rsocket." + interactionModel, Tags.of(tags).and("signal.type", signalType.name()));
  5. }
  6. }

代码示例来源:origin: com.hotels.road/road-offramp-service

  1. public void record(TimerTag timerTag, Runnable runnable) {
  2. registry.timer(OFFRAMP_TIMER, roadStreamTags.and(timerTag.tag)).record(runnable);
  3. }

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

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

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

  1. @Override
  2. public ScheduledExecutorService newScheduledThreadPool(ThreadPoolProfile profile, ThreadFactory threadFactory) {
  3. ScheduledExecutorService executorService = threadPoolFactory.newScheduledThreadPool(profile, threadFactory);
  4. String executorServiceName = name(profile.getId());
  5. return new TimedScheduledExecutorService(meterRegistry, executorService, executorServiceName, Tags.empty());
  6. }

相关文章