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

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

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

Tags.of介绍

暂无

代码示例

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

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

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

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

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

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

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

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

代码示例来源:origin: spring-cloud/spring-cloud-gateway

private void endTimerInner(ServerWebExchange exchange, Sample sample) {
    String outcome = "CUSTOM";
    String status = "CUSTOM";
    HttpStatus statusCode = exchange.getResponse().getStatusCode();
    if (statusCode != null) {
      outcome = statusCode.series().name();
      status = statusCode.name();
    }
    else { // a non standard HTTPS status could be used. Let's be defensive here
      if (exchange.getResponse() instanceof AbstractServerHttpResponse) {
        Integer statusInt = ((AbstractServerHttpResponse) exchange.getResponse())
            .getStatusCodeValue();
        if (statusInt != null) {
          status = String.valueOf(statusInt);
        }
        else {
          status = "NA";
        }
      }
    }
    Route route = exchange.getAttribute(GATEWAY_ROUTE_ATTR);
    Tags tags = Tags.of("outcome", outcome, "status", status, "routeId",
        route.getId(), "routeUri", route.getUri().toString());
    if (log.isTraceEnabled()) {
      log.trace("Stopping timer 'gateway.requests' with tags " + tags);
    }
    sample.stop(meterRegistry.timer("gateway.requests", tags));
  }
}

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

/**
 * Return additional {@link Tag tags} to be associated with the given {@link Cache}.
 * @param cache the cache
 * @return a list of additional tags to associate to that {@code cache}.
 */
protected Iterable<Tag> getAdditionalTags(Cache cache) {
  return Tags.of("name", cache.getName());
}

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

@Override
public Iterable<Tag> getLongRequestTags(HttpServletRequest request, Object handler) {
  return Tags.of(WebMvcTags.method(request), WebMvcTags.uri(request, null));
}

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

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

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

private static Timer timer(
   MeterRegistry meterRegistry, String interactionModel, SignalType signalType, Tag... tags) {
  return meterRegistry.timer(
    "rsocket." + interactionModel, Tags.of(tags).and("signal.type", signalType.name()));
 }
}

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

/**
 * Creates a new {@link DuplexConnection}.
 *
 * @param connectionType the type of connection being monitored
 * @param delegate the {@link DuplexConnection} to delegate to
 * @param meterRegistry the {@link MeterRegistry} to use
 * @param tags additional tags to attach to {@link Meter}s
 * @throws NullPointerException if {@code connectionType}, {@code delegate}, or {@code
 *     meterRegistry} is {@code null}
 */
MicrometerDuplexConnection(
  Type connectionType, DuplexConnection delegate, MeterRegistry meterRegistry, Tag... tags) {
 Objects.requireNonNull(connectionType, "connectionType must not be null");
 this.delegate = Objects.requireNonNull(delegate, "delegate must not be null");
 Objects.requireNonNull(meterRegistry, "meterRegistry must not be null");
 this.close =
   meterRegistry.counter(
     "rsocket.duplex.connection.close",
     Tags.of(tags).and("connection.type", connectionType.name()));
 this.dispose =
   meterRegistry.counter(
     "rsocket.duplex.connection.dispose",
     Tags.of(tags).and("connection.type", connectionType.name()));
 this.frameCounters = new FrameCounters(connectionType, meterRegistry, tags);
}

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

/**
 * Attempt to bind the specified {@link Cache} to the registry. Return {@code true} if
 * the cache is supported and was bound to the registry, {@code false} otherwise.
 * @param cache the cache to handle
 * @param tags the tags to associate with the metrics of that cache
 * @return {@code true} if the {@code cache} is supported and was registered
 */
public boolean bindCacheToRegistry(Cache cache, Tag... tags) {
  MeterBinder meterBinder = getMeterBinder(unwrapIfNecessary(cache), Tags.of(tags));
  if (meterBinder != null) {
    meterBinder.bindTo(this.registry);
    return true;
  }
  return false;
}

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

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

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

@Override
public Iterable<Tag> getTags(HttpServletRequest request, HttpServletResponse response,
    Object handler, Throwable exception) {
  return Tags.of(WebMvcTags.method(request), WebMvcTags.uri(request, response),
      WebMvcTags.exception(exception), WebMvcTags.status(response),
      WebMvcTags.outcome(response));
}

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

/**
 * Record metrics on a ConcurrentMapCache cache.
 *
 * @param registry The registry to bind metrics to.
 * @param cache    The cache to instrument.
 * @param tags     Tags to apply to all recorded metrics. Must be an even number of arguments representing key/value pairs of tags.
 * @return The instrumented cache, unchanged. The original cache is not wrapped or proxied in any way.
 */
public static ConcurrentMapCache monitor(MeterRegistry registry, ConcurrentMapCache cache, String... tags) {
  return monitor(registry, cache, Tags.of(tags));
}

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

default Tags getTags(CamelContext camelContext) {
    return Tags.of(
        SERVICE_NAME, MicrometerEventNotifierService.class.getSimpleName(),
        CAMEL_CONTEXT_TAG, camelContext.getName(),
        EVENT_TYPE_TAG, AbstractRouteEvent.class.getSimpleName());
  }
}

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

private static MeterFilter createMapFilter(Map<String, String> tags) {
  if (tags.isEmpty()) {
    return new MeterFilter() {
    };
  }
  Tags commonTags = Tags.of(tags.entrySet().stream()
      .map((entry) -> Tag.of(entry.getKey(), entry.getValue()))
      .collect(Collectors.toList()));
  return MeterFilter.commonTags(commonTags);
}

代码示例来源:origin: eclipse/hono

@Override
public final void incrementNoCommandReceivedAndTTDExpired(final String tenantId) {
  Objects.requireNonNull(tenantId);
  this.registry.counter(METER_COMMANDS_TTD_EXPIRED,
      Tags.of(MetricsTags.TAG_TENANT, tenantId))
      .increment();
}

代码示例来源:origin: eclipse/hono

@Override
public final void incrementUndeliverableMessages(final String type, final String tenantId) {
  Objects.requireNonNull(type);
  Objects.requireNonNull(tenantId);
  this.registry.counter(METER_MESSAGES_UNDELIVERABLE,
      Tags.of(MetricsTags.TAG_TENANT, tenantId).and(MetricsTags.TAG_TYPE, type))
      .increment();
}

代码示例来源:origin: eclipse/hono

/**
 * Creates the default tag set for a service.
 * 
 * @param name The name of the service.
 * @return A ready to use tag set.
 */
public static Tags forService(final String name) {
  return Tags.of(
      Tag.of(MetricsTags.TAG_HOST, Hostnames.getHostname()),
      Tag.of(MetricsTags.TAG_COMPONENT_TYPE, MetricsTags.VALUE_COMPONENT_TYPE_SERVICE),
      Tag.of(MetricsTags.TAG_COMPONENT_NAME, name));
}

代码示例来源:origin: eclipse/hono

/**
 * Creates the default tag set for a protocol adapter.
 * 
 * @param name The name of the protocol adapter.
 * @return A ready to use tag set.
 */
public static Tags forProtocolAdapter(final String name) {
  return Tags.of(
      Tag.of(MetricsTags.TAG_HOST, Hostnames.getHostname()),
      Tag.of(MetricsTags.TAG_COMPONENT_TYPE, MetricsTags.VALUE_COMPONENT_TYPE_ADAPTER),
      Tag.of(MetricsTags.TAG_COMPONENT_NAME, name));
}

相关文章